Change to support new ARB editing.
svn:revision:376 cvs:account:mike cvs:branch:trunk
This commit is contained in:
1 parent
ce6fb0e282
commit
ea7423aa0b
10 files changed
+1072
-482
No files matched your search
+95
-52
@@ -53,6 +53,7 @@ static void ars_anal();
|
||||
|
||||
static union record temp_rec; /* local copy of es_rec */
|
||||
float tot_vol, tot_area;
|
||||
int type; /* comgeom type */
|
||||
|
||||
void
|
||||
f_analyze()
|
||||
@@ -110,6 +111,8 @@ f_analyze()
|
||||
(void)printf("%s: not a solid \n",cmd_args[i]);
|
||||
return;
|
||||
}
|
||||
if(temp_rec.s.s_cgtype < 0)
|
||||
temp_rec.s.s_cgtype *= -1;
|
||||
do_list(ndp);
|
||||
do_anal();
|
||||
}
|
||||
@@ -149,6 +152,16 @@ do_anal()
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* edge definition array */
|
||||
static int nedge[5][24] = {
|
||||
{0,1, 1,2, 2,0, 0,3, 3,2, 1,3, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, /* ARB4 */
|
||||
{0,1, 1,2, 2,3, 0,3, 0,4, 1,4, 2,4, 3,4, -1,-1,-1,-1,-1,-1,-1,-1}, /* ARB5 */
|
||||
{0,1, 1,2, 2,3, 0,3, 0,4, 1,4, 2,5, 3,5, 4,5, -1,-1,-1,-1,-1,-1}, /* ARB6 */
|
||||
{0,1, 1,2, 2,3, 0,3, 0,4, 3,4, 1,5, 2,6, 4,5, 5,6, 4,6, -1,-1}, /* ARB7 */
|
||||
{0,1, 1,2, 2,3, 0,3, 0,4, 4,5, 1,5, 5,6, 6,7, 4,7, 3,7, 2,6},
|
||||
};
|
||||
|
||||
static void
|
||||
arb_anal()
|
||||
{
|
||||
@@ -161,6 +174,15 @@ arb_anal()
|
||||
|
||||
tot_area = tot_vol = 0.0;
|
||||
|
||||
type = temp_rec.s.s_cgtype;
|
||||
if( type < 0 )
|
||||
type *= -1;
|
||||
if(type == RPP || type == BOX)
|
||||
type = ARB8;
|
||||
if(type == RAW)
|
||||
type = ARB6;
|
||||
type -= 4;
|
||||
|
||||
/* analyze each face */
|
||||
(void)printf("\n--------------------------------------------------------------------------\n");
|
||||
(void)printf("| FACE | ROT FB | PLANE EQUATION | SURFACE AREA |\n");
|
||||
@@ -173,49 +195,50 @@ arb_anal()
|
||||
/* analyze each edge */
|
||||
(void)printf(" | EDGE LEN | EDGE LEN | EDGE LEN | EDGE LEN |\n");
|
||||
(void)printf(" |---------------|---------------|---------------|---------------|\n ");
|
||||
for(i=0; i<12; i++)
|
||||
|
||||
/* set up the records for arb4's and arb6's */
|
||||
if( (type+4) == ARB4 ) {
|
||||
VMOVE(&temp_rec.s.s_values[9], &temp_rec.s.s_values[12]);
|
||||
}
|
||||
if( (type+4) == ARB6 ) {
|
||||
VMOVE(&temp_rec.s.s_values[15], &temp_rec.s.s_values[18]);
|
||||
}
|
||||
for(i=0; i<12; i++) {
|
||||
anal_edge( i );
|
||||
if( nedge[type][i*2] == -1 )
|
||||
break;
|
||||
}
|
||||
|
||||
(void)printf(" -----------------------------------------------------------------\n");
|
||||
|
||||
/* put records back */
|
||||
if( (type+4) == ARB4 ) {
|
||||
VMOVE(&temp_rec.s.s_values[9], &temp_rec.s.s_values[0]);
|
||||
}
|
||||
if( (type+4) == ARB6 ) {
|
||||
VMOVE(&temp_rec.s.s_values[15], &temp_rec.s.s_values[12]);
|
||||
}
|
||||
/* find the volume - break arb8 into 6 arb4s */
|
||||
for(i=0; i<6; i++)
|
||||
find_vol( i );
|
||||
|
||||
(void)printf(" | Surface Area = %15.3f Volume = %18.3f |\n",
|
||||
tot_area*base2local*base2local,
|
||||
tot_vol*base2local*base2local*base2local);
|
||||
(void)printf(" | Volume = %18.3f Surface Area = %15.3f |\n",
|
||||
tot_vol*base2local*base2local*base2local,
|
||||
tot_area*base2local*base2local);
|
||||
(void)printf(" | %18.3f gal |\n",tot_vol/3787878.79);
|
||||
(void)printf(" -----------------------------------------------------------------\n");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* face definition array */
|
||||
static int nface[6][4] = {
|
||||
{0, 1, 2, 3},
|
||||
{4, 5, 6, 7},
|
||||
{0, 4, 7, 3},
|
||||
{1, 2, 6, 5},
|
||||
{3, 2, 6, 7},
|
||||
{0, 1, 5, 4},
|
||||
/* ARB face printout array */
|
||||
static int prface[5][6] = {
|
||||
{123, 124, 234, 134, -111, -111}, /* ARB4 */
|
||||
{1234, 125, 235, 345, 145, -111}, /* ARB5 */
|
||||
{1234, 2365, 1564, 512, 634, -111}, /* ARB6 */
|
||||
{1234, 567, 145, 2376, 1265, 4375}, /* ARB7 */
|
||||
{1234, 5678, 1584, 2376, 1265, 4378}, /* ARB8 */
|
||||
};
|
||||
|
||||
/* edge definition array */
|
||||
static int nedge[12][2] = {
|
||||
{0, 1},
|
||||
{1, 2},
|
||||
{2, 3},
|
||||
{3, 0},
|
||||
{0, 4},
|
||||
{4, 5},
|
||||
{5, 1},
|
||||
{5, 6},
|
||||
{6, 7},
|
||||
{7, 4},
|
||||
{7, 3},
|
||||
{2, 6},
|
||||
};
|
||||
|
||||
/* division of an arb8 into 6 arb4s */
|
||||
static int farb4[6][4] = {
|
||||
{0, 1, 2, 4},
|
||||
@@ -239,34 +262,37 @@ int face;
|
||||
static float temp, area[2], len[6];
|
||||
static vect_t v_temp;
|
||||
|
||||
a = nface[face][0];
|
||||
b = nface[face][1];
|
||||
c = nface[face][2];
|
||||
d = nface[face][3];
|
||||
a = faces[type][face*4+0];
|
||||
b = faces[type][face*4+1];
|
||||
c = faces[type][face*4+2];
|
||||
d = faces[type][face*4+3];
|
||||
|
||||
if(a == -1)
|
||||
return;
|
||||
|
||||
/* find plane eqn for this face */
|
||||
if( plane(a, b, c, d, &temp_rec.s) >= 0 ) {
|
||||
if( planeqn(6, a, b, c, &temp_rec.s) ) {
|
||||
(void)printf("| %d%d%d%d ***NOT A PLANE*** |\n",
|
||||
a+1,b+1,c+1,d+1);
|
||||
return;
|
||||
}
|
||||
|
||||
/* es_plant[] contains normalized eqn of plane of this face
|
||||
/* es_peqn[6][] contains normalized eqn of plane of this face
|
||||
* find the dir cos, rot, fb angles
|
||||
*/
|
||||
findang( angles, es_plant );
|
||||
findang( angles, &es_peqn[6][0] );
|
||||
|
||||
/* find the surface area of this face */
|
||||
for(i=0; i<3; i++) {
|
||||
j = nface[face][i];
|
||||
k = nface[face][i+1];
|
||||
j = faces[type][face*4+i];
|
||||
k = faces[type][face*4+i+1];
|
||||
VSUB2(v_temp, &temp_rec.s.s_values[k*3], &temp_rec.s.s_values[j*3]);
|
||||
len[i] = MAGNITUDE( v_temp );
|
||||
}
|
||||
len[4] = len[2];
|
||||
j = nface[face][0];
|
||||
j = faces[type][face*4+0];
|
||||
for(i=2; i<4; i++) {
|
||||
k = nface[face][i];
|
||||
k = faces[type][face*4+i];
|
||||
VSUB2(v_temp, &temp_rec.s.s_values[k*3], &temp_rec.s.s_values[j*3]);
|
||||
len[((i*2)-1)] = MAGNITUDE( v_temp );
|
||||
}
|
||||
@@ -279,9 +305,9 @@ int face;
|
||||
tot_area += area[i];
|
||||
}
|
||||
|
||||
(void)printf("| %d%d%d%d |",a+1,b+1,c+1,d+1);
|
||||
(void)printf("| %4d |",prface[type][face]);
|
||||
(void)printf(" %6.2f %6.2f | %5.2f %5.2f %5.2f %10.2f |",angles[3],angles[4],
|
||||
es_plant[0],es_plant[1],es_plant[2],es_plant[3]*base2local);
|
||||
es_peqn[6][0],es_peqn[6][1],es_peqn[6][2],es_peqn[6][3]*base2local);
|
||||
(void)printf(" %13.3f |\n",(area[0]+area[1])*base2local*base2local);
|
||||
}
|
||||
|
||||
@@ -293,8 +319,24 @@ int edge;
|
||||
register int a, b;
|
||||
static vect_t v_temp;
|
||||
|
||||
a = nedge[edge][0];
|
||||
b = nedge[edge][1];
|
||||
a = nedge[type][edge*2];
|
||||
b = nedge[type][edge*2+1];
|
||||
|
||||
if( b == -1 ) {
|
||||
/* fill out the line */
|
||||
if( (a = edge%4) == 0 )
|
||||
return;
|
||||
if( a == 1 ) {
|
||||
(void)printf(" | | | |\n ");
|
||||
return;
|
||||
}
|
||||
if( a == 2 ) {
|
||||
(void)printf(" | | |\n ");
|
||||
return;
|
||||
}
|
||||
(void)printf(" | |\n ");
|
||||
return;
|
||||
}
|
||||
|
||||
VSUB2(v_temp, &temp_rec.s.s_values[b*3], &temp_rec.s.s_values[a*3]);
|
||||
(void)printf(" | %d%d %8.2f",a+1,b+1,MAGNITUDE(v_temp)*base2local);
|
||||
@@ -324,9 +366,9 @@ int loc;
|
||||
|
||||
vol = 0.0; /* volume of this arb */
|
||||
|
||||
if( planeqn(a, b, c, &temp_rec.s) ) {
|
||||
if( planeqn(6, a, b, c, &temp_rec.s) == 0 ) {
|
||||
/* have a good arb4 - find its volume */
|
||||
height = fabs(es_plant[3] - VDOT(es_plant, &temp_rec.s.s_values[d*3]));
|
||||
height = fabs(es_peqn[6][3] - VDOT(&es_peqn[6][0], &temp_rec.s.s_values[d*3]));
|
||||
VSUB2(v_temp, &temp_rec.s.s_values[b*3], &temp_rec.s.s_values[a*3]);
|
||||
len[0] = MAGNITUDE(v_temp);
|
||||
VSUB2(v_temp, &temp_rec.s.s_values[c*3], &temp_rec.s.s_values[a*3]);
|
||||
@@ -355,8 +397,8 @@ tor_anal()
|
||||
vol = 2.0 * pi * pi * r1 * r2 * r2;
|
||||
sur_area = 4.0 * pi * pi * r1 * r2;
|
||||
|
||||
(void)printf("Vol = %.4f Surface Area = %.4f\n",
|
||||
vol*base2local*base2local*base2local,
|
||||
(void)printf("Vol = %.4f (%.4f gal) Surface Area = %.4f\n",
|
||||
vol*base2local*base2local*base2local,vol/3787878.79,
|
||||
sur_area*base2local*base2local);
|
||||
|
||||
return;
|
||||
@@ -371,15 +413,16 @@ ell_anal()
|
||||
{
|
||||
float ma, mb, mc;
|
||||
float ecc, major, minor;
|
||||
int type = 0;
|
||||
float vol, sur_area;
|
||||
|
||||
ma = MAGNITUDE( &temp_rec.s.s_values[3] );
|
||||
mb = MAGNITUDE( &temp_rec.s.s_values[6] );
|
||||
mc = MAGNITUDE( &temp_rec.s.s_values[9] );
|
||||
|
||||
type = 0;
|
||||
|
||||
vol = 4.0 * pi * ma * mb * mc / 3.0;
|
||||
(void)printf("Volume = %.4f",vol*base2local*base2local*base2local);
|
||||
(void)printf("Volume = %.4f (%.4f gal)",vol*base2local*base2local*base2local,vol/3787878.79);
|
||||
|
||||
if( fabs(ma-mb) < .00001 && fabs(mb-mc) < .00001 ) {
|
||||
/* have a sphere */
|
||||
@@ -529,9 +572,9 @@ tgc_anal()
|
||||
area_base*base2local*base2local,
|
||||
area_top*base2local*base2local,
|
||||
area_side*base2local*base2local);
|
||||
(void)printf("Total Surface Area=%.4f Volume=%.4f\n",
|
||||
(void)printf("Total Surface Area=%.4f Volume=%.4f (%.4f gal)\n",
|
||||
(area_base+area_top+area_side)*base2local*base2local,
|
||||
vol*base2local*base2local*base2local);
|
||||
vol*base2local*base2local*base2local,vol/3787878.79);
|
||||
|
||||
return;
|
||||
|
||||
|
||||
+202
-70
@@ -250,146 +250,209 @@ f_extrude()
|
||||
(void)printf("Extrude: solid type must be ARB\n");
|
||||
return;
|
||||
}
|
||||
face = atoi( cmd_args[1] );
|
||||
if( face < 1000 || face > 9999 ) {
|
||||
(void)printf("ERROR: face must be 4 points\n");
|
||||
|
||||
if(es_type != ARB8 && es_type != ARB6 && es_type != ARB4) {
|
||||
(void)printf("ARB%d: extrusion of faces not allowed\n",es_type);
|
||||
return;
|
||||
}
|
||||
|
||||
face = atoi( cmd_args[1] );
|
||||
|
||||
/* get distance to project face */
|
||||
dist = atof( cmd_args[2] );
|
||||
/* apply es_mat[15] to get to real model space */
|
||||
/* convert from the local unit (as input) to the base unit */
|
||||
dist = dist * es_mat[15] * local2base;
|
||||
|
||||
newedge = 1;
|
||||
|
||||
/* convert to point notation in temporary buffer */
|
||||
VMOVE( &lsolid.s_values[0], &es_rec.s.s_values[0] );
|
||||
for( i = 3; i <= 21; i += 3 ) {
|
||||
VADD2(&lsolid.s_values[i], &es_rec.s.s_values[i], &lsolid.s_values[0]);
|
||||
}
|
||||
|
||||
pt[0] = face / 1000;
|
||||
i = face - (pt[0]*1000);
|
||||
pt[1] = i / 100;
|
||||
i = i - (pt[1]*100);
|
||||
pt[2] = i / 10;
|
||||
pt[3] = i - (pt[2]*10);
|
||||
if( (es_type == ARB6 || es_type == ARB4) && face < 1000 ) {
|
||||
/* 3 point face */
|
||||
pt[0] = face / 100;
|
||||
i = face - (pt[0]*100);
|
||||
pt[1] = i / 10;
|
||||
pt[2] = i - (pt[1]*10);
|
||||
pt[3] = 1;
|
||||
}
|
||||
else {
|
||||
pt[0] = face / 1000;
|
||||
i = face - (pt[0]*1000);
|
||||
pt[1] = i / 100;
|
||||
i = i - (pt[1]*100);
|
||||
pt[2] = i / 10;
|
||||
pt[3] = i - (pt[2]*10);
|
||||
}
|
||||
|
||||
/* user can input face in any order - will use product of
|
||||
* face points to distinguish faces:
|
||||
* product face
|
||||
* 24 1234
|
||||
* 1680 5678
|
||||
* 252 2367
|
||||
* 160 1548
|
||||
* 672 4378
|
||||
* 60 1256
|
||||
* 24 1234 for ARB8
|
||||
* 1680 5678 for ARB8
|
||||
* 252 2367 for ARB8
|
||||
* 160 1548 for ARB8
|
||||
* 672 4378 for ARB8
|
||||
* 60 1256 for ARB8
|
||||
* 10 125 for ARB6
|
||||
* 72 346 for ARB6
|
||||
* --- special case to make ARB6 from ARB4
|
||||
* --- provides easy way to build ARB6's
|
||||
* 6 123 for ARB4
|
||||
* 8 124 for ARB4
|
||||
* 12 134 for ARB4
|
||||
* 24 234 for ARB4
|
||||
*/
|
||||
prod = 1;
|
||||
for( i = 0; i <= 3; i++ ) {
|
||||
prod *= pt[i];
|
||||
--pt[i];
|
||||
if(es_type == ARB6 && pt[i] == 6)
|
||||
pt[i]++;
|
||||
if(es_type == ARB4 && pt[i] == 4)
|
||||
pt[i]++;
|
||||
pt[i]--;
|
||||
if( pt[i] > 7 ) {
|
||||
(void)printf("bad face: %d\n",face);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* find plane containing this face */
|
||||
if( (j = plane( pt[0], pt[1], pt[2], pt[3], &lsolid )) >= 0 ) {
|
||||
if( planeqn(6, pt[0], pt[1], pt[2], &lsolid) ) {
|
||||
(void)printf("face: %d is not a plane\n",face);
|
||||
return;
|
||||
}
|
||||
/* get normal vector of length == dist */
|
||||
for( i = 0; i < 3; i++ )
|
||||
es_plant[i] *= dist;
|
||||
es_peqn[6][i] *= dist;
|
||||
|
||||
/* protrude the selected face */
|
||||
switch( prod ) {
|
||||
|
||||
case 24: /* protrude face 1234 */
|
||||
if(es_type == ARB6) {
|
||||
(void)printf("ARB6: extrusion of face %d not allowed\n",face);
|
||||
return;
|
||||
}
|
||||
if(es_type == ARB4)
|
||||
goto a4toa6; /* extrude face 234 of ARB4 to make ARB6 */
|
||||
|
||||
for( i = 0; i < 4; i++ ) {
|
||||
j = i + 4;
|
||||
VADD2( &lsolid.s_values[j*3],
|
||||
&lsolid.s_values[i*3],
|
||||
&es_plant[0]);
|
||||
&es_peqn[6][0]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 6: /* extrude ARB4 face 123 to make ARB6 */
|
||||
case 8: /* extrude ARB4 face 124 to make ARB6 */
|
||||
case 12: /* extrude ARB4 face 134 to Make ARB6 */
|
||||
a4toa6:
|
||||
ext4to6(pt[0], pt[1], pt[2], dist, &lsolid);
|
||||
es_rec.s.s_cgtype = ARB6;
|
||||
es_edflag = IDLE;
|
||||
es_menu = 0;
|
||||
sedit_menu();
|
||||
break;
|
||||
|
||||
case 1680: /* protrude face 5678 */
|
||||
for( i = 0; i < 4; i++ ) {
|
||||
j = i + 4;
|
||||
VADD2( &lsolid.s_values[i*3],
|
||||
&lsolid.s_values[j*3],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
}
|
||||
break;
|
||||
|
||||
case 60: /* protrude face 1256 */
|
||||
case 10: /* extrude face 125 of ARB6 */
|
||||
VADD2( &lsolid.s_values[9],
|
||||
&lsolid.s_values[0],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
VADD2( &lsolid.s_values[6],
|
||||
&lsolid.s_values[3],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
VADD2( &lsolid.s_values[21],
|
||||
&lsolid.s_values[12],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
VADD2( &lsolid.s_values[18],
|
||||
&lsolid.s_values[15],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
break;
|
||||
|
||||
case 672: /* protrude face 4378 */
|
||||
case 72: /* extrude face 346 of ARB6 */
|
||||
VADD2( &lsolid.s_values[0],
|
||||
&lsolid.s_values[9],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
VADD2( &lsolid.s_values[3],
|
||||
&lsolid.s_values[6],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
VADD2( &lsolid.s_values[15],
|
||||
&lsolid.s_values[18],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
VADD2( &lsolid.s_values[12],
|
||||
&lsolid.s_values[21],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
break;
|
||||
|
||||
case 252: /* protrude face 2367 */
|
||||
VADD2( &lsolid.s_values[0],
|
||||
&lsolid.s_values[3],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
VADD2( &lsolid.s_values[9],
|
||||
&lsolid.s_values[6],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
VADD2( &lsolid.s_values[12],
|
||||
&lsolid.s_values[15],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
VADD2( &lsolid.s_values[21],
|
||||
&lsolid.s_values[18],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
break;
|
||||
|
||||
case 160: /* protrude face 1548 */
|
||||
VADD2( &lsolid.s_values[3],
|
||||
&lsolid.s_values[0],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
VADD2( &lsolid.s_values[15],
|
||||
&lsolid.s_values[12],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
VADD2( &lsolid.s_values[6],
|
||||
&lsolid.s_values[9],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
VADD2( &lsolid.s_values[18],
|
||||
&lsolid.s_values[21],
|
||||
&es_plant[0] );
|
||||
&es_peqn[6][0] );
|
||||
break;
|
||||
|
||||
case 120:
|
||||
case 180:
|
||||
(void)printf("ARB6: extrusion of face %d not allowed\n",face);
|
||||
return;
|
||||
|
||||
default:
|
||||
(void)printf("bad face: %d\n", face );
|
||||
return;
|
||||
}
|
||||
|
||||
/* redo the plane equations */
|
||||
for(i=0; i<6; i++) {
|
||||
if(faces[es_type-4][i*4] == -1)
|
||||
break;
|
||||
pt[0] = faces[es_type-4][i*4];
|
||||
pt[1] = faces[es_type-4][i*4+1];
|
||||
pt[2] = faces[es_type-4][i*4+2];
|
||||
if(planeqn(i, pt[0], pt[1], pt[2], &lsolid)) {
|
||||
(void)printf("No equation for face %d%d%d%d\n",
|
||||
pt[0]+1,pt[1]+1,pt[2]+1,faces[es_type-4][i*4+3]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert back to point&vector notation */
|
||||
VMOVE( &es_rec.s.s_values[0], &lsolid.s_values[0] );
|
||||
for( i = 3; i <= 21; i += 3 ) {
|
||||
@@ -426,24 +489,23 @@ f_arbdef()
|
||||
/* get fallback angle */
|
||||
fb = atof( cmd_args[3] ) * degtorad;
|
||||
|
||||
/* copy arb8 to the new name */
|
||||
if( (dp = lookup( "arb8", LOOKUP_NOISY )) == DIR_NULL )
|
||||
return;
|
||||
db_getrec( dp, &record, 0 );
|
||||
if( (dp = dir_add( cmd_args[1], -1, DIR_SOLID, 1 )) == DIR_NULL )
|
||||
return;
|
||||
db_alloc( dp, 1 );
|
||||
NAMEMOVE( cmd_args[1], record.s.s_name );
|
||||
record.s.s_id = ID_SOLID;
|
||||
record.s.s_type = GENARB8;
|
||||
record.s.s_cgtype = ARB8;
|
||||
|
||||
/* put vertex of new solid at center of screen */
|
||||
record.s.s_values[0] = -toViewcenter[MDX];
|
||||
record.s.s_values[1] = -toViewcenter[MDY];
|
||||
record.s.s_values[2] = -toViewcenter[MDZ];
|
||||
|
||||
/* calculate normal vector (length = .5) defined by rot,fb */
|
||||
norm[0] = cos(fb) * cos(rota) * -0.5;
|
||||
norm[1] = cos(fb) * sin(rota) * -0.5;
|
||||
norm[2] = sin(fb) * -0.5;
|
||||
/* calculate normal vector (length = 2) defined by rot,fb */
|
||||
norm[0] = cos(fb) * cos(rota) * -50.8;
|
||||
norm[1] = cos(fb) * sin(rota) * -50.8;
|
||||
norm[2] = sin(fb) * -50.8;
|
||||
|
||||
for( i = 3; i < 24; i++ )
|
||||
record.s.s_values[i] = 0.0;
|
||||
@@ -458,10 +520,12 @@ f_arbdef()
|
||||
VCROSS( &record.s.s_values[9], &record.s.s_values[3], norm );
|
||||
VCROSS( &record.s.s_values[3], &record.s.s_values[9], norm );
|
||||
|
||||
/* create new rpp 5x5x.5 */
|
||||
/* the 5x5 faces are in rot,fb plane */
|
||||
/* create new rpp 20x20x2 */
|
||||
/* the 20x20 faces are in rot,fb plane */
|
||||
VUNITIZE( &record.s.s_values[3] );
|
||||
VUNITIZE( &record.s.s_values[9] );
|
||||
VSCALE(&record.s.s_values[3], &record.s.s_values[3], 508.0);
|
||||
VSCALE(&record.s.s_values[9], &record.s.s_values[9], 508.0);
|
||||
VADD2( &record.s.s_values[6],
|
||||
&record.s.s_values[3],
|
||||
&record.s.s_values[9] );
|
||||
@@ -538,6 +602,11 @@ f_mirface()
|
||||
(void)printf("Mirface: solid type must be ARB\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(es_type != ARB8 && es_type != ARB6) {
|
||||
(void)printf("ARB%d: mirroring of faces not allowed\n",es_type);
|
||||
return;
|
||||
}
|
||||
face = atoi( cmd_args[1] );
|
||||
if( face < 1000 || face > 9999 ) {
|
||||
(void)printf("ERROR: face must be 4 points\n");
|
||||
@@ -565,27 +634,38 @@ f_mirface()
|
||||
VADD2(&lsolid.s_values[i], &es_rec.s.s_values[i], &lsolid.s_values[0]);
|
||||
}
|
||||
|
||||
pt[0] = face / 1000;
|
||||
i = face - (pt[0]*1000);
|
||||
pt[1] = i / 100;
|
||||
i = i - (pt[1]*100);
|
||||
pt[2] = i / 10;
|
||||
pt[3] = i - (pt[2]*10);
|
||||
if(es_type == ARB6 && face < 1000) { /* 3 point face */
|
||||
pt[0] = face / 100;
|
||||
i = face - (pt[0]*100);
|
||||
pt[1] = i / 10;
|
||||
pt[2] = i - (pt[1]*10);
|
||||
pt[3] = 1;
|
||||
}
|
||||
else {
|
||||
pt[0] = face / 1000;
|
||||
i = face - (pt[0]*1000);
|
||||
pt[1] = i / 100;
|
||||
i = i - (pt[1]*100);
|
||||
pt[2] = i / 10;
|
||||
pt[3] = i - (pt[2]*10);
|
||||
}
|
||||
|
||||
/* user can input face in any order - will use product of
|
||||
* face points to distinguish faces:
|
||||
* product face
|
||||
* 24 1234
|
||||
* 1680 5678
|
||||
* 252 2367
|
||||
* 160 1548
|
||||
* 672 4378
|
||||
* 60 1256
|
||||
* 24 1234 for ARB8
|
||||
* 1680 5678 for ARB8
|
||||
* 252 2367 for ARB8
|
||||
* 160 1548 for ARB8
|
||||
* 672 4378 for ARB8
|
||||
* 60 1256 for ARB8
|
||||
* 10 125 for ARB6
|
||||
* 72 346 for ARB6
|
||||
*/
|
||||
prod = 1;
|
||||
for( i = 0; i <= 3; i++ ) {
|
||||
prod *= pt[i];
|
||||
--pt[i];
|
||||
pt[i]--;
|
||||
if( pt[i] > 7 ) {
|
||||
(void)printf("bad face: %d\n",face);
|
||||
return;
|
||||
@@ -596,6 +676,10 @@ f_mirface()
|
||||
switch( prod ) {
|
||||
|
||||
case 24: /* mirror face 1234 */
|
||||
if(es_type == ARB6) {
|
||||
(void)printf("ARB6: mirroring of face %d not allowed\n",face);
|
||||
return;
|
||||
}
|
||||
for( i = 0; i < 4; i++ ) {
|
||||
j = i + 4;
|
||||
VELMUL( &lsolid.s_values[j*3],
|
||||
@@ -614,6 +698,7 @@ f_mirface()
|
||||
break;
|
||||
|
||||
case 60: /* mirror face 1256 */
|
||||
case 10: /* mirror face 125 of ARB6 */
|
||||
VELMUL( &lsolid.s_values[9],
|
||||
&lsolid.s_values[0],
|
||||
work );
|
||||
@@ -629,6 +714,7 @@ f_mirface()
|
||||
break;
|
||||
|
||||
case 672: /* mirror face 4378 */
|
||||
case 72: /* mirror face 346 of ARB6 */
|
||||
VELMUL( &lsolid.s_values[0],
|
||||
&lsolid.s_values[9],
|
||||
work );
|
||||
@@ -673,11 +759,30 @@ f_mirface()
|
||||
work );
|
||||
break;
|
||||
|
||||
case 120:
|
||||
case 180:
|
||||
(void)printf("ARB6: mirroring of face %d not allowed\n",face);
|
||||
return;
|
||||
|
||||
default:
|
||||
(void)printf("bad face: %d\n", face );
|
||||
return;
|
||||
}
|
||||
|
||||
/* redo the plane equations */
|
||||
for(i=0; i<6; i++) {
|
||||
if(faces[es_type-4][i*4] == -1)
|
||||
break;
|
||||
pt[0] = faces[es_type-4][i*4];
|
||||
pt[1] = faces[es_type-4][i*4+1];
|
||||
pt[2] = faces[es_type-4][i*4+2];
|
||||
if(planeqn(i, pt[0], pt[1], pt[2], &lsolid)) {
|
||||
(void)printf("No equation for face %d%d%d%d\n",
|
||||
pt[0]+1,pt[1]+1,pt[2]+1,faces[es_type-4][i*4+3]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert back to point&vector notation */
|
||||
VMOVE( &es_rec.s.s_values[0], &lsolid.s_values[0] );
|
||||
for( i = 3; i <= 21; i += 3 ) {
|
||||
@@ -1091,18 +1196,10 @@ f_edgedir()
|
||||
}
|
||||
|
||||
if( es_gentype != GENARB8 ) {
|
||||
(void)printf("Edgeslope: solid type must be an ARB\n");
|
||||
(void)printf("Edgedir: solid type must be an ARB\n");
|
||||
return;
|
||||
}
|
||||
|
||||
VMOVE(work, &es_rec.s.s_values[0]);
|
||||
if( (point = es_menu / 10 - 1) ) {
|
||||
VADD2(work, &es_rec.s.s_values[0], &es_rec.s.s_values[point*3]);
|
||||
}
|
||||
|
||||
newedge = 1;
|
||||
editarb( work );
|
||||
|
||||
/* set up slope -
|
||||
* if 2 values input assume rot, fb used
|
||||
* else assume delta_x, delta_y, delta_z
|
||||
@@ -1127,9 +1224,44 @@ f_edgedir()
|
||||
}
|
||||
|
||||
/* get it done */
|
||||
newedge = 1;
|
||||
editarb( work );
|
||||
sedraw++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* EXT4TO6(): extrudes face pt1 pt2 pt3 of an ARB4 "distance"
|
||||
* to produce ARB6 using solid record "sp"
|
||||
*/
|
||||
ext4to6(pt1, pt2, pt3, distance, sp)
|
||||
int pt1, pt2, pt3;
|
||||
float distance;
|
||||
struct solidrec *sp;
|
||||
{
|
||||
|
||||
static struct solidrec tmp;
|
||||
int i;
|
||||
|
||||
VMOVE(&tmp.s_values[0], &sp->s_values[pt1*3]);
|
||||
VMOVE(&tmp.s_values[3], &sp->s_values[pt2*3]);
|
||||
VMOVE(&tmp.s_values[12], &sp->s_values[pt3*3]);
|
||||
VMOVE(&tmp.s_values[15], &sp->s_values[pt3*3]);
|
||||
|
||||
/* extrude "distance" to get remaining points */
|
||||
VADD2(&tmp.s_values[6], &tmp.s_values[3], &es_peqn[6][0]);
|
||||
VADD2(&tmp.s_values[9], &tmp.s_values[0], &es_peqn[6][0]);
|
||||
VADD2(&tmp.s_values[18], &tmp.s_values[12], &es_peqn[6][0]);
|
||||
VMOVE(&tmp.s_values[21], &tmp.s_values[18]);
|
||||
|
||||
/* copy to the original record */
|
||||
for(i=0; i<=21; i+=3) {
|
||||
VMOVE(&sp->s_values[i], &tmp.s_values[i]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+10
-1
@@ -251,11 +251,20 @@ do_list( dp )
|
||||
db_getrec( dp, &record, 0 );
|
||||
|
||||
if( record.u_id == ID_SOLID ) {
|
||||
(void)printf("%s: %s\n",
|
||||
(void)printf("%s: %s",
|
||||
dp->d_namep,record.s.s_type==GENARB8 ? "GENARB8" :
|
||||
record.s.s_type==GENTGC ? "GENTGC" :
|
||||
record.s.s_type==GENELL ? "GENELL": "TOR" );
|
||||
|
||||
if(record.s.s_type == GENARB8) {
|
||||
if( (i=record.s.s_cgtype) < 0 )
|
||||
i *= -1;
|
||||
(void)printf(" (%s)",i==ARB4 ? "ARB4" :
|
||||
i==ARB5 ? "ARB5" : i==ARB6 ? "ARB6" :
|
||||
i==ARB7 ? "ARB7" : i==RAW ? "ARB6" : "ARB8");
|
||||
}
|
||||
(void)printf("\n");
|
||||
|
||||
pr_solid( &record.s );
|
||||
|
||||
for( i=0; i < es_nlines; i++ )
|
||||
|
||||
@@ -363,6 +363,7 @@ f_param()
|
||||
case EARB:
|
||||
case MOVEH:
|
||||
case MOVEHH:
|
||||
case PTARB:
|
||||
/* must convert to base units */
|
||||
es_para[0] *= local2base;
|
||||
es_para[1] *= local2base;
|
||||
|
||||
+405
-294
@@ -2,10 +2,10 @@
|
||||
* E D A R B . C
|
||||
*
|
||||
* Functions -
|
||||
* editarb edit ARB edge
|
||||
* do_new_edge internal routine for editarb()
|
||||
* plane attempts to find equation of plane
|
||||
* planeqn ?
|
||||
* editarb edit ARB edge (and move points)
|
||||
* planeqn finds plane equation given 3 points
|
||||
* intersect finds intersection point of three planes
|
||||
* mv_edge moves an arb edge
|
||||
*
|
||||
* Author -
|
||||
* Keith A. Applin
|
||||
@@ -36,29 +36,183 @@ static char RCSid[] = "@(#)$Header$ (BRL)";
|
||||
|
||||
extern int printf();
|
||||
|
||||
static void findsam();
|
||||
static int compar(), special();
|
||||
static int compar();
|
||||
|
||||
/*
|
||||
* E D I T A R B
|
||||
*
|
||||
* An ARB edge is moved by finding the slope of the
|
||||
* line containing the edge, moving this line to the
|
||||
* desired location, and intersecting the new line
|
||||
* with the 2 bounding planes to define the new edge.
|
||||
* An ARB edge is moved by finding the direction of
|
||||
* the line containing the edge and the 2 "bounding"
|
||||
* planes. The new edge is found by intersecting the
|
||||
* new line location with the bounding planes. The
|
||||
* two "new" planes thus defined are calculated and the
|
||||
* affected points are calculated by intersecting planes.
|
||||
* This keeps ALL faces planar.
|
||||
*
|
||||
* If es_menu = (a*10)+b then moving edge ab.
|
||||
*/
|
||||
|
||||
/* The storage for the "specific" ARB types is :
|
||||
*
|
||||
* ARB4 0 1 2 0 3 3 3 3
|
||||
* ARB5 0 1 2 3 4 4 4 4
|
||||
* ARB6 0 1 2 3 4 4 5 5
|
||||
* ARB7 0 1 2 3 4 5 6 4
|
||||
* ARB8 0 1 2 3 4 5 6 7
|
||||
*/
|
||||
|
||||
/* Another summary of how the vertices of ARBs are stored:
|
||||
*
|
||||
* Vertices: 1 2 3 4 5 6 7 8
|
||||
* Location----------------------------------------------------------------
|
||||
* ARB8 0 1 2 3 4 5 6 7
|
||||
* ARB7 0 1 2 3 4,7 5 6
|
||||
* ARB6 0 1 2 3 4,5 6,7
|
||||
* ARB5 0 1 2 3 4,5,6,7
|
||||
* ARB4 0,3 1 2 4,5,6,7
|
||||
*/
|
||||
|
||||
/* The following arb editing arrays generally contain the following:
|
||||
*
|
||||
* location comments
|
||||
*------------------------------------------------------------------------
|
||||
* 0,1 edge end points
|
||||
* 2,3 bounding planes 1 and 2
|
||||
* 4, 5,6,7 plane 1 to recalculate, using next 3 points
|
||||
* 8, 9,10,11 plane 2 to recalculate, using next 3 points
|
||||
* 12, 13,14,15 plane 3 to recalculate, using next 3 points
|
||||
* 16,17 points (vertices) to recalculate
|
||||
*
|
||||
*
|
||||
* Each line is repeated for each edge (or point) to move
|
||||
*/
|
||||
|
||||
/* edit array for arb8's */
|
||||
static short earb8[12][18] = {
|
||||
{0,1, 2,3, 0,0,1,2, 4,0,1,4, -1,0,0,0, 3,5}, /* edge 12 */
|
||||
{1,2, 4,5, 0,0,1,2, 3,1,2,5, -1,0,0,0, 3,6}, /* edge 23 */
|
||||
{2,3, 3,2, 0,0,2,3, 5,2,3,6, -1,0,0,0, 1,7}, /* edge 34 */
|
||||
{0,3, 4,5, 0,0,1,3, 2,0,3,4, -1,0,0,0, 2,7}, /* edge 41 */
|
||||
{0,4, 0,1, 2,0,4,3, 4,0,1,4, -1,0,0,0, 7,5}, /* edge 15 */
|
||||
{1,5, 0,1, 4,0,1,5, 3,1,2,5, -1,0,0,0, 4,6}, /* edge 26 */
|
||||
{4,5, 2,3, 4,0,5,4, 1,4,5,6, -1,0,0,0, 1,7}, /* edge 56 */
|
||||
{5,6, 4,5, 3,1,5,6, 1,4,5,6, -1,0,0,0, 2,7}, /* edge 67 */
|
||||
{6,7, 3,2, 5,2,7,6, 1,4,6,7, -1,0,0,0, 3,4}, /* edge 78 */
|
||||
{4,7, 4,5, 2,0,7,4, 1,4,5,7, -1,0,0,0, 3,6}, /* edge 58 */
|
||||
{2,6, 0,1, 3,1,2,6, 5,2,3,6, -1,0,0,0, 5,7}, /* edge 37 */
|
||||
{3,7, 0,1, 2,0,3,7, 5,2,3,7, -1,0,0,0, 4,6}, /* edge 48 */
|
||||
};
|
||||
|
||||
/* edit array for arb7's */
|
||||
static short earb7[12][18] = {
|
||||
{0,1, 2,3, 0,0,1,2, 4,0,1,4, -1,0,0,0, 3,5}, /* edge 12 */
|
||||
{1,2, 4,5, 0,0,1,2, 3,1,2,5, -1,0,0,0, 3,6}, /* edge 23 */
|
||||
{2,3, 3,2, 0,0,2,3, 5,2,3,6, -1,0,0,0, 1,4}, /* edge 34 */
|
||||
{0,3, 4,5, 0,0,1,3, 2,0,3,4, -1,0,0,0, 2,-1}, /* edge 41 */
|
||||
{0,4, 0,5, 4,0,5,4, 2,0,3,4, 1,4,5,6, 1,-1}, /* edge 15 */
|
||||
{1,5, 0,1, 4,0,1,5, 3,1,2,5, -1,0,0,0, 4,6}, /* edge 26 */
|
||||
{4,5, 5,3, 2,0,3,4, 4,0,5,4, 1,4,5,6, 1,-1}, /* edge 56 */
|
||||
{5,6, 4,5, 3,1,6,5, 1,4,5,6, -1,0,0,0, 2, -1}, /* edge 67 */
|
||||
{2,6, 0,1, 5,2,3,6, 3,1,2,6, -1,0,0,0, 4,5}, /* edge 37 */
|
||||
{4,6, 4,3, 2,0,3,4, 5,3,4,6, 1,4,5,6, 2,-1}, /* edge 57 */
|
||||
{3,4, 0,1, 4,0,1,4, 2,0,3,4, 5,2,3,4, 5,6}, /* edge 45 */
|
||||
{-1,-1, -1,-1, 5,2,3,4, 4,0,1,4, 8,2,1,-1, 6,5}, /* point 5 */
|
||||
};
|
||||
|
||||
/* edit array for arb6's */
|
||||
static short earb6[10][18] = {
|
||||
{0,1, 2,1, 3,0,1,4, 0,0,1,2, -1,0,0,0, 3,-1}, /* edge 12 */
|
||||
{1,2, 3,4, 1,1,2,5, 0,0,1,2, -1,0,0,0, 3,4}, /* edge 23 */
|
||||
{2,3, 1,2, 4,2,3,5, 0,0,2,3, -1,0,0,0, 1,-1}, /* edge 34 */
|
||||
{0,3, 3,4, 2,0,3,5, 0,0,1,3, -1,0,0,0, 4,2}, /* edge 14 */
|
||||
{0,4, 0,1, 3,0,1,4, 2,0,3,4, -1,0,0,0, 6,-1}, /* edge 15 */
|
||||
{1,4, 0,2, 3,0,1,4, 1,1,2,4, -1,0,0,0, 6,-1}, /* edge 25 */
|
||||
{2,6, 0,2, 4,6,2,3, 1,1,2,6, -1,0,0,0, 4,-1}, /* edge 36 */
|
||||
{3,6, 0,1, 4,6,2,3, 2,0,3,6, -1,0,0,0, 4,-1}, /* edge 46 */
|
||||
{-1,-1, -1,-1, 2,0,3,4, 1,1,2,4, 3,0,1,4, 6,-1},/* point 5 */
|
||||
{-1,-1, -1,-1, 2,0,3,6, 1,1,2,6, 4,2,3,6, 4,-1},/* point 6 */
|
||||
};
|
||||
|
||||
/* edit array for arb5's */
|
||||
static short earb5[9][18] = {
|
||||
{0,1, 4,2, 0,0,1,2, 1,0,1,4, -1,0,0,0, 3,-1}, /* edge 12 */
|
||||
{1,2, 1,3, 0,0,1,2, 2,1,2,4, -1,0,0,0, 3,-1}, /* edge 23 */
|
||||
{2,3, 2,4, 0,0,2,3, 3,2,3,4, -1,0,0,0, 1,-1}, /* edge 34 */
|
||||
{0,3, 1,3, 0,0,1,3, 4,0,3,4, -1,0,0,0, 2,-1}, /* edge 14 */
|
||||
{0,4, 0,2, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, /* edge 15 */
|
||||
{1,4, 0,3, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, /* edge 25 */
|
||||
{2,4, 0,4, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, /* edge 35 */
|
||||
{3,4, 0,1, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, /* edge 45 */
|
||||
{-1,-1, -1,-1, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, /* point 5 */
|
||||
};
|
||||
|
||||
/* edit array for arb4's */
|
||||
static short earb4[5][18] = {
|
||||
{-1,-1, -1,-1, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, /* point 1 */
|
||||
{-1,-1, -1,-1, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, /* point 2 */
|
||||
{-1,-1, -1,-1, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, /* point 3 */
|
||||
{-1,-1, -1,-1, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, /* dummy */
|
||||
{-1,-1, -1,-1, 9,0,0,0, 9,0,0,0, 9,0,0,0, -1,-1}, /* point 4 */
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
editarb( pos_model )
|
||||
vect_t pos_model;
|
||||
{
|
||||
register float *op;
|
||||
register float *opp;
|
||||
static double t;
|
||||
register int i;
|
||||
static int j, k;
|
||||
static int pt1, pt2;
|
||||
static int pt1, pt2, bp1, bp2, newp, p1, p2, p3, p4;
|
||||
short *edptr; /* pointer to arb edit array */
|
||||
short *final; /* location of points to redo */
|
||||
register float *op;
|
||||
static int i, *iptr;
|
||||
|
||||
/* set the pointer */
|
||||
switch( es_type ) {
|
||||
|
||||
case ARB4:
|
||||
edptr = &earb4[es_menu][0];
|
||||
final = &earb4[es_menu][16];
|
||||
break;
|
||||
|
||||
case ARB5:
|
||||
edptr = &earb5[es_menu][0];
|
||||
final = &earb5[es_menu][16];
|
||||
if(es_edflag == PTARB) {
|
||||
edptr = &earb5[8][0];
|
||||
final = &earb5[8][16];
|
||||
}
|
||||
break;
|
||||
|
||||
case ARB6:
|
||||
edptr = &earb6[es_menu][0];
|
||||
final = &earb6[es_menu][16];
|
||||
if(es_edflag == PTARB) {
|
||||
i = 9;
|
||||
if(es_menu == 4)
|
||||
i = 8;
|
||||
edptr = &earb6[i][0];
|
||||
final = &earb6[i][16];
|
||||
}
|
||||
break;
|
||||
|
||||
case ARB7:
|
||||
edptr = &earb7[es_menu][0];
|
||||
final = &earb7[es_menu][16];
|
||||
if(es_edflag == PTARB) {
|
||||
edptr = &earb7[11][0];
|
||||
final = &earb7[11][16];
|
||||
}
|
||||
break;
|
||||
|
||||
case ARB8:
|
||||
edptr = &earb8[es_menu][0];
|
||||
final = &earb8[es_menu][16];
|
||||
break;
|
||||
|
||||
default:
|
||||
(void)printf("edarb: unknown ARB type\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* convert to point notation (in place ----- DANGEROUS) */
|
||||
for(i=3; i<=21; i+=3) {
|
||||
@@ -66,272 +220,169 @@ vect_t pos_model;
|
||||
VADD2( op, op, &es_rec.s.s_values[0] );
|
||||
}
|
||||
|
||||
if( newedge > 0 ) {
|
||||
newedge = 0;
|
||||
if( do_new_edge() < 0 )
|
||||
/* do the arb editing */
|
||||
|
||||
if( es_edflag == PTARB ) {
|
||||
/* moving a point - not an edge */
|
||||
VMOVE(&es_rec.s.s_values[es_menu*3], &pos_model[0]);
|
||||
edptr += 4;
|
||||
}
|
||||
|
||||
if( es_edflag == EARB ) {
|
||||
/* moving an edge */
|
||||
pt1 = *edptr++;
|
||||
pt2 = *edptr++;
|
||||
/* direction of this edge */
|
||||
if( newedge ) {
|
||||
/* edge direction comes from edgedir() */
|
||||
VMOVE(pos_model, &es_rec.s.s_values[pt1*3]);
|
||||
newedge = 0;
|
||||
}
|
||||
else {
|
||||
/* must calculate edge direction */
|
||||
VSUB2(es_m, &es_rec.s.s_values[3*pt2], &es_rec.s.s_values[3*pt1]);
|
||||
}
|
||||
if(MAGNITUDE(es_m) == 0.0)
|
||||
goto err;
|
||||
/* bounding planes bp1,bp2 */
|
||||
bp1 = *edptr++;
|
||||
bp2 = *edptr++;
|
||||
|
||||
/* move the edge */
|
||||
/*
|
||||
printf("moving edge: %d%d bound planes: %d %d\n",pt1+1,pt2+1,bp1+1,bp2+1);
|
||||
*/
|
||||
if( mv_edge(pos_model, bp1, bp2, pt1, pt2) )
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Now we have line and planes data - move the edge */
|
||||
|
||||
pt1 = (es_menu / 10) - 1;
|
||||
pt2 = (es_menu % 10) - 1;
|
||||
|
||||
/*
|
||||
* Line containing edge must now go throug
|
||||
* point contained in pos_model[] array
|
||||
*/
|
||||
|
||||
if( VDOT(es_plano, es_m) == 0 ||
|
||||
VDOT(es_plant, es_m) == 0 ) {
|
||||
(void)printf("edge (slope) parallel to face\n");
|
||||
goto err;
|
||||
}
|
||||
t = (es_plano[3] - VDOT(es_plano, pos_model)) / VDOT(es_plano, es_m);
|
||||
op = &es_rec.s.s_values[pt1*3];
|
||||
VCOMP1( op, pos_model, t, es_m );
|
||||
|
||||
t = (es_plant[3] - VDOT(es_plant, pos_model)) / VDOT(es_plant, es_m);
|
||||
op = &es_rec.s.s_values[pt2*3];
|
||||
VCOMP1( op, pos_model, t, es_m );
|
||||
|
||||
/* move along any like points */
|
||||
k = pt1;
|
||||
for(i=0; i<6; i++) {
|
||||
if(i >= 3)
|
||||
k = pt2;
|
||||
if( (j = es_same[i]) > -1 ) {
|
||||
op = &es_rec.s.s_values[j*3];
|
||||
opp = &es_rec.s.s_values[k*3];
|
||||
VMOVE(op, opp);
|
||||
/* editing is done - insure planar faces */
|
||||
/* redo plane eqns that changed */
|
||||
newp = *edptr++; /* plane to redo */
|
||||
if( newp == 9 ) {
|
||||
/* special flag --> redo all the planes */
|
||||
iptr = &faces[es_type-4][0];
|
||||
for(i=0; i<6; i++) {
|
||||
p1 = *iptr++;
|
||||
p2 = *iptr++;
|
||||
p3 = *iptr++;
|
||||
p4 = *iptr++;
|
||||
/*
|
||||
printf("REDO plane %d with points %d %d %d\n",i+1,p1+1,p2+1,p3+1);
|
||||
*/
|
||||
if( planeqn(i, p1, p2, p3, &es_rec.s) )
|
||||
goto err;
|
||||
if( *iptr == -1 )
|
||||
break; /* finished */
|
||||
}
|
||||
}
|
||||
if(newp >= 0 && newp < 6) {
|
||||
for(i=0; i<3; i++) {
|
||||
/* redo this plane (newp), use points p1,p2,p3 */
|
||||
p1 = *edptr++;
|
||||
p2 = *edptr++;
|
||||
p3 = *edptr++;
|
||||
/*
|
||||
printf("redo plane %d with points %d %d %d\n",newp+1,p1+1,p2+1,p3+1);
|
||||
*/
|
||||
if( planeqn(newp, p1, p2, p3, &es_rec.s) )
|
||||
goto err;
|
||||
/* next plane */
|
||||
if( (newp = *edptr++) == -1 || newp == 8 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(newp == 8) {
|
||||
/* special...redo next planes using pts defined in faces */
|
||||
for(i=0; i<3; i++) {
|
||||
if( (newp = *edptr++) == -1 )
|
||||
break;
|
||||
iptr = &faces[es_type-4][4*newp];
|
||||
p1 = *iptr++;
|
||||
p2 = *iptr++;
|
||||
p3 = *iptr++;
|
||||
/*
|
||||
printf("REdo plane %d with points %d %d %d\n",newp+1,p1+1,p2+1,p3+1);
|
||||
*/
|
||||
if( planeqn(newp, p1, p2, p3, &es_rec.s) )
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
/* the changed planes are all redone
|
||||
* push necessary points back into the planes
|
||||
*/
|
||||
edptr = final; /* point to the correct location */
|
||||
for(i=0; i<2; i++) {
|
||||
if( (p1 = *edptr++) == -1 )
|
||||
break;
|
||||
/* intersect proper planes to define vertex p1 */
|
||||
/*
|
||||
printf("intersect: type=%d point = %d\n",es_type,p1+1);
|
||||
*/
|
||||
if( intersect( es_type, p1*3, p1, &es_rec.s ) )
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Special case for ARB7: move point 5 .... must
|
||||
* recalculate plane 2 = 456
|
||||
*/
|
||||
if(es_type == ARB7 && es_edflag == PTARB) {
|
||||
/*
|
||||
printf("redo plane 2 == 5,6,7 for ARB7\n");
|
||||
*/
|
||||
if( planeqn(2, 4, 5, 6, &es_rec.s) )
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* carry along any like points */
|
||||
switch( es_type ) {
|
||||
case ARB8:
|
||||
break;
|
||||
|
||||
case ARB7:
|
||||
VMOVE(&es_rec.s.s_values[21], &es_rec.s.s_values[12]);
|
||||
break;
|
||||
|
||||
case ARB6:
|
||||
VMOVE(&es_rec.s.s_values[15], &es_rec.s.s_values[12]);
|
||||
VMOVE(&es_rec.s.s_values[21], &es_rec.s.s_values[18]);
|
||||
break;
|
||||
|
||||
case ARB5:
|
||||
for(i=15; i<=21; i+=3) {
|
||||
VMOVE(&es_rec.s.s_values[i], &es_rec.s.s_values[12]);
|
||||
}
|
||||
break;
|
||||
|
||||
case ARB4:
|
||||
VMOVE(&es_rec.s.s_values[9], &es_rec.s.s_values[0]);
|
||||
for(i=15; i<=21; i+=3) {
|
||||
VMOVE(&es_rec.s.s_values[i], &es_rec.s.s_values[12]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* back to vector notation */
|
||||
for(i=3; i<=21; i+=3) {
|
||||
opp = &es_rec.s.s_values[i];
|
||||
VSUB2( opp, opp, &es_rec.s.s_values[0] );
|
||||
op = &es_rec.s.s_values[i];
|
||||
VSUB2( op, op, &es_rec.s.s_values[0] );
|
||||
}
|
||||
return(0); /* OK */
|
||||
|
||||
err:
|
||||
/* Error handling */
|
||||
(void)printf("cannot move edge: %d\n", es_menu);
|
||||
(void)printf("cannot move edge: %d%d\n", pt1+1,pt2+1);
|
||||
es_edflag = IDLE;
|
||||
|
||||
/* back to vector notation */
|
||||
for(i=3; i<=21; i+=3) {
|
||||
opp = &es_rec.s.s_values[i];
|
||||
VSUB2(opp, opp, &es_rec.s.s_values[0]);
|
||||
op = &es_rec.s.s_values[i];
|
||||
VSUB2(op, op, &es_rec.s.s_values[0]);
|
||||
}
|
||||
return(1); /* BAD */
|
||||
}
|
||||
|
||||
/*
|
||||
* D O _ N E W _ E D G E
|
||||
*
|
||||
* Internal routine for editarb(), called whenever a new
|
||||
* edge has been selected for editing.
|
||||
*
|
||||
* Find the line equation, and the equations of the bounding planes.
|
||||
*/
|
||||
int
|
||||
do_new_edge()
|
||||
{
|
||||
register float *op;
|
||||
register float *opp;
|
||||
static int i, j;
|
||||
static int pt1,pt2;
|
||||
|
||||
/* find line data */
|
||||
pt1 = (es_menu / 10) - 1;
|
||||
pt2 = (es_menu % 10) - 1;
|
||||
|
||||
for(i=0; i<6; i++)
|
||||
es_same[i] = -1;
|
||||
|
||||
/* find any equal points to move along with the edge */
|
||||
findsam(0, pt1, &es_rec.s);
|
||||
findsam(3, pt2, &es_rec.s);
|
||||
pt1*=3;
|
||||
pt2*=3;
|
||||
|
||||
/* find slope of line containing edge pt1, pt2 */
|
||||
op = &es_rec.s.s_values[pt2];
|
||||
opp = &es_rec.s.s_values[pt1];
|
||||
VSUB2(es_m, op, opp);
|
||||
if(MAGNITUDE(es_m) == 0.0)
|
||||
return(-1);
|
||||
|
||||
/* find bounding planes and equations */
|
||||
/* put equation coefficients in plano[] and plant[] arrays */
|
||||
if( es_menu == 15 ||
|
||||
es_menu == 26 ||
|
||||
es_menu == 37 ||
|
||||
es_menu == 48) {
|
||||
/*
|
||||
* plane() returns:
|
||||
* -1 if successful
|
||||
* 0 if unsuccessful
|
||||
* >0 if degenerate plane (special case)
|
||||
*/
|
||||
if( (j = plane(0, 1, 2, 3, &es_rec.s)) > 0 ) {
|
||||
/* special case */
|
||||
i = 2;
|
||||
if( j == 3 )
|
||||
i = 1;
|
||||
/* try to find a substitute
|
||||
plane for the degenerate plane */
|
||||
if((j = special(i, pt1, &es_rec.s))>0)
|
||||
return(-1);
|
||||
}
|
||||
if(j == 0)
|
||||
return(-1);
|
||||
|
||||
VMOVE(&es_plano[0], &es_plant[0]);
|
||||
es_plano[3] = es_plant[3];
|
||||
|
||||
if( (j = plane(4, 5, 6, 7, &es_rec.s)) > 0 ) {
|
||||
i = 2;
|
||||
if(j == 47)
|
||||
i = 1;
|
||||
if( (j = special(i, pt1, &es_rec.s)) > 0)
|
||||
return(-1);
|
||||
}
|
||||
if(j == 0)
|
||||
return(-1);
|
||||
} else if(
|
||||
es_menu == 12 ||
|
||||
es_menu == 56 ||
|
||||
es_menu == 87 ||
|
||||
es_menu == 43
|
||||
) {
|
||||
if( (j = plane(0, 3, 7, 4, &es_rec.s)) > 0 ) {
|
||||
i = 3;
|
||||
if(j == 3)
|
||||
i = 1;
|
||||
if( (j =special(i, pt1, &es_rec.s)) > 0 )
|
||||
return(-1);
|
||||
}
|
||||
if(j == 0)
|
||||
return(-1);
|
||||
|
||||
VMOVE(&es_plano[0], &es_plant[0]);
|
||||
es_plano[3] = es_plant[3];
|
||||
|
||||
if( (j = plane(1, 2, 6, 5, &es_rec.s)) > 0 ) {
|
||||
i = 3;
|
||||
if(j == 12)
|
||||
i = 1;
|
||||
if( (j = special(i, pt1, &es_rec.s)) > 0 ) {
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
if(j == 0)
|
||||
return(-1);
|
||||
} else {
|
||||
if( (j = plane(0, 1, 5, 4, &es_rec.s)) > 0 ) {
|
||||
i = 3;
|
||||
if(j == 1)
|
||||
i = 2;
|
||||
if( (j = special(i, pt1, &es_rec.s)) > 0)
|
||||
return(-1);
|
||||
}
|
||||
if(j == 0)
|
||||
return(-1);
|
||||
|
||||
VMOVE(&es_plano[0], &es_plant[0]);
|
||||
es_plano[3] = es_plant[3];
|
||||
|
||||
if( (j = plane(2, 3, 7, 6, &es_rec.s)) > 0 ) {
|
||||
i = 3;
|
||||
if(j == 23)
|
||||
i = 2;
|
||||
if( (j = special(i, pt1, &es_rec.s)) > 0 ) {
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
if(j == 0)
|
||||
return(-1);
|
||||
}
|
||||
return(0); /* OK */
|
||||
}
|
||||
|
||||
/*
|
||||
* P L A N E
|
||||
*
|
||||
* Attempts to find equation of plane abcd
|
||||
*
|
||||
* returns >0 if plane abcd is degenerate
|
||||
* -1 if equation of plane abcd is found
|
||||
* 0 if cannot find equation of plane abcd
|
||||
* yet plane is NOT degenerate
|
||||
*/
|
||||
int
|
||||
plane( a, b, c, d, sp )
|
||||
struct solidrec *sp;
|
||||
int a,b,c,d;
|
||||
{
|
||||
|
||||
/* check for special case (degenerate plane) */
|
||||
if(compar(&sp->s_values[a*3],&sp->s_values[b*3]) &&
|
||||
compar(&sp->s_values[c*3],&sp->s_values[d*3]))
|
||||
return((a*10 + b));
|
||||
if(compar(&sp->s_values[a*3],&sp->s_values[c*3]) &&
|
||||
compar(&sp->s_values[b*3],&sp->s_values[d*3]))
|
||||
return((a*10 + c));
|
||||
if(compar(&sp->s_values[a*3],&sp->s_values[d*3]) &&
|
||||
compar(&sp->s_values[b*3],&sp->s_values[c*3]))
|
||||
return((a*10 + d));
|
||||
|
||||
/* find equation of plane abcd */
|
||||
if( planeqn(a,b,c,sp) )
|
||||
return(-1);
|
||||
if( planeqn(a,b,d,sp) )
|
||||
return(-1);
|
||||
if( planeqn(a,c,d,sp) )
|
||||
return(-1);
|
||||
if( planeqn(b,c,d,sp) )
|
||||
return(-1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* S P E C I A L
|
||||
*/
|
||||
static int
|
||||
special( a , b, sp )
|
||||
struct solidrec *sp;
|
||||
int a,b;
|
||||
{
|
||||
b /= 3;
|
||||
switch( a ) {
|
||||
|
||||
case 1:
|
||||
if( b == 0 || b == 1 || b == 4 )
|
||||
return( plane(2,3,6,7,sp) );
|
||||
else
|
||||
return( plane(0,1,5,4,sp) );
|
||||
|
||||
case 2:
|
||||
if( b == 1 || b == 2 || b == 5 )
|
||||
return( plane(0,4,3,7,sp) );
|
||||
else
|
||||
return( plane(1,2,6,5,sp) );
|
||||
|
||||
case 3:
|
||||
if( b == 4 || b == 5 || b == 7 )
|
||||
return( plane(0,1,2,3,sp) );
|
||||
else
|
||||
return( plane(4,5,6,7,sp) );
|
||||
|
||||
default:
|
||||
(void)printf("subroutine special: edge input error\n");
|
||||
return(0);
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
compar( x, y )
|
||||
@@ -348,42 +399,102 @@ float *x,*y;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
findsam( flag, pt, sp )
|
||||
int flag,pt;
|
||||
struct solidrec *sp;
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<8; i++) {
|
||||
if( (compar(&sp->s_values[i*3],&sp->s_values[pt*3])) &&
|
||||
(i != pt) )
|
||||
es_same[flag++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* PLANEQN:
|
||||
* finds equation of a plane defined by 3 points use1,use2,use3
|
||||
* of solid record sp. Equation is stored at "loc" of es_peqn
|
||||
* array.
|
||||
*/
|
||||
int
|
||||
planeqn( a, b, c, sp )
|
||||
int a,b,c;
|
||||
planeqn(loc, use1, use2, use3, sp)
|
||||
int loc, use1, use2, use3;
|
||||
struct solidrec *sp;
|
||||
{
|
||||
int i;
|
||||
float work[3],worc[3],mag;
|
||||
|
||||
if( compar(&sp->s_values[a*3],&sp->s_values[b*3]) )
|
||||
return(0);
|
||||
if( compar(&sp->s_values[b*3],&sp->s_values[c*3]) )
|
||||
return(0);
|
||||
if( compar(&sp->s_values[a*3],&sp->s_values[c*3]) )
|
||||
return(0);
|
||||
VSUB2(work,&sp->s_values[b*3],&sp->s_values[a*3]);
|
||||
VSUB2(worc,&sp->s_values[c*3],&sp->s_values[a*3]);
|
||||
VCROSS(es_plant,work,worc);
|
||||
if( (mag = MAGNITUDE(es_plant)) == 0.0 )
|
||||
return(0);
|
||||
VSCALE(es_plant,es_plant,1.0/mag);
|
||||
i = a*3;
|
||||
es_plant[3] = VDOT(es_plant,&sp->s_values[i]);
|
||||
return(1);
|
||||
if( compar(&sp->s_values[use1*3],&sp->s_values[use2*3]) )
|
||||
return(1);
|
||||
if( compar(&sp->s_values[use2*3],&sp->s_values[use3*3]) )
|
||||
return(1);
|
||||
if( compar(&sp->s_values[use1*3],&sp->s_values[use3*3]) )
|
||||
return(1);
|
||||
VSUB2(work,&sp->s_values[use2*3],&sp->s_values[use1*3]);
|
||||
VSUB2(worc,&sp->s_values[use3*3],&sp->s_values[use1*3]);
|
||||
VCROSS(&es_peqn[loc][0],work,worc);
|
||||
if( (mag = MAGNITUDE(&es_peqn[loc][0])) == 0.0 )
|
||||
return(1);
|
||||
VSCALE(&es_peqn[loc][0],&es_peqn[loc][0],1.0/mag);
|
||||
es_peqn[loc][3] = VDOT(&es_peqn[loc][0],&sp->s_values[use1*3]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* INTERSECT:
|
||||
* Finds intersection point of three planes.
|
||||
* The planes are at es_planes[type][loc] and
|
||||
* the result is stored at "pos" in solid struct sp.
|
||||
*/
|
||||
int
|
||||
intersect( type, loc, pos, sp )
|
||||
int type, loc, pos;
|
||||
struct solidrec *sp;
|
||||
{
|
||||
float vec1[3], vec2[3], vec3[3];
|
||||
float d;
|
||||
int i, j, i1, i2, i3;
|
||||
|
||||
j = type - 4;
|
||||
|
||||
i1 = planes[j][loc];
|
||||
i2 = planes[j][loc+1];
|
||||
i3 = planes[j][loc+2];
|
||||
/*
|
||||
printf("intersect planes are %d %d %d\n",i1+1,i2+1,i3+1);
|
||||
*/
|
||||
|
||||
VCROSS(vec1, &es_peqn[i2][0], &es_peqn[i3][0]);
|
||||
if( (d = VDOT(&es_peqn[i1][0], vec1)) == 0.0 )
|
||||
return( 1 );
|
||||
d = 1.0 / d;
|
||||
VCROSS(vec2, &es_peqn[i1][0], &es_peqn[i3][0]);
|
||||
VCROSS(vec3, &es_peqn[i1][0], &es_peqn[i2][0]);
|
||||
for(i=0; i<3; i++) {
|
||||
j = pos * 3 + i;
|
||||
es_rec.s.s_values[j] = d * ((es_peqn[i1][3] * vec1[i])
|
||||
- (es_peqn[i2][3] * vec2[i])
|
||||
+ (es_peqn[i3][3] * vec3[i]));
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* MV_EDGE:
|
||||
* Moves an arb edge (end1,end2) with bounding
|
||||
* planes bp1 and bp2 through point "thru"
|
||||
*/
|
||||
int
|
||||
mv_edge(thru, bp1, bp2, end1, end2)
|
||||
vect_t thru;
|
||||
int bp1, bp2, end1, end2;
|
||||
{
|
||||
float *op;
|
||||
double t;
|
||||
|
||||
if( VDOT(&es_peqn[bp1][0], es_m) == 0 ||
|
||||
VDOT(&es_peqn[bp2][0], es_m) == 0 ) {
|
||||
(void)printf("edge (direction) parallel to face\n");
|
||||
return( 1 );
|
||||
}
|
||||
t = (es_peqn[bp1][3] - VDOT(&es_peqn[bp1][0], thru)) / VDOT(&es_peqn[bp1][0], es_m);
|
||||
op = &es_rec.s.s_values[end1*3];
|
||||
VCOMP1( op, thru, t, es_m );
|
||||
|
||||
t = (es_peqn[bp2][3] - VDOT(&es_peqn[bp2][0], thru)) / VDOT(&es_peqn[bp2][0], es_m);
|
||||
op = &es_rec.s.s_values[end2*3];
|
||||
VCOMP1( op, thru, t, es_m );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
+249
-26
@@ -41,24 +41,80 @@ static char RCSid[] = "@(#)$Header$ (BRL)";
|
||||
|
||||
extern int printf();
|
||||
|
||||
static void arb_ed(), ars_ed(), ell_ed(), tgc_ed(), tor_ed(), spline_ed();
|
||||
static void arb8_ed(), ars_ed(), ell_ed(), tgc_ed(), tor_ed(), spline_ed();
|
||||
static void arb7_ed(), arb6_ed(), arb5_ed(), arb4_ed();
|
||||
|
||||
void pscale();
|
||||
|
||||
struct menu_item arb_menu[] = {
|
||||
{ "ARB MENU", (void (*)())NULL, 0 },
|
||||
{ "move edge 12", arb_ed, 12 },
|
||||
{ "move edge 23", arb_ed, 23 },
|
||||
{ "move edge 34", arb_ed, 43 },
|
||||
{ "move edge 14", arb_ed, 14 },
|
||||
{ "move edge 15", arb_ed, 15 },
|
||||
{ "move edge 26", arb_ed, 26 },
|
||||
{ "move edge 56", arb_ed, 56 },
|
||||
{ "move edge 67", arb_ed, 67 },
|
||||
{ "move edge 78", arb_ed, 87 },
|
||||
{ "move edge 58", arb_ed, 58 },
|
||||
{ "move edge 37", arb_ed, 37 },
|
||||
{ "move edge 48", arb_ed, 48 },
|
||||
struct menu_item arb8_menu[] = {
|
||||
{ "ARB8 MENU", (void (*)())NULL, 0 },
|
||||
{ "move edge 12", arb8_ed, 0 },
|
||||
{ "move edge 23", arb8_ed, 1 },
|
||||
{ "move edge 34", arb8_ed, 2 },
|
||||
{ "move edge 14", arb8_ed, 3 },
|
||||
{ "move edge 15", arb8_ed, 4 },
|
||||
{ "move edge 26", arb8_ed, 5 },
|
||||
{ "move edge 56", arb8_ed, 6 },
|
||||
{ "move edge 67", arb8_ed, 7 },
|
||||
{ "move edge 78", arb8_ed, 8 },
|
||||
{ "move edge 58", arb8_ed, 9 },
|
||||
{ "move edge 37", arb8_ed, 10 },
|
||||
{ "move edge 48", arb8_ed, 11 },
|
||||
{ "", (void (*)())NULL, 0 }
|
||||
};
|
||||
|
||||
struct menu_item arb7_menu[] = {
|
||||
{ "ARB7 MENU", (void (*)())NULL, 0 },
|
||||
{ "move edge 12", arb7_ed, 0 },
|
||||
{ "move edge 23", arb7_ed, 1 },
|
||||
{ "move edge 34", arb7_ed, 2 },
|
||||
{ "move edge 14", arb7_ed, 3 },
|
||||
{ "move edge 15", arb7_ed, 4 },
|
||||
{ "move edge 26", arb7_ed, 5 },
|
||||
{ "move edge 56", arb7_ed, 6 },
|
||||
{ "move edge 67", arb7_ed, 7 },
|
||||
{ "move edge 37", arb7_ed, 8 },
|
||||
{ "move edge 57", arb7_ed, 9 },
|
||||
{ "move edge 45", arb7_ed, 10 },
|
||||
{ "move point 5", arb7_ed, 11 },
|
||||
{ "", (void (*)())NULL, 0 }
|
||||
};
|
||||
|
||||
struct menu_item arb6_menu[] = {
|
||||
{ "ARB6 MENU", (void (*)())NULL, 0 },
|
||||
{ "move edge 12", arb6_ed, 0 },
|
||||
{ "move edge 23", arb6_ed, 1 },
|
||||
{ "move edge 34", arb6_ed, 2 },
|
||||
{ "move edge 14", arb6_ed, 3 },
|
||||
{ "move edge 15", arb6_ed, 4 },
|
||||
{ "move edge 25", arb6_ed, 5 },
|
||||
{ "move edge 36", arb6_ed, 6 },
|
||||
{ "move edge 46", arb6_ed, 7 },
|
||||
{ "move point 5", arb6_ed, 8 },
|
||||
{ "move point 6", arb6_ed, 9 },
|
||||
{ "", (void (*)())NULL, 0 }
|
||||
};
|
||||
|
||||
struct menu_item arb5_menu[] = {
|
||||
{ "ARB5 MENU", (void (*)())NULL, 0 },
|
||||
{ "move edge 12", arb5_ed, 0 },
|
||||
{ "move edge 23", arb5_ed, 1 },
|
||||
{ "move edge 34", arb5_ed, 2 },
|
||||
{ "move edge 14", arb5_ed, 3 },
|
||||
{ "move edge 15", arb5_ed, 4 },
|
||||
{ "move edge 25", arb5_ed, 5 },
|
||||
{ "move edge 35", arb5_ed, 6 },
|
||||
{ "move edge 45", arb5_ed, 7 },
|
||||
{ "move point 5", arb5_ed, 8 },
|
||||
{ "", (void (*)())NULL, 0 }
|
||||
};
|
||||
|
||||
struct menu_item arb4_menu[] = {
|
||||
{ "ARB4 MENU", (void (*)())NULL, 0 },
|
||||
{ "move point 1", arb4_ed, 0 },
|
||||
{ "move point 2", arb4_ed, 1 },
|
||||
{ "move point 3", arb4_ed, 2 },
|
||||
{ "move point 4", arb4_ed, 4 },
|
||||
{ "", (void (*)())NULL, 0 }
|
||||
};
|
||||
|
||||
@@ -71,7 +127,7 @@ struct menu_item tgc_menu[] = {
|
||||
{ "scale d", tgc_ed, MENUP2 },
|
||||
{ "rotate H", tgc_ed, MENURH },
|
||||
{ "rotate AxB", tgc_ed, MENURAB },
|
||||
{ "move end H (rt)", tgc_ed, MENUMH },
|
||||
{ "move end H(rt)", tgc_ed, MENUMH },
|
||||
{ "move end H", tgc_ed, MENUMHH },
|
||||
{ "", (void (*)())NULL, 0 }
|
||||
};
|
||||
@@ -105,15 +161,66 @@ struct menu_item spline_menu[] = {
|
||||
|
||||
|
||||
static void
|
||||
arb_ed( arg )
|
||||
arb8_ed( arg )
|
||||
int arg;
|
||||
{
|
||||
es_menu = arg;
|
||||
es_edflag = EARB;
|
||||
newedge = 1;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
arb7_ed( arg )
|
||||
int arg;
|
||||
{
|
||||
es_menu = arg;
|
||||
es_edflag = EARB;
|
||||
if(arg == 11) {
|
||||
/* move point 5 */
|
||||
es_edflag = PTARB;
|
||||
es_menu = 4; /* location of point */
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
arb6_ed( arg )
|
||||
int arg;
|
||||
{
|
||||
es_menu = arg;
|
||||
es_edflag = EARB;
|
||||
if(arg == 8) {
|
||||
/* move point 5 location = 4 */
|
||||
es_edflag = PTARB;
|
||||
es_menu = 4;
|
||||
}
|
||||
if(arg == 9) {
|
||||
/* move point 6 location = 6 */
|
||||
es_edflag = PTARB;
|
||||
es_menu = 6;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
arb5_ed( arg )
|
||||
int arg;
|
||||
{
|
||||
es_menu = arg;
|
||||
es_edflag = EARB;
|
||||
if(arg == 8) {
|
||||
/* move point 5 at loaction 4 */
|
||||
es_edflag = PTARB;
|
||||
es_menu = 4;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
arb4_ed( arg )
|
||||
int arg;
|
||||
{
|
||||
es_menu = arg;
|
||||
es_edflag = PTARB;
|
||||
}
|
||||
|
||||
static void
|
||||
tgc_ed( arg )
|
||||
int arg;
|
||||
@@ -137,7 +244,6 @@ int arg;
|
||||
es_edflag = PSCALE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ell_ed( arg )
|
||||
int arg;
|
||||
@@ -209,6 +315,10 @@ union record *recp;
|
||||
void
|
||||
init_sedit()
|
||||
{
|
||||
union record temprec; /* copy of solid record to determine type */
|
||||
register int i, type, p1, p2, p3;
|
||||
float *op;
|
||||
|
||||
/*
|
||||
* Check for a processed region or other illegal solid.
|
||||
*/
|
||||
@@ -229,8 +339,63 @@ init_sedit()
|
||||
}
|
||||
|
||||
es_menu = 0;
|
||||
if(es_rec.s.s_cgtype < 0)
|
||||
es_rec.s.s_cgtype *= -1;
|
||||
|
||||
temprec = es_rec;
|
||||
|
||||
if( (type = es_rec.s.s_cgtype) < 0 )
|
||||
type *= -1;
|
||||
if(type == BOX || type == RPP)
|
||||
type = ARB8;
|
||||
if(type == RAW) {
|
||||
/* rearrange vectors to correspond to the
|
||||
* "standard" ARB6
|
||||
*/
|
||||
VMOVE(&temprec.s.s_values[3], &es_rec.s.s_values[9]);
|
||||
VMOVE(&temprec.s.s_values[6], &es_rec.s.s_values[21]);
|
||||
VMOVE(&temprec.s.s_values[9], &es_rec.s.s_values[12]);
|
||||
VMOVE(&temprec.s.s_values[12], &es_rec.s.s_values[3]);
|
||||
VMOVE(&temprec.s.s_values[15], &es_rec.s.s_values[6]);
|
||||
VMOVE(&temprec.s.s_values[18], &es_rec.s.s_values[18]);
|
||||
VMOVE(&temprec.s.s_values[21], &es_rec.s.s_values[15]);
|
||||
es_rec = temprec;
|
||||
type = ARB6;
|
||||
}
|
||||
es_rec.s.s_cgtype = type;
|
||||
|
||||
if( es_rec.s.s_type == GENARB8 ) {
|
||||
/* find the comgeom arb type */
|
||||
if( (type = type_arb( &es_rec )) == 0 ) {
|
||||
(void)printf("%s: BAD ARB\n",es_rec.s.s_name);
|
||||
return;
|
||||
}
|
||||
|
||||
temprec = es_rec;
|
||||
es_rec.s.s_cgtype = type;
|
||||
|
||||
/* find the plane equations */
|
||||
/* point notation - use temprec record */
|
||||
for(i=3; i<=21; i+=3) {
|
||||
op = &temprec.s.s_values[i];
|
||||
VADD2(op, op, &es_rec.s.s_values[0]);
|
||||
}
|
||||
type -= 4; /* ARB4 at location 0, ARB5 at 1, etc */
|
||||
for(i=0; i<6; i++) {
|
||||
if(faces[type][i*4] == -1)
|
||||
break; /* faces are done */
|
||||
p1 = faces[type][i*4];
|
||||
p2 = faces[type][i*4+1];
|
||||
p3 = faces[type][i*4+2];
|
||||
if(planeqn(i, p1, p2, p3, &temprec.s)) {
|
||||
(void)printf("No eqn for face %d%d%d%d\n",
|
||||
p1+1,p2+1,p3+1,faces[type][i*4+3]+1);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
printf("peqn[%d][]: %.4f %.4f %.4f %.4f\n",i,es_peqn[i][0],es_peqn[i][1],es_peqn[i][2],es_peqn[i][3]);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Save aggregate path matrix */
|
||||
pathHmat( illump, es_mat );
|
||||
@@ -265,7 +430,25 @@ sedit_menu() {
|
||||
switch( es_gentype ) {
|
||||
|
||||
case GENARB8:
|
||||
menu_array[MENU_L1] = arb_menu;
|
||||
switch( es_type ) {
|
||||
|
||||
case ARB8:
|
||||
menu_array[MENU_L1] = arb8_menu;
|
||||
break;
|
||||
|
||||
case ARB7:
|
||||
menu_array[MENU_L1] = arb7_menu;
|
||||
break;
|
||||
case ARB6:
|
||||
menu_array[MENU_L1] = arb6_menu;
|
||||
break;
|
||||
case ARB5:
|
||||
menu_array[MENU_L1] = arb5_menu;
|
||||
break;
|
||||
case ARB4:
|
||||
menu_array[MENU_L1] = arb4_menu;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GENTGC:
|
||||
menu_array[MENU_L1] = tgc_menu;
|
||||
@@ -409,6 +592,7 @@ sedit()
|
||||
pscale();
|
||||
break;
|
||||
|
||||
case PTARB: /* move an ARB point */
|
||||
case EARB: /* edit an ARB edge */
|
||||
if( inpara ) {
|
||||
/* apply es_invmat to convert to real model space */
|
||||
@@ -554,12 +738,16 @@ register struct solidrec *sp;
|
||||
static vect_t unitv;
|
||||
static float ang[5];
|
||||
static struct solidrec local;
|
||||
register int length;
|
||||
int cgtype;
|
||||
|
||||
/* make a private copy in local units */
|
||||
for(i=0; i<24; i+=3) {
|
||||
VSCALE(work, &sp->s_values[i], base2local);
|
||||
VMOVE(&local.s_values[i], work);
|
||||
}
|
||||
if( (cgtype = sp->s_cgtype) < 0 )
|
||||
cgtype *= -1;
|
||||
|
||||
switch( sp->s_type ) {
|
||||
|
||||
@@ -589,11 +777,46 @@ register struct solidrec *sp;
|
||||
|
||||
case GENARB8:
|
||||
PR_PT( 0, '1', &local.s_values[0] );
|
||||
for(i=3; i<=21; i+=3) {
|
||||
VADD2( work, &local.s_values[i], &local.s_values[0] );
|
||||
PR_PT( i/3, '1'+(i/3), work );
|
||||
switch( cgtype ) {
|
||||
case ARB8:
|
||||
es_nlines = length = 8;
|
||||
/* common area for arbs */
|
||||
arbcommon:
|
||||
for(i=3; i<=3*length; i+=3) {
|
||||
VADD2( work, &local.s_values[i], &local.s_values[0] );
|
||||
PR_PT( i/3, '1'+(i/3), work );
|
||||
}
|
||||
break;
|
||||
|
||||
case ARB7:
|
||||
es_nlines = length = 7;
|
||||
goto arbcommon;
|
||||
break;
|
||||
|
||||
case ARB6:
|
||||
es_nlines = length = 6;
|
||||
VMOVE(&local.s_values[15], &local.s_values[18]);
|
||||
goto arbcommon;
|
||||
break;
|
||||
|
||||
case ARB5:
|
||||
es_nlines = length = 5;
|
||||
goto arbcommon;
|
||||
break;
|
||||
|
||||
case ARB4:
|
||||
es_nlines = length = 4;
|
||||
VMOVE(&local.s_values[9], &local.s_values[12]);
|
||||
goto arbcommon;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* use ARB8 */
|
||||
es_nlines = length = 8;
|
||||
goto arbcommon;
|
||||
break;
|
||||
|
||||
}
|
||||
es_nlines = 8;
|
||||
break;
|
||||
|
||||
case GENELL:
|
||||
|
||||
+55
-22
@@ -33,7 +33,7 @@ static char RCSid[] = "@(#)$Header$ (BRL)";
|
||||
static void center(), cpoint(), dwreg(), ellin(), move(), neg(), points(),
|
||||
regin(), solin(), solpl(), tgcin(), tplane(),
|
||||
vectors();
|
||||
static int arb(), cgarbs(), comparvec(), gap(), planeeq(), redoarb(),
|
||||
static int arb(), cgarbs(), comparvec(), gap(), planeeq(), redoarb(),
|
||||
region();
|
||||
|
||||
static union record input; /* Holds an object file record */
|
||||
@@ -78,19 +78,17 @@ int flag, more;
|
||||
|
||||
if(type == GENARB8) {
|
||||
/* check for arb8, arb7, arb6, arb5, arb4 */
|
||||
if(input.s.s_cgtype >= 0) {
|
||||
points();
|
||||
if( (i = cgarbs(uvec, svec)) == 0 ) {
|
||||
nmemb = param_count = memb_count = 0;
|
||||
return(-1); /* ERROR */
|
||||
}
|
||||
if(redoarb(uvec, svec, i) == 0) {
|
||||
nmemb = param_count = memb_count = 0;
|
||||
return(-1); /* ERROR */
|
||||
}
|
||||
vectors();
|
||||
points();
|
||||
if( (i = cgarbs(uvec, svec)) == 0 ) {
|
||||
nmemb = param_count = memb_count = 0;
|
||||
return(-1); /* ERROR */
|
||||
}
|
||||
cgtype = input.s.s_cgtype * -1;
|
||||
if(redoarb(uvec, svec, i) == 0) {
|
||||
nmemb = param_count = memb_count = 0;
|
||||
return(-1); /* ERROR */
|
||||
}
|
||||
vectors();
|
||||
cgtype = input.s.s_cgtype;
|
||||
}
|
||||
if(cgtype == RPP || cgtype == BOX || cgtype == GENARB8)
|
||||
cgtype = ARB8;
|
||||
@@ -272,22 +270,22 @@ register int *svec; /* array of like points */
|
||||
switch( numuvec ) {
|
||||
|
||||
case 8:
|
||||
input.s.s_cgtype = -8; /* ARB8 */
|
||||
input.s.s_cgtype = ARB8; /* ARB8 */
|
||||
break;
|
||||
|
||||
case 6:
|
||||
input.s.s_cgtype = -7; /* ARB7 */
|
||||
input.s.s_cgtype = ARB7; /* ARB7 */
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if(svec[0] == 2)
|
||||
input.s.s_cgtype = -6; /* ARB6 */
|
||||
input.s.s_cgtype = ARB6; /* ARB6 */
|
||||
else
|
||||
input.s.s_cgtype = -5; /* ARB5 */
|
||||
input.s.s_cgtype = ARB5; /* ARB5 */
|
||||
break;
|
||||
|
||||
case 2:
|
||||
input.s.s_cgtype = -4; /* ARB4 */
|
||||
input.s.s_cgtype = ARB4; /* ARB4 */
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -306,11 +304,9 @@ register int *uvec, *svec;
|
||||
int numvec;
|
||||
{
|
||||
register int i, j;
|
||||
static int prod, cgtype;
|
||||
static int prod;
|
||||
|
||||
cgtype = input.s.s_cgtype * -1;
|
||||
|
||||
switch( cgtype ) {
|
||||
switch( input.s.s_cgtype ) {
|
||||
|
||||
case ARB8:
|
||||
/* do nothing */
|
||||
@@ -1347,3 +1343,40 @@ float *p1, *p2, *p3;
|
||||
peq[(lc*4)+3] = VDOT(&peq[lc*4], p1);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* TYPE_ARB() returns specific ARB type of record rec. The record rec
|
||||
* is also rearranged to "standard" form.
|
||||
*/
|
||||
type_arb( rec )
|
||||
union record *rec;
|
||||
{
|
||||
int i;
|
||||
static int uvec[8], svec[11];
|
||||
|
||||
if( rec->s.s_type != GENARB8 )
|
||||
return( 0 );
|
||||
|
||||
input = *rec; /* copy */
|
||||
|
||||
/* convert input record to points */
|
||||
points();
|
||||
|
||||
if( (i = cgarbs(uvec, svec)) == 0 )
|
||||
return(0);
|
||||
|
||||
if( redoarb(uvec, svec, i) == 0 )
|
||||
return( 0 );
|
||||
|
||||
/* convert to vectors in the rec record */
|
||||
VMOVE(&rec->s.s_values[0], &input.s.s_values[0]);
|
||||
for(i=3; i<=21; i+=3) {
|
||||
VSUB2(&rec->s.s_values[i], &input.s.s_values[i], &input.s.s_values[0]);
|
||||
}
|
||||
|
||||
return( input.s.s_cgtype );
|
||||
|
||||
}
|
||||
|
||||
|
||||
+33
-15
@@ -38,27 +38,45 @@ int es_edflag; /* type of editing for this solid */
|
||||
#define EARB 7
|
||||
#define MOVEH 8
|
||||
#define MOVEHH 9
|
||||
#define PTARB 10
|
||||
float es_scale; /* scale factor */
|
||||
float es_para[3]; /* keyboard input parameter changes */
|
||||
float es_plano[4]; /* coefficients of bounding plane 1 */
|
||||
float es_plant[4]; /* coefficients of bounding plane 2 */
|
||||
float es_peqn[7][4]; /* ARBs defining plane equations */
|
||||
float es_m[3]; /* edge(line) slope */
|
||||
int es_same[6]; /* like arb vertices */
|
||||
int es_menu; /* item selected from menu */
|
||||
#define MENUH 1
|
||||
#define MENUR1 2
|
||||
#define MENUR2 3
|
||||
#define MENUA 4
|
||||
#define MENUB 5
|
||||
#define MENUC 6
|
||||
#define MENUP1 7
|
||||
#define MENUP2 8
|
||||
#define MENURH 9
|
||||
#define MENURAB 10
|
||||
#define MENUMH 11
|
||||
#define MENUMHH 12
|
||||
#define MENUH 1
|
||||
#define MENUR1 2
|
||||
#define MENUR2 3
|
||||
#define MENUA 4
|
||||
#define MENUB 5
|
||||
#define MENUC 6
|
||||
#define MENURH 7
|
||||
#define MENURAB 8
|
||||
#define MENUMH 9
|
||||
#define MENUMHH 10
|
||||
#define MENUP1 11
|
||||
#define MENUP2 12
|
||||
mat_t es_mat; /* accumulated matrix of path */
|
||||
mat_t es_invmat; /* inverse of es_mat KAA */
|
||||
int es_nlines; /* # lines in printed display */
|
||||
#define ES_LINELEN 128 /* len of display text lines */
|
||||
char es_display[ES_LINELEN*10];/* buffer for lines of display */
|
||||
|
||||
/* face definitions for each arb type */
|
||||
static int faces[5][24] = {
|
||||
{0,1,2,3, 0,1,4,5, 1,2,4,5, 0,2,4,5, -1,-1,-1,-1, -1,-1,-1,-1}, /* ARB4 */
|
||||
{0,1,2,3, 4,0,1,5, 4,1,2,5, 4,2,3,5, 4,3,0,5, -1,-1,-1,-1}, /* ARB5 */
|
||||
{0,1,2,3, 1,2,4,6, 0,4,6,3, 4,1,0,5, 6,2,3,7, -1,-1,-1,-1}, /* ARB6 */
|
||||
{0,1,2,3, 4,5,6,7, 0,3,4,7, 1,2,6,5, 0,1,5,4, 3,2,6,4}, /* ARB7 */
|
||||
{0,1,2,3, 4,5,6,7, 0,4,7,3, 1,2,6,5, 0,1,5,4, 3,2,6,7}, /* ARB8 */
|
||||
};
|
||||
|
||||
/* planes to define ARB vertices */
|
||||
static int planes[5][24] = {
|
||||
{0,1,3, 0,1,2, 0,2,3, 0,1,3, 1,2,3, 1,2,3, 1,2,3, 1,2,3}, /* ARB4 */
|
||||
{0,1,4, 0,1,2, 0,2,3, 0,3,4, 1,2,4, 1,2,4, 1,2,4, 1,2,4}, /* ARB5 */
|
||||
{0,2,3, 0,1,3, 0,1,4, 0,2,4, 1,2,3, 1,2,3, 1,2,4, 1,2,4}, /* ARB6 */
|
||||
{0,2,4, 0,3,4, 0,3,5, 0,2,5, 1,2,4, 1,3,4, 1,3,5, 1,2,4}, /* ARB7 */
|
||||
{0,2,4, 0,3,4, 0,3,5, 0,2,5, 1,2,4, 1,3,4, 1,3,5, 1,2,5}, /* ARB8 */
|
||||
};
|
||||
|
||||
+9
-2
@@ -134,9 +134,16 @@ dotitles()
|
||||
MAT4X3PNT( work, es_mat, es_rec.s.s_values );
|
||||
MAT4X3PNT( pos_view, model2objview, work );
|
||||
dmp->dmr_puts( "1", ((int)(pos_view[X]*2048))+15, ((int)(pos_view[Y]*2048))+15, 0, DM_WHITE );
|
||||
for(i=1; i<8; i++) {
|
||||
temp_rec.s = es_rec.s;
|
||||
if(es_type == ARB4) {
|
||||
VMOVE(&temp_rec.s.s_values[9], &temp_rec.s.s_values[12]);
|
||||
}
|
||||
if(es_type == ARB6) {
|
||||
VMOVE(&temp_rec.s.s_values[15], &temp_rec.s.s_values[18]);
|
||||
}
|
||||
for(i=1; i<es_type; i++) {
|
||||
static char kvt[4] = "X\0";/* Cvts chars to strings */
|
||||
VADD2( work, es_rec.s.s_values, &es_rec.s.s_values[i*3] );
|
||||
VADD2( work, es_rec.s.s_values, &temp_rec.s.s_values[i*3] );
|
||||
MAT4X3PNT(temp, es_mat, work);
|
||||
MAT4X3PNT( pos_view, model2objview, temp );
|
||||
kvt[0] = i + '1';
|
||||
|
||||
@@ -206,6 +206,19 @@ usepen()
|
||||
VSUB2( &es_rec.s.s_tgc_H, tr_temp, &es_rec.s.s_tgc_V );
|
||||
sedraw = 1;
|
||||
return;
|
||||
case PTARB:
|
||||
/* move an arb point to indicated point */
|
||||
/* point is located at es_values[es_menu*3] */
|
||||
VADD2(temp, es_rec.s.s_values, &es_rec.s.s_values[es_menu*3]);
|
||||
MAT4X3PNT(pos_model, es_mat, temp);
|
||||
MAT4X3PNT(pos_view, model2view, pos_model);
|
||||
pos_view[X] = dm_values.dv_xpen / 2047.0;
|
||||
pos_view[Y] = dm_values.dv_ypen / 2047.0;
|
||||
MAT4X3PNT(temp, view2model, pos_view);
|
||||
MAT4X3PNT(pos_model, es_invmat, temp);
|
||||
editarb( pos_model );
|
||||
sedraw = 1;
|
||||
return;
|
||||
case EARB:
|
||||
/* move arb edge, through indicated point */
|
||||
tabvec[X] = dm_values.dv_xpen / 2047.0;
|
||||
|
||||
Reference in new issue
Block a user