Skip to content

Commit 8690355

Browse files
committed
fix #16
1 parent 2b8aa9f commit 8690355

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

utils/geom.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# define material_type void*
3131
static void material_type_copy(void **src, void **dest) { *dest = *src; }
3232
#endif
33-
#include <ctlgeom.h>
33+
#include "ctlgeom.h"
3434

3535
#ifdef CXX_CTL_IO
3636
using namespace ctlio;
@@ -138,7 +138,7 @@ void geom_fix_object(geometric_object o)
138138
break;
139139
}
140140
case GEOM PRISM:
141-
{
141+
{
142142
}
143143
break;
144144
case GEOM COMPOUND_GEOMETRIC_OBJECT:
@@ -477,7 +477,7 @@ vector3 normal_to_fixed_object(vector3 p, geometric_object o)
477477
} // switch
478478
} // case GEOM BLOCK
479479
case GEOM PRISM:
480-
{
480+
{
481481
return normal_to_prism(o.subclass.prism_data, p);
482482
}
483483
default:
@@ -916,18 +916,18 @@ int intersect_line_with_object(vector3 p, vector3 d, geometric_object o,
916916
double intersect_line_segment_with_object(vector3 p, vector3 d, geometric_object o, double a, double b)
917917
{
918918
if (o.which_subclass==GEOM PRISM)
919-
{
919+
{
920920
return intersect_line_segment_with_prism(o.subclass.prism_data, p, d, a, b);
921921
}
922922
else
923923
{ double s[2];
924-
if (2 == intersect_line_with_object(p, d, o, s))
924+
if (2 == intersect_line_with_object(p, d, o, s))
925925
{ double ds = (s[0] < s[1] ? MIN(s[1],b) - MAX(s[0],a)
926926
: MIN(s[0],b) - MAX(s[1],a)
927927
);
928928
return (ds > 0 ? ds : 0.0);
929929
}
930-
else
930+
else
931931
return 0.0;
932932
}
933933
}
@@ -2068,7 +2068,7 @@ geometric_object make_ellipsoid(material_type material, vector3 center,
20682068
return o;
20692069
}
20702070

2071-
/***************************************************************
2071+
/***************************************************************
20722072
* the remainder of this file is the content of `prism.c`
20732073
* implementing geometric primitives for prisms
20742074
*
@@ -2079,8 +2079,8 @@ geometric_object make_ellipsoid(material_type material, vector3 center,
20792079
* most calculations are done in the "prism coordinate system",
20802080
* in which the prism floor lies in the XY plane with centroid
20812081
* at the origin and the prism axis is the positive Z-axis.
2082-
* homer reid 4/2018
2083-
*
2082+
* homer reid 4/2018
2083+
*
20842084
***************************************************************/
20852085

20862086
/***************************************************************/
@@ -2108,7 +2108,7 @@ void get_prism_bounding_box(prism *prsm, geom_box *box)
21082108
int num_vertices = prsm->vertices.num_items;
21092109
double height = prsm->height;
21102110

2111-
// set x,y coordinates of low, high to bounding box
2111+
// set x,y coordinates of low, high to bounding box
21122112
// of prism base polygon (in prism coordinate system)
21132113
vector3 low=vertices[0], high=vertices[0];
21142114
int nv;
@@ -2119,11 +2119,11 @@ void get_prism_bounding_box(prism *prsm, geom_box *box)
21192119
high.y = fmax(high.y, vertices[nv].y);
21202120
};
21212121

2122-
// set z coordinates of low, high to upper and lower
2122+
// set z coordinates of low, high to upper and lower
21232123
// prism surfaces (in prism coordinate system)
21242124
low.z = 0.0;
21252125
high.z = height;
2126-
2126+
21272127
// convert from prism coordinates to cartesian coordinates
21282128
box->low = prism_coordinate_p2c(prsm, low);
21292129
box->high = prism_coordinate_p2c(prsm, high);
@@ -2139,7 +2139,7 @@ void get_prism_bounding_box(prism *prsm, geom_box *box)
21392139
boolean intersect_line_with_segment(double px, double py, double dx, double dy,
21402140
vector3 v1, vector3 v2, double *s)
21412141
{
2142-
double ax = v1.x, ay = v1.y;
2142+
double ax = v1.x, ay = v1.y;
21432143
double bx = v2.x-v1.x, by = v2.y-v1.y;
21442144
double M00 = dx, M10 = dy;
21452145
double M01 = -1.0*bx, M11 = -1.0*by;
@@ -2194,7 +2194,7 @@ boolean point_in_polygon(double px, double py, vector3 *vertices, int num_vertic
21942194
/* return 1 or 0 if xc lies inside or outside the prism */
21952195
/***************************************************************/
21962196
boolean point_in_prism(prism *prsm, vector3 xc)
2197-
{
2197+
{
21982198
vector3 *vertices = prsm->vertices.items;
21992199
int num_vertices = prsm->vertices.num_items;
22002200
double height = prsm->height;
@@ -2210,8 +2210,8 @@ boolean point_in_prism(prism *prsm, vector3 xc)
22102210
/***************************************************************/
22112211
int insert_s_in_list(double s, double slist[2], int length)
22122212
{
2213-
if (length==0)
2214-
{ slist[0]=s;
2213+
if (length==0)
2214+
{ slist[0]=s;
22152215
return 1;
22162216
}
22172217
if ( s < slist[0] )
@@ -2234,7 +2234,7 @@ int intersect_line_with_prism(prism *prsm, vector3 p, vector3 d, double slist[2]
22342234
int num_vertices = prsm->vertices.num_items;
22352235
vector3 *vertices = prsm->vertices.items;
22362236
double height = prsm->height;
2237-
2237+
22382238
// get coords of p (line origin) and components of d (line slope)
22392239
// in prism coordinate system
22402240
vector3 p_prsm = prism_coordinate_c2p(prsm,p);
@@ -2244,11 +2244,11 @@ int intersect_line_with_prism(prism *prsm, vector3 p, vector3 d, double slist[2]
22442244
// lengths to be small or large
22452245
double length_scale = vector3_norm(vector3_minus(vertices[1], vertices[0]));
22462246

2247-
// identify intersections with prism side faces
2247+
// identify intersections with prism side faces
22482248
int num_intersections=0;
22492249
int nv;
22502250
for(nv=0; nv<num_vertices; nv++)
2251-
{
2251+
{
22522252
int nvp1 = nv+1; if (nvp1==num_vertices) nvp1=0;
22532253

22542254
// first solve the in-plane portion of the problem: determine the
@@ -2261,7 +2261,7 @@ int intersect_line_with_prism(prism *prsm, vector3 p, vector3 d, double slist[2]
22612261

22622262
// OK, we know the XY-plane projection of the line intersects the polygon edge;
22632263
// now go back to 3D, ask for the z-coordinate at which the line intersects
2264-
// the z-axis extrusion of the edge, and determine whether this point lies
2264+
// the z-axis extrusion of the edge, and determine whether this point lies
22652265
// inside or outside the height of the prism.
22662266
double z_intersect = p_prsm.z + s*d_prsm.z;
22672267
double AbsTol = 1.0e-7*length_scale;
@@ -2335,7 +2335,7 @@ vector3 normal_to_prism(prism *prsm, vector3 xc)
23352335

23362336
vector3 xp = prism_coordinate_c2p(prsm, xc);
23372337
vector3 axis = {0,0,0}; axis.z=height;
2338-
2338+
23392339
vector3 retval;
23402340
double min_distance=HUGE_VAL;
23412341

@@ -2420,12 +2420,12 @@ vector3 triangle_normal(vector3 v1, vector3 v2, vector3 v3)
24202420
/***************************************************************/
24212421
/***************************************************************/
24222422
/***************************************************************/
2423-
GEOMETRIC_OBJECT make_prism(MATERIAL_TYPE material,
2423+
geometric_object make_prism(material_type material,
24242424
const vector3 *vertices, int num_vertices,
24252425
double height, vector3 axis)
24262426
{
24272427
CHECK(num_vertices>=3, "fewer than 3 vertices in make_prism");
2428-
2428+
24292429
// compute centroid of vertices
24302430
vector3 centroid = {0.0, 0.0, 0.0};
24312431
int nv;
@@ -2439,7 +2439,7 @@ GEOMETRIC_OBJECT make_prism(MATERIAL_TYPE material,
24392439
for(nv=0; nv<num_vertices; nv++)
24402440
{ int nvp1 = (nv+1) % num_vertices;
24412441
vector3 zhatp = triangle_normal(centroid,vertices[nv],vertices[nvp1]);
2442-
boolean axis_normal
2442+
boolean axis_normal
24432443
= ( vector3_nearly_equal(zhat, zhatp, tolerance)
24442444
|| vector3_nearly_equal(zhat, vector3_scale(-1.0,zhatp), tolerance)
24452445
);
@@ -2454,7 +2454,7 @@ GEOMETRIC_OBJECT make_prism(MATERIAL_TYPE material,
24542454
// note: the prism *centroid* is the center of mass of the planar vertex polygon,
24552455
// i.e. it is a point lying on the bottom surface of the prism.
24562456
// This is the origin of coordinates in the prism system.
2457-
// The *center* of the geometric object is the center of mass of the
2457+
// The *center* of the geometric object is the center of mass of the
24582458
// 3D prism. So center = centroid + 0.5*zHat.
24592459
vector3 xhat = unit_vector3(vector3_minus(vertices[1],vertices[0]));
24602460
vector3 yhat = unit_vector3(vector3_cross(zhat,xhat));
@@ -2475,7 +2475,7 @@ GEOMETRIC_OBJECT make_prism(MATERIAL_TYPE material,
24752475
prsm->vertices.items = (vector3 *)malloc(num_vertices*sizeof(vector3));
24762476
for(nv=0; nv<num_vertices; nv++)
24772477
prsm->vertices.items[nv] = prism_coordinate_c2p(prsm,vertices[nv]);
2478-
2478+
24792479
// note the center and centroid are different!
24802480
vector3 center = vector3_plus(centroid, vector3_scale(0.5*height,zhat) );
24812481
geometric_object o=make_geometric_object(material, center);

0 commit comments

Comments
 (0)