Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
10942 lines (10086 sloc) 340 KB
Index: src/libged/simulate/simrt.c
===================================================================
--- src/libged/simulate/simrt.c (revision 53222)
+++ src/libged/simulate/simrt.c (working copy)
@@ -33,55 +33,45 @@
#include "simrt.h"
-#define USE_VELOCITY_FOR_NORMAL 1
-
-/*
- * Global lists filled up while raytracing : remove these as in the forward
- * progression of a ray, the y needs to be increased gradually, no need to
- * record other info
- */
-#define MAX_OVERLAPS 4
-#define MAX_HITS 4
-#define MAX_AIRGAPS 4
-
int num_hits = 0;
int num_overlaps = 0;
int num_airgaps = 0;
+int checker = 1;
+int currentRay = 0;
+
struct overlap overlap_list[MAX_OVERLAPS];
struct hit_reg hit_list[MAX_HITS];
struct hit_reg airgap_list[MAX_AIRGAPS];
-
struct rayshot_results rt_result;
-
void
print_overlap_node(int i)
{
- bu_log("--------- Index %d -------\n", overlap_list[i].index);
+
+ bu_log("--------- Index %d -------\n", overlap_list[i].index);
bu_log("insol :%s -->> outsol :%s \n", overlap_list[i].insol->st_name,
- overlap_list[i].outsol->st_name);
+ overlap_list[i].outsol->st_name);
bu_log("Entering at (%f,%f,%f) at distance of %f",
- V3ARGS(overlap_list[i].in_point), overlap_list[i].in_dist);
- bu_log("Exiting at (%f,%f,%f) at distance of %f",
- V3ARGS(overlap_list[i].out_point), overlap_list[i].out_dist);
+ V3ARGS(overlap_list[i].in_point), overlap_list[i].in_dist);
+ bu_log("Exiting at (%f,%f,%f) at distance of %f",
+ V3ARGS(overlap_list[i].out_point), overlap_list[i].out_dist);
- bu_log("in_normal: %f,%f,%f -->> out_normal: %f,%f,%f",
- V3ARGS(overlap_list[i].in_normal),
- V3ARGS(overlap_list[i].out_normal) );
+ bu_log("in_normal: %f,%f,%f -->> out_normal: %f,%f,%f",
+ V3ARGS(overlap_list[i].in_normal),
+ V3ARGS(overlap_list[i].out_normal) );
- bu_log("incurve pdir : (%f,%f,%f), curv in dir c1: %f, curv opp dir c2: %f",
- V3ARGS(overlap_list[i].incur.crv_pdir), overlap_list[i].incur.crv_c1,
- overlap_list[i].incur.crv_c2);
+ bu_log("incurve pdir : (%f,%f,%f), curv in dir c1: %f, curv opp dir c2: %f",
+ V3ARGS(overlap_list[i].incur.crv_pdir), overlap_list[i].incur.crv_c1,
+ overlap_list[i].incur.crv_c2);
- bu_log("outcurve pdir : (%f,%f,%f), curv in dir c1: %f, curv opp dir c2: %f",
- V3ARGS(overlap_list[i].outcur.crv_pdir), overlap_list[i].outcur.crv_c1,
- overlap_list[i].outcur.crv_c2);
+ bu_log("outcurve pdir : (%f,%f,%f), curv in dir c1: %f, curv opp dir c2: %f",
+ V3ARGS(overlap_list[i].outcur.crv_pdir), overlap_list[i].outcur.crv_c1,
+ overlap_list[i].outcur.crv_c2);
-
}
@@ -99,6 +89,8 @@
int
get_overlap(struct rigid_body *rbA, struct rigid_body *rbB, vect_t overlap_min, vect_t overlap_max)
{
+ /*bu_log("get_overlap\n");
+ */
bu_log("Calculating overlap between BB of %s(%f, %f, %f):(%f,%f,%f) \
and %s(%f, %f, %f):(%f,%f,%f)",
rbA->rb_namep,
@@ -129,6 +121,8 @@
if_hit(struct application *ap, struct partition *part_headp, struct seg *UNUSED(segs))
{
+ /*bu_log("if_hit\n");
+*/
/* iterating over partitions, this will keep track of the current
* partition we're working on.
*/
@@ -153,10 +147,10 @@
vect_t onormal;
/* used for calculating the air gap distance */
- vect_t v;
+ /* vect_t v;
+*/
+ int i = 0;/*, j = 0;*/
- int i = 0, j = 0;
-
/* iterate over each partition until we get back to the head.
* each partition corresponds to a specific homogeneous region of
* material.
@@ -177,7 +171,7 @@
pp->pt_regionp->reg_regionid,
pp->pt_regionp->reg_aircode,
pp->pt_regionp->reg_gmater);
-
+
if(pp->pt_regionp->reg_aircode != 0)
bu_log("AIR REGION FOUND !!");
@@ -287,24 +281,24 @@
* though they may belong to the same comb(A or B) but
* we do not check that here. We just record the points and prims in the airgap_list[].
*/
- if( (num_hits > 1) &&
+ /*if( (num_hits > 1) &&
(!VEQUAL(hit_list[i].in_point, hit_list[i-1].out_point))
- ){
+ ){*/
/* There has been at least 1 out_point recorded and the
* in_point of current hit reg. does not match out_point of previous hit reg.
*/
- if(num_airgaps < MAX_AIRGAPS){
+ /* if(num_airgaps < MAX_AIRGAPS){
j = num_airgaps;
VMOVE(airgap_list[j].in_point, hit_list[i].in_point);
- VMOVE(airgap_list[j].out_point, hit_list[i-1].out_point); /* Note: i-1 */
- VSUB2(v, airgap_list[j].out_point, airgap_list[j].in_point);
+ VMOVE(airgap_list[j].out_point, hit_list[i-1].out_point);*/ /* Note: i-1 */
+ /* VSUB2(v, airgap_list[j].out_point, airgap_list[j].in_point);
airgap_list[j].out_dist = MAGNITUDE(v);
airgap_list[j].in_stp = hit_list[i].in_stp;
- airgap_list[j].out_stp = hit_list[i-1].out_stp; /* Note: i-1 */
-
+ airgap_list[j].out_stp = hit_list[i-1].out_stp; *//* Note: i-1 */
+/*
airgap_list[j].index = j;
bu_log("\nRecorded AIR GAP in %s(%f,%f,%f), out %s(%f,%f,%f), gap size %f mm\n",
@@ -321,8 +315,8 @@
bu_log("if_hit: WARNING Skipping AIR region as maximum AIR regions reached");
}
+*/
-
}
else{
bu_log("if_hit: WARNING Skipping hit region as maximum hits reached");
@@ -347,11 +341,15 @@
{
int i = 0;
+ /*bu_log("if_overlap : num_overlaps = %d\n", num_overlaps);
+
bu_log("if_overlap: OVERLAP between %s and %s", reg1->reg_name, reg2->reg_name);
+*/
-
if(num_overlaps < MAX_OVERLAPS){
+ /*bu_log("DAMN!\n");*/
i = num_overlaps;
+ /*bu_log("if_overlap : i = %d\n", i);*/
overlap_list[i].ap = ap;
overlap_list[i].pp = pp;
overlap_list[i].reg1 = reg1;
@@ -401,7 +399,12 @@
bu_log("if_overlap: WARNING Skipping overlap region as maximum overlaps reached");
}
- return rt_defoverlap (ap, pp, reg1, reg2, InputHdp);
+ /*bu_log("if_overlap : after finding overlaps the number of num_overlaps = %d\n", num_overlaps);
+*/
+ /* int k;
+ k = rt_defoverlap(ap, pp, reg1, reg2, InputHdp);
+ bu_log("if_overlap : k = %d\n", k);
+ */return rt_defoverlap(ap, pp, reg1, reg2, InputHdp);
}
@@ -410,6 +413,8 @@
{
struct application ap;
+ /*bu_log("shoot_ray : Calling this function\n");
+*/
/* Initialize the table of resource structures */
/* rt_init_resource(&res_tab, 0, rtip); */
@@ -418,6 +423,8 @@
ap.a_hit = if_hit; /* branch to if_hit routine */
ap.a_miss = if_miss; /* branch to if_miss routine */
ap.a_overlap = if_overlap;/* branch to if_overlap routine */
+ /*bu_log("shoot_ray : num_overlaps = %i\n", num_overlaps);
+ bu_log("shoot_ray : ap.a_overlap = %f ap.a_hit = %f ap.a_miss = %f\n", ap.a_overlap, ap.a_hit, ap.a_miss); */
/*ap.a_logoverlap = rt_silent_logoverlap;*/
ap.a_onehit = 0; /* continue through shotline after hit */
ap.a_purpose = "Sim Manifold ray";
@@ -516,6 +523,8 @@
struct bu_vls reg_vls = BU_VLS_INIT_ZERO;
struct rt_comb_internal *comb =(struct rt_comb_internal *)NULL;
+ /* bu_log("traverse_xray_lists : num_overlaps = %d\n", num_overlaps);
+*/
/* Draw all the overlap regions : lines are added for overlap segments
* to help visual debugging
*/
@@ -601,7 +610,8 @@
struct bu_vls reg_vls = BU_VLS_INIT_ZERO;
struct rt_comb_internal *comb =(struct rt_comb_internal *)NULL;
-
+ /* bu_log("traverse_yray_lists : num_overlaps = %d\n", num_overlaps);
+*/
/* Draw all the overlap regions : lines are added for overlap segments
* to help visual debugging
*/
@@ -677,20 +687,22 @@
int
traverse_zray_lists(
- struct sim_manifold *current_manifold,
+ struct sim_manifold *UNUSED(current_manifold),
struct simulation_params *sim_params,
point_t pt, point_t dir)
{
- int i, rv;
+ int i;/* rv;*/
/*struct hit_reg *hrp;*/
struct bu_vls reg_vls = BU_VLS_INIT_ZERO;
- struct rt_comb_internal *comb =(struct rt_comb_internal *)NULL;
+ /* struct rt_comb_internal *comb =(struct rt_comb_internal *)NULL;
+*/
+ bu_log("traverse_zray_lists : num_overlaps = %d\n", num_overlaps);
-
/* Draw all the overlap regions : lines are added for overlap segments
* to help visual debugging
*/
+
for(i=0; i<num_overlaps; i++){
bu_vls_sprintf(&reg_vls, "ray_overlap_%s_%s_%d_%f_%f_%f_%f_%f_%f",
@@ -704,7 +716,7 @@
line(sim_params->gedp, bu_vls_addr(&reg_vls),
overlap_list[i].in_point,
overlap_list[i].out_point,
- 0, 210, 0);
+ 0, 0, 255);
bu_log("traverse_zray_lists: %s", bu_vls_addr(&reg_vls));
@@ -714,17 +726,17 @@
/* Fill up the result structure */
/* Only check with the comb of rigid body B */
- comb = (struct rt_comb_internal *)(current_manifold->rbB->intern.idb_ptr);
-
+ /*comb = (struct rt_comb_internal *)(current_manifold->rbB->intern.idb_ptr);
+ */
/* Check if the in solid belongs to rbB */
- rv = check_tree_funcleaf(sim_params->gedp->ged_wdbp->dbip,
+ /*rv = check_tree_funcleaf(sim_params->gedp->ged_wdbp->dbip,
comb,
comb->tree,
find_solid,
(genptr_t)(overlap_list[i].insol->st_name));
if(rv == FOUND && !exists_normal(overlap_list[i].in_normal) ){
- /* It does, so sum the in_normal */
- bu_log("traverse_zray_lists: %s is present in %s", overlap_list[i].insol->st_name,
+ */ /* It does, so sum the in_normal */
+ /* bu_log("traverse_zray_lists: %s is present in %s", overlap_list[i].insol->st_name,
current_manifold->rbB->rb_namep);
bu_log("traverse_zray_lists: resultant_normal_B is (%f,%f,%f)", V3ARGS(rt_result.resultant_normal_B));
@@ -733,17 +745,17 @@
V3ARGS(rt_result.resultant_normal_B), V3ARGS(overlap_list[i].in_normal));
add_normal(overlap_list[i].in_normal);
- }
+ }*/
/* Check if the out solid belongs to rbB */
- rv = check_tree_funcleaf(sim_params->gedp->ged_wdbp->dbip,
+ /*rv = check_tree_funcleaf(sim_params->gedp->ged_wdbp->dbip,
comb,
comb->tree,
find_solid,
(genptr_t)(overlap_list[i].outsol->st_name));
if(rv == FOUND && !exists_normal(overlap_list[i].out_normal) ){
- /* It does, so sum the out_normal */
- bu_log("traverse_zray_lists: %s is present in %s", overlap_list[i].outsol->st_name,
+ */ /* It does, so sum the out_normal */
+ /* bu_log("traverse_zray_lists: %s is present in %s", overlap_list[i].outsol->st_name,
current_manifold->rbB->rb_namep);
bu_log("traverse_zray_lists: resultant_normal_B is (%f,%f,%f)", V3ARGS(rt_result.resultant_normal_B));
@@ -752,7 +764,7 @@
V3ARGS(rt_result.resultant_normal_B), V3ARGS(overlap_list[i].out_normal));
add_normal(overlap_list[i].out_normal);
- }
+ }*/
}
@@ -778,20 +790,23 @@
fastf_t depth;
struct rt_comb_internal *comb =(struct rt_comb_internal *)NULL;
-
+ /* bu_log("traverse_normalray_list : num_overlaps = %d\n", num_overlaps);
+*/
/* Draw all the overlap regions : lines are added for overlap segments
* to help visual debugging
*/
for(i=0; i<num_overlaps; i++){
+ bu_log("Do you ever enter here?\n");
+
bu_vls_sprintf(&reg_vls, "ray_ovrlp_%s_%s_%d_%f_%f_%f_%f_%f_%f",
overlap_list[i].reg1->reg_name,
overlap_list[i].reg2->reg_name,
overlap_list[i].index,
V3ARGS(pt), V3ARGS(dir));
-
+
clear_bad_chars(&reg_vls);
-
+
line(sim_params->gedp, bu_vls_addr(&reg_vls),
overlap_list[i].in_point,
overlap_list[i].out_point,
@@ -870,6 +885,8 @@
} /* end-for overlap */
+ /* bu_log("traverse_normalray_list : rt_result.overlap_found = %d\n", rt_result.overlap_found);
+*/
/* Investigate hit regions, only if no overlap was found for the ENTIRE bunch of
* rays being shot, thus rt_result.overlap_found is set to FALSE, before a single
@@ -879,7 +896,7 @@
*/
if(!rt_result.overlap_found){
- bu_log("traverse_normalray_lists : No overlap found yet, checking hit regions");
+ bu_log("traverse_normalray_lists : No overlap found yet, checking hit regions\n");
/* Draw the hit regions */
@@ -1105,75 +1122,51 @@
vect_t overlap_max)
{
point_t r_pt, r_dir;
- fastf_t starty, startx, x, y, incr_x, incr_y;
- vect_t diff;
+ fastf_t x, y, constant;
+ vect_t initialOverlapMin;
+ vect_t initialOverlapMax;
/* Set direction as straight down Z-axis */
VSET(r_dir, 0.0, 0.0, 1.0);
+ bu_log("shoot_z_rays gets called\n");
bu_log("Querying overlap between A:%s & B:%s",
current_manifold->rbA->rb_namep,
current_manifold->rbB->rb_namep);
- /* Determine the width along z axis */
- VSUB2(diff, overlap_max, overlap_min);
-
- /* If it's thinner than TOLerance, reduce TOL, so that only 2 boundary rays shot
- */
- incr_y = TOL;
- if(diff[Y] < TOL){
- incr_y = diff[Y]*0.5;
+ bu_log("overlap_min (%f,%f,%f)\n", V3ARGS(overlap_min));
+ bu_log("overlap_max (%f,%f,%f)\n", V3ARGS(overlap_max));
+
+ if (checker == 1) {
+ bu_log("DO YOU ENTER HERE?\n");
+ VMOVE(initialOverlapMin, overlap_min);
+ VMOVE(initialOverlapMax, overlap_max);
+ checker = 0;
}
- incr_x = TOL;
- if(diff[X] < TOL){
- incr_x = diff[X]*0.5;
- }
+ constant = (initialOverlapMax[X] + initialOverlapMin[X]) / MAX_NR_RAYS;
- starty = overlap_min[Y] - incr_y;
+ bu_log("constant = %f\n", constant);
- /* Shoot rays vertically and across the xy plane */
- for(y=starty; y<overlap_max[Y]; ){
+ if (currentRay < MAX_NR_RAYS) {
- y += incr_y;
- if(y > overlap_max[Y])
- y = overlap_max[Y];
+ x = overlap_min[X] + currentRay * TOL * 10;
+ y = overlap_min[Y] + currentRay * TOL * 10;
+
+ VSET(r_pt, x, y, overlap_min[Z]);
- startx = overlap_min[X] - incr_x;
+ bu_log("*********r_pt (%f,%f,%f)\n", V3ARGS(r_pt));
+
+ currentRay = currentRay + 1;
+ num_overlaps = 0;
+ shoot_ray(sim_params->rtip, r_pt, r_dir);
- for(x=startx; x<overlap_max[X]; ){
-
- x += incr_x;
- if(x > overlap_max[X])
- x = overlap_max[X];
-
- /* Shooting towards higher z, so start from min z outside of overlap box */
- VSET(r_pt, x, y, overlap_min[Z]);
-
- bu_log("*****shoot_z_rays : From : (%f,%f,%f) , dir:(%f,%f,%f)*******",
- V3ARGS(r_pt), V3ARGS(r_dir));
-
- num_overlaps = 0;
- shoot_ray(sim_params->rtip, r_pt, r_dir);
-
- /* Traverse the hit list and overlap list, drawing the ray segments
- * for the current ray
- */
- traverse_zray_lists(current_manifold, sim_params, r_pt, r_dir);
-
- /* Cleanup the overlap and hit lists and free memory */
- cleanup_lists();
-
- /*bu_log("Last x ray fired from x = %f, overlap_max[X]=%f", x, overlap_max[X]);*/
-
- }
-
- /*bu_log("Last y ray fired from y = %f, overlap_max[Y]=%f", y, overlap_max[Y]);*/
-
+ traverse_zray_lists(current_manifold, sim_params, r_pt, r_dir);
+
}
+ cleanup_lists();
-
return GED_OK;
}
@@ -1346,19 +1339,19 @@
init_rayshot_results();
-#ifndef USE_VELOCITY_FOR_NORMAL
+//#ifndef USE_VELOCITY_FOR_NORMAL
/* Shoot rays right here as the pair of rigid_body ptrs are known,
* TODO: ignore volumes already shot
*/
- shoot_x_rays(rt_mf, sim_params, overlap_min, overlap_max);
- shoot_y_rays(rt_mf, sim_params, overlap_min, overlap_max);
+/* shoot_x_rays(rt_mf, sim_params, overlap_min, overlap_max);
+ shoot_y_rays(rt_mf, sim_params, overlap_min, overlap_max);*/
shoot_z_rays(rt_mf, sim_params, overlap_min, overlap_max);
-#endif
+//#endif
/* Create the contact pairs and normals : Currently just 1 manifold is allowed per pair of objects*/
- create_contact_pairs(rt_mf, sim_params, overlap_min, overlap_max);
-
+/* create_contact_pairs(rt_mf, sim_params, overlap_min, overlap_max);
+*/
return GED_OK;
}
Index: src/libged/simulate/simrt.h
===================================================================
--- src/libged/simulate/simrt.h (revision 53222)
+++ src/libged/simulate/simrt.h (working copy)
@@ -59,14 +59,28 @@
* region in half, generating manifolds in a plane.
*/
#define TOL 0.04
-
+#define MAX_NR_RAYS 10
/*
* Maximum normals allowed to be detected by ray shots
*/
#define MAX_NORMALS 10
+#define USE_VELOCITY_FOR_NORMAL 1
/*
+ * Global lists filled up while raytracing : remove these as in the forward
+ * progression of a ray, the y needs to be increased gradually, no need to
+ * record other info
+ */
+#define MAX_OVERLAPS 4
+#define MAX_HITS 4
+#define MAX_AIRGAPS 4
+
+extern int num_hits;
+extern int num_overlaps;
+extern int num_airgaps;
+
+/*
* This structure is a single node of an array
* of overlap regions: similar to the one in nirt/usrfrmt.h
*/
Index: src/libged/simulate/simulate.c
===================================================================
--- src/libged/simulate/simulate.c (revision 53222)
+++ src/libged/simulate/simulate.c (working copy)
@@ -305,11 +305,11 @@
/* Store this world transformation to undo it before next world transformation */
MAT_COPY(current_node->m_prev, current_node->m);
- /*insert_AABB(gedp, sim_params, current_node);
+ insert_AABB(gedp, sim_params, current_node);
print_manifold_list(current_node);
- insert_manifolds(gedp, sim_params, current_node);*/
+ insert_manifolds(gedp, sim_params, current_node);
current_node->num_bt_manifolds = 0;
@@ -442,7 +442,7 @@
sim_params.rtip->useair = 1;
/* Initialize the raytrace world */
- //init_raytrace(&sim_params);
+ init_raytrace(&sim_params);
/* Recreate sim.c to clear AABBs and manifold regions from previous iteration */
recreate_sim_comb(gedp, &sim_params);
Index: src/libged/simulate/simutils.c
===================================================================
--- src/libged/simulate/simutils.c (revision 53222)
+++ src/libged/simulate/simutils.c (working copy)
@@ -237,6 +237,9 @@
char *cmd_args[5];
int rv, argc = 4;
+ bu_log("add_to_comb : target : %s\n", target);
+ bu_log("add_to_comb : add : %s\n", add);
+
cmd_args[0] = bu_strdup("comb");
cmd_args[1] = bu_strdup(target);
cmd_args[2] = bu_strdup("u");
@@ -306,7 +309,7 @@
cmd_args[19] = (char *)0;
- /* print_command(cmd_args, 19); */
+ print_command(cmd_args, 19);
rv = ged_in(gedp, argc, (const char **)cmd_args);
if (rv != GED_OK) {
Index: src/libged/simulate/simphysics.cpp
===================================================================
--- src/libged/simulate/simphysics.cpp (revision 53222)
+++ src/libged/simulate/simphysics.cpp (working copy)
@@ -141,7 +141,7 @@
collision_shapes.push_back(bb_Shape);
volume = current_node->bb_dims[0] * current_node->bb_dims[1] * current_node->bb_dims[2];
- mass = 1.0; //volume; // density is 1
+ mass = 1;//volume; // density is 1
btVector3 bb_Inertia(0, 0, 0);
bb_Shape->calculateLocalInertia(mass, bb_Inertia);
@@ -249,7 +249,7 @@
//Copy the transform matrix
MAT_COPY(current_node->m, m);
- print_matrices(current_node->rb_namep, current_node->m, m);
+ //print_matrices(current_node->rb_namep, current_node->m, m);
//Get the state of the body
current_node->state = bb_RigidBody->getActivationState();
@@ -522,9 +522,9 @@
/*dispatcher->registerCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,
SPHERE_SHAPE_PROXYTYPE,
new btRTCollisionAlgorithm::CreateFunc);*/
- /* dispatcher->registerCollisionCreateFunc(BOX_SHAPE_PROXYTYPE,
+ dispatcher->registerCollisionCreateFunc(BOX_SHAPE_PROXYTYPE,
BOX_SHAPE_PROXYTYPE,
- new btRTCollisionAlgorithm::CreateFunc);*/
+ new btRTCollisionAlgorithm::CreateFunc);
btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
@@ -537,7 +537,7 @@
add_rigid_bodies(dynamicsWorld, collision_shapes);
//Add a broadphase callback to hook to the AABB detection algos
-/* btOverlapFilterCallback * filterCallback = new broadphase_callback();
+ btOverlapFilterCallback * filterCallback = new broadphase_callback();
dynamicsWorld->getPairCache()->setOverlapFilterCallback(filterCallback);
//Add a nearphase callback to hook to the contact points generation algos
@@ -546,7 +546,7 @@
//Investigating the contact pairs used between 2 rigid bodies
gContactAddedCallback = contact_added;
gContactProcessedCallback = contact_processed;
- gContactDestroyedCallback = contact_destroyed;*/
+ gContactDestroyedCallback = contact_destroyed;
//Step the physics the required number of times
step_physics(dynamicsWorld);
Index: src/librt/primitives/extrude/extrude.c
===================================================================
--- src/librt/primitives/extrude/extrude.c (revision 53222)
+++ src/librt/primitives/extrude/extrude.c (working copy)
@@ -46,7 +46,7 @@
vect_t u_vec, vect_t v_vec, struct rt_sketch_internal *sketch_ip, genptr_t seg);
struct extrude_specific {
- mat_t rot, irot; /* rotation and translation to get extrusion vector in +z direction with V at origin */
+ mat_t rot, irot; /* rotation and translation to get extrsuion vector in +z direction with V at origin */
vect_t unit_h; /* unit vector in direction of extrusion vector */
vect_t u_vec; /* u vector rotated and projected */
vect_t v_vec; /* v vector rotated and projected */
Index: src/librt/primitives/arbn/arbn.c
===================================================================
--- src/librt/primitives/arbn/arbn.c (revision 53222)
+++ src/librt/primitives/arbn/arbn.c (working copy)
@@ -120,7 +120,7 @@
/*
* ARBN must be convex. Test for concavity.
- * Byproduct is an enumeration of all the vertices,
+ * Byproduct is an enumeration of all the verticies,
* which are used to make the bounding RPP. No need
* to call the bbox routine, as the work must be duplicated
* here to count faces.
@@ -472,7 +472,7 @@
point_count++;
}
/* Point counts of 1 are (generally) not harmful,
- * occurring on pyramid peaks and the like.
+ * occuring on pyramid peaks and the like.
*/
}
}
@@ -590,7 +590,7 @@
struct arbn_pts *pts;
struct arbn_edges *edges; /* A list of edges for each plane eqn (each face) */
size_t *edge_count; /* number of edges for each face */
- size_t max_edge_count; /* maximum number of edges for any face */
+ size_t max_edge_count; /* maximium number of edges for any face */
struct vertex **verts; /* Array of pointers to vertex structs */
struct vertex ***loop_verts; /* Array of pointers to vertex structs to pass to nmg_cmface */
@@ -952,7 +952,6 @@
unsigned long neqn;
int double_count;
size_t byte_count;
- double *eqn;
RT_CK_DB_INTERNAL(ip);
BU_CK_EXTERNAL(ep);
@@ -973,14 +972,9 @@
aip->magic = RT_ARBN_INTERNAL_MAGIC;
aip->neqn = neqn;
if (aip->neqn <= 0) return -1;
+ aip->eqn = (plane_t *)bu_malloc(byte_count, "arbn plane eqn[]");
- eqn = (double *)bu_malloc(byte_count, "arbn plane eqn[] temp buf");
- ntohd((unsigned char *)eqn, (unsigned char *)ep->ext_buf + 4, double_count);
- aip->eqn = (plane_t *)bu_malloc(double_count * sizeof(fastf_t), "arbn plane eqn[]");
- for (i=0; i < aip->neqn; i++) {
- HMOVE(aip->eqn[i], &eqn[i*ELEMENTS_PER_PLANE]);
- }
- bu_free(eqn, "arbn plane eqn[] temp buf");
+ ntohd((unsigned char *)aip->eqn, (unsigned char *)ep->ext_buf + 4, double_count);
/* Transform by the matrix, if we have one that is not the identity */
if (mat && !bn_mat_is_identity(mat)) {
@@ -1021,8 +1015,8 @@
{
struct rt_arbn_internal *aip;
size_t i;
- double *vec;
- double *sp;
+ fastf_t *vec;
+ fastf_t *sp;
int double_count;
int byte_count;
@@ -1153,7 +1147,7 @@
V4ARGS(arbn->eqn[i]));
}
} else if (attr[0] == 'P') {
- if (isdigit((int)attr[1]) == 0) {
+ if (isdigit(attr[1]) == 0) {
bu_vls_printf(logstr, "ERROR: Illegal plane number\n");
return BRLCAD_ERROR;
}
@@ -1253,7 +1247,7 @@
arbn->eqn = (plane_t *)bu_realloc(arbn->eqn,
(arbn->neqn) * sizeof(plane_t),
"arbn->eqn");
- } else if (isdigit((int)argv[0][1])) {
+ } else if (isdigit(argv[0][1])) {
i = atoi(&argv[0][1]);
} else {
bu_vls_printf(logstr,
Index: src/librt/primitives/revolve/revolve.c
===================================================================
--- src/librt/primitives/revolve/revolve.c (revision 53222)
+++ src/librt/primitives/revolve/revolve.c (working copy)
@@ -68,7 +68,7 @@
fastf_t radius;
point_t center;
- int *endcount = NULL;
+ int *endcount;
size_t nseg, i, j, k;
RT_CK_DB_INTERNAL(ip);
@@ -79,8 +79,9 @@
* if even, the point is ok
* if odd, the point is at the end of a path
*/
- if (rip->skt->vert_count)
- endcount = (int *)bu_calloc(rip->skt->vert_count, sizeof(int), "endcount");
+ endcount = (int *)bu_calloc(rip->skt->vert_count, sizeof(int), "endcount");
+ for (i=0; i<rip->skt->vert_count; i++)
+ endcount[i] = 0;
nseg = rip->skt->curve.count;
for (i=0; i<nseg; i++) {
@@ -138,8 +139,7 @@
j++;
}
}
- while (j < rip->skt->vert_count)
- endcount[j++] = -1;
+ while (j < rip->skt->vert_count) endcount[j++] = -1;
VMOVE(zUnit, rip->axis3d);
VUNITIZE(zUnit);
@@ -158,8 +158,7 @@
(*min)[Z] = center[Z] - radius;
(*max)[Z] = center[Z] + radius;
- if (rip->skt->vert_count)
- bu_free(endcount, "endcount");
+ bu_free(endcount, "endcount");
return 0; /* OK */
}
@@ -187,7 +186,7 @@
vect_t xEnd, yEnd;
- int *endcount = NULL;
+ int *endcount;
size_t nseg, i, j, k;
if (rtip) RT_CK_RTI(rtip);
@@ -227,9 +226,9 @@
* if even, the point is ok
* if odd, the point is at the end of a path
*/
- if (rev->skt->vert_count) {
- endcount = (int *)bu_calloc(rev->skt->vert_count, sizeof(int), "endcount");
- }
+ endcount = (int *)bu_calloc(rev->skt->vert_count, sizeof(int), "endcount");
+ for (i=0; i<rev->skt->vert_count; i++)
+ endcount[i] = 0;
nseg = rev->skt->curve.count;
for (i=0; i<nseg; i++) {
@@ -287,8 +286,7 @@
j++;
}
}
- while (j < rev->skt->vert_count)
- endcount[j++] = -1;
+ while (j < rev->skt->vert_count) endcount[j++] = -1;
rev->ends = endcount;
@@ -1212,7 +1210,7 @@
vect_t ell[16], cir[16], ucir[16], height, xdir, ydir, ux, uy, uz, rEnd, xEnd, yEnd;
fastf_t cos22_5 = 0.9238795325112867385;
fastf_t cos67_5 = 0.3826834323650898373;
- int *endcount = NULL;
+ int *endcount;
point_t add, add2, add3;
BU_CK_LIST_HEAD(vhead);
@@ -1275,9 +1273,10 @@
VREVERSE(ucir[12], ucir[4]);
/* find open endpoints, and determine which points are used */
- if (nvert)
- endcount = (int *)bu_calloc(nvert, sizeof(int), "endcount");
-
+ endcount = (int *)bu_calloc(rip->skt->vert_count, sizeof(int), "endcount");
+ for (i=0; i<rip->skt->vert_count; i++) {
+ endcount[i] = 0;
+ }
nseg = rip->skt->curve.count;
for (i=0; i<nseg; i++) {
@@ -1357,9 +1356,7 @@
}
}
nadd = j;
- while (j < rip->skt->vert_count) {
- endcount[j++] = -1;
- }
+ while (j < rip->skt->vert_count) endcount[j++] = -1;
/* draw sketch outlines */
for (i=0; i<narc; i++) {
@@ -1409,8 +1406,7 @@
}
}
- if (nvert)
- bu_free(endcount, "endcount");
+ bu_free(endcount, "endcount");
return 0;
}
Index: src/librt/primitives/poly/poly.c
===================================================================
--- src/librt/primitives/poly/poly.c (revision 53222)
+++ src/librt/primitives/poly/poly.c (working copy)
@@ -266,7 +266,7 @@
dn = VDOT(trip->tri_wn, rp->r_dir);
/*
- * If ray lies directly along the face, (i.e., dot product
+ * If ray lies directly along the face, (ie, dot product
* is zero), drop this face.
*/
abs_dn = dn >= 0.0 ? dn : (-dn);
@@ -389,7 +389,7 @@
dot1 = dot2;
dot2 = VDOT(rp->r_dir, hits[i].hit_normal);
if (dot1 > 0.0 && dot2 > 0.0) {
- /* two consecutive exits,
+ /* two consectutive exits,
* manufacture an entrance at same distance
* as second exit.
*/
@@ -401,7 +401,7 @@
nhits++;
bu_log("\t\tadding fictitious entry at %f (%s)\n", hits[i].hit_dist, stp->st_name);
} else if (dot1 < 0.0 && dot2 < 0.0) {
- /* two consecutive entrances,
+ /* two consectutive entrances,
* manufacture an exit between them.
*/
Index: src/librt/primitives/pnts/pnts.c
===================================================================
--- src/librt/primitives/pnts/pnts.c (revision 53222)
+++ src/librt/primitives/pnts/pnts.c (working copy)
@@ -165,7 +165,7 @@
register struct pnt *point;
for (BU_LIST_FOR(point, pnt, &(((struct pnt *)pnts->point)->l))) {
- double v[3];
+ point_t v;
/* pack v */
VSCALE(v, point->v, local2mm);
@@ -178,17 +178,15 @@
register struct pnt_color *point;
for (BU_LIST_FOR(point, pnt_color, &(((struct pnt_color *)pnts->point)->l))) {
- double v[3];
+ point_t v;
double c[3];
- fastf_t cf[3];
/* pack v */
VSCALE(v, point->v, local2mm);
buf = pnts_pack_double(buf, (unsigned char *)v, ELEMENTS_PER_POINT);
/* pack c */
- bu_color_to_rgb_floats(&point->c, cf);
- VMOVE(c, cf);
+ bu_color_to_rgb_floats(&point->c, c);
buf = pnts_pack_double(buf, (unsigned char *)c, 3);
}
@@ -198,7 +196,7 @@
register struct pnt_scale *point;
for (BU_LIST_FOR(point, pnt_scale, &(((struct pnt_scale *)pnts->point)->l))) {
- double v[3];
+ point_t v;
double s[1];
/* pack v */
@@ -216,8 +214,8 @@
register struct pnt_normal *point;
for (BU_LIST_FOR(point, pnt_normal, &(((struct pnt_normal *)pnts->point)->l))) {
- double v[3];
- double n[3];
+ point_t v;
+ vect_t n;
/* pack v */
VSCALE(v, point->v, local2mm);
@@ -234,9 +232,8 @@
register struct pnt_color_scale *point;
for (BU_LIST_FOR(point, pnt_color_scale, &(((struct pnt_color_scale *)pnts->point)->l))) {
- double v[3];
+ point_t v;
double c[3];
- fastf_t cf[3];
double s[1];
/* pack v */
@@ -244,8 +241,7 @@
buf = pnts_pack_double(buf, (unsigned char *)v, ELEMENTS_PER_POINT);
/* pack c */
- bu_color_to_rgb_floats(&point->c, cf);
- VMOVE(c, cf);
+ bu_color_to_rgb_floats(&point->c, c);
buf = pnts_pack_double(buf, (unsigned char *)c, 3);
/* pack s */
@@ -259,18 +255,16 @@
register struct pnt_color_normal *point;
for (BU_LIST_FOR(point, pnt_color_normal, &(((struct pnt_color_normal *)pnts->point)->l))) {
- double v[3];
+ point_t v;
double c[3];
- fastf_t cf[3];
- double n[3];
+ vect_t n;
/* pack v */
VSCALE(v, point->v, local2mm);
buf = pnts_pack_double(buf, (unsigned char *)v, ELEMENTS_PER_POINT);
/* pack c */
- bu_color_to_rgb_floats(&point->c, cf);
- VMOVE(c, cf);
+ bu_color_to_rgb_floats(&point->c, c);
buf = pnts_pack_double(buf, (unsigned char *)c, 3);
/* pack n */
@@ -284,9 +278,9 @@
register struct pnt_scale_normal *point;
for (BU_LIST_FOR(point, pnt_scale_normal, &(((struct pnt_scale_normal *)pnts->point)->l))) {
- double v[3];
+ point_t v;
double s[1];
- double n[3];
+ vect_t n;
/* pack v */
VSCALE(v, point->v, local2mm);
@@ -307,19 +301,17 @@
register struct pnt_color_scale_normal *point;
for (BU_LIST_FOR(point, pnt_color_scale_normal, &(((struct pnt_color_scale_normal *)pnts->point)->l))) {
- double v[3];
- double s[1];
+ point_t v;
double c[3];
- fastf_t cf[3];
- double n[3];
+ double s[1];
+ vect_t n;
/* pack v */
VSCALE(v, point->v, local2mm);
buf = pnts_pack_double(buf, (unsigned char *)v, ELEMENTS_PER_POINT);
/* pack c */
- bu_color_to_rgb_floats(&point->c, cf);
- VMOVE(c, cf);
+ bu_color_to_rgb_floats(&point->c, c);
buf = pnts_pack_double(buf, (unsigned char *)c, 3);
/* pack s */
@@ -401,7 +393,7 @@
pnts->point = point;
for (i = 0; i < pnts->count; i++) {
- double v[3];
+ point_t v;
BU_GET(point, struct pnt);
@@ -423,9 +415,8 @@
pnts->point = point;
for (i = 0; i < pnts->count; i++) {
- double v[3];
+ point_t v;
double c[3];
- fastf_t cf[3];
BU_GET(point, struct pnt_color);
@@ -435,8 +426,7 @@
/* unpack c */
buf = pnts_unpack_double(buf, (unsigned char *)c, 3);
- VMOVE(cf, c);
- bu_color_from_rgb_floats(&point->c, cf);
+ bu_color_from_rgb_floats(&point->c, c);
BU_LIST_PUSH(head, &point->l);
}
@@ -452,7 +442,7 @@
pnts->point = point;
for (i = 0; i < pnts->count; i++) {
- double v[3];
+ point_t v;
double s[1];
BU_GET(point, struct pnt_scale);
@@ -479,8 +469,8 @@
pnts->point = point;
for (i = 0; i < pnts->count; i++) {
- double v[3];
- double n[3];
+ point_t v;
+ vect_t n;
BU_GET(point, struct pnt_normal);
@@ -506,9 +496,8 @@
pnts->point = point;
for (i = 0; i < pnts->count; i++) {
- double v[3];
+ point_t v;
double c[3];
- fastf_t cf[3];
double s[1];
BU_GET(point, struct pnt_color_scale);
@@ -519,8 +508,7 @@
/* unpack c */
buf = pnts_unpack_double(buf, (unsigned char *)c, 3);
- VMOVE(cf, c);
- bu_color_from_rgb_floats(&point->c, cf);
+ bu_color_from_rgb_floats(&point->c, c);
/* unpack s */
buf = pnts_unpack_double(buf, (unsigned char *)s, 1);
@@ -540,10 +528,9 @@
pnts->point = point;
for (i = 0; i < pnts->count; i++) {
- double v[3];
+ point_t v;
double c[3];
- fastf_t cf[3];
- double n[3];
+ vect_t n;
BU_GET(point, struct pnt_color_normal);
@@ -553,8 +540,7 @@
/* unpack c */
buf = pnts_unpack_double(buf, (unsigned char *)c, 3);
- VMOVE(cf, c);
- bu_color_from_rgb_floats(&point->c, cf);
+ bu_color_from_rgb_floats(&point->c, c);
/* unpack n */
buf = pnts_unpack_double(buf, (unsigned char *)n, ELEMENTS_PER_VECT);
@@ -574,9 +560,9 @@
pnts->point = point;
for (i = 0; i < pnts->count; i++) {
- double v[3];
+ point_t v;
double s[1];
- double n[3];
+ vect_t n;
BU_GET(point, struct pnt_scale_normal);
@@ -606,11 +592,10 @@
pnts->point = point;
for (i = 0; i < pnts->count; i++) {
- double v[3];
- double s[1];
+ point_t v;
double c[3];
- fastf_t cf[3];
- double n[3];
+ double s[1];
+ vect_t n;
BU_GET(point, struct pnt_color_scale_normal);
@@ -620,8 +605,7 @@
/* unpack c */
buf = pnts_unpack_double(buf, (unsigned char *)c, 3);
- VMOVE(cf, c);
- bu_color_from_rgb_floats(&point->c, cf);
+ bu_color_from_rgb_floats(&point->c, c);
/* unpack s */
buf = pnts_unpack_double(buf, (unsigned char *)s, 1);
Index: src/librt/primitives/rpc/rpc.c
===================================================================
--- src/librt/primitives/rpc/rpc.c (revision 53222)
+++ src/librt/primitives/rpc/rpc.c (working copy)
@@ -104,7 +104,7 @@
* NORMALS. Given the point W on the surface of the rpc, what is the
* vector normal to the tangent plane at that point?
*
- * Map W onto the unit rpc, i.e.: W' = S(R(W - V)).
+ * Map W onto the unit rpc, ie: W' = S(R(W - V)).
*
* Plane on unit rpc at W' has a normal vector N' where
*
@@ -173,7 +173,6 @@
#include "../../librt_private.h"
-static int rpc_is_valid(struct rt_rpc_internal *rpc);
struct rpc_specific {
point_t rpc_V; /* vector to rpc origin */
@@ -271,6 +270,7 @@
fastf_t magsq_b, magsq_h, magsq_r;
fastf_t mag_b, mag_h, mag_r;
+ fastf_t f;
mat_t R;
mat_t Rinv;
mat_t S;
@@ -279,9 +279,7 @@
RT_CK_DB_INTERNAL(ip);
xip = (struct rt_rpc_internal *)ip->idb_ptr;
- if (!rpc_is_valid(xip)) {
- return 1;
- }
+ RT_RPC_CK_MAGIC(xip);
/* compute |B| |H| */
mag_b = sqrt(magsq_b = MAGSQ(xip->rpc_B));
@@ -289,6 +287,21 @@
mag_r = xip->rpc_r;
magsq_r = mag_r * mag_r;
+ /* Check for |H| > 0, |B| > 0, |R| > 0 */
+ if (NEAR_ZERO(mag_h, RT_LEN_TOL) || NEAR_ZERO(mag_b, RT_LEN_TOL)
+ || NEAR_ZERO(mag_r, RT_LEN_TOL)) {
+ return 1; /* BAD, too small */
+ }
+
+ /* Check for B.H == 0 */
+ f = VDOT(xip->rpc_B, xip->rpc_H) / (mag_b * mag_h);
+ if (! NEAR_ZERO(f, RT_DOT_TOL)) {
+ return 1; /* BAD */
+ }
+
+ /*
+ * RPC is ok
+ */
stp->st_id = ID_RPC; /* set soltab ID */
stp->st_meth = &rt_functab[ID_RPC];
@@ -657,225 +670,7 @@
return 0;
}
-/* A canonical parabola in the Y-Z plane has equation z = y^2 / 4p, and opens
- * toward positive z with vertex at the origin.
- *
- * The contour of an rpc in the plane B-R is a parabola with vertex at B,
- * opening toward -B. We can transform this parabola to get an equivalent
- * canonical parabola in the Y-Z plane, opening toward positive Z (-B) with
- * vertex at the origin (B).
- *
- * This parabola passes through the point (r, |B|). If we plug the point (r, |B|)
- * into our canonical equation, we see how p relates to r and |B|:
- *
- * |B| = r^2 / 4p
- * p = (r^2) / (4|B|)
- */
-static fastf_t
-rpc_parabola_p(fastf_t r, fastf_t mag_b)
-{
- return (r * r) / (4 * mag_b);
-}
-/* The contour of an rpc in the plane B-R is a parabola with vertex at B,
- * opening toward -B. We can transform this parabola to get an equivalent
- * parabola in the Y-Z plane, opening toward positive Z (-B) with vertex at
- * (0, -|B|).
- *
- * The part of this parabola that passes between (0, -|B|) and (r, 0) is
- * approximated by num_points points (including (0, -|B|) and (r, 0)).
- *
- * The constructed point list is returned (NULL returned on error). Because the
- * above transformation puts the rpc vertex at the origin and the parabola
- * vertex at (0, -|B|), multiplying the z values by -1 gives corresponding
- * distances along the rpc breadth vector B.
- */
-static struct rt_pt_node *
-rpc_parabolic_curve(fastf_t mag_b, fastf_t r, int num_points)
-{
- int count;
- struct rt_pt_node *curve;
-
- curve = (struct rt_pt_node *)bu_malloc(sizeof(struct rt_pt_node), "rt_pt_node");
- curve->next = (struct rt_pt_node *)bu_malloc(sizeof(struct rt_pt_node), "rt_pt_node");
-
- curve->next->next = NULL;
- VSET(curve->p, 0, 0, -mag_b);
- VSET(curve->next->p, 0, r, 0);
-
- count = approximate_parabolic_curve(curve, rpc_parabola_p(r, mag_b), num_points - 2);
-
- if (count != (num_points - 2)) {
- return NULL;
- }
-
- return curve;
-}
-
-/* plot half of a parabolic contour curve using the given (r, b) points (pts),
- * translation along H (rpc_H), and multiplier for r (rscale)
- */
-static void
-rpc_plot_parabolic_curve(
- struct bu_list *vhead,
- struct rpc_specific *rpc,
- struct rt_pt_node *pts,
- vect_t rpc_H,
- fastf_t rscale)
-{
- vect_t t, Ru, Bu;
- point_t p;
- struct rt_pt_node *node;
-
- VADD2(t, rpc->rpc_V, rpc_H);
- VMOVE(Ru, rpc->rpc_Runit);
- VMOVE(Bu, rpc->rpc_Bunit);
-
- VJOIN2(p, t, rscale * pts->p[Y], Ru, -pts->p[Z], Bu);
- RT_ADD_VLIST(vhead, p, BN_VLIST_LINE_MOVE);
-
- node = pts->next;
- while (node != NULL) {
- VJOIN2(p, t, rscale * node->p[Y], Ru, -node->p[Z], Bu);
- RT_ADD_VLIST(vhead, p, BN_VLIST_LINE_DRAW);
-
- node = node->next;
- }
-}
-
-static void
-rpc_plot_parabolas(
- struct bu_list *vhead,
- struct rt_rpc_internal *rpc,
- struct rt_pt_node *pts)
-{
- vect_t rpc_H;
- struct rpc_specific rpc_s;
-
- VMOVE(rpc_s.rpc_V, rpc->rpc_V);
-
- VMOVE(rpc_s.rpc_Bunit, rpc->rpc_B);
- VUNITIZE(rpc_s.rpc_Bunit);
-
- VCROSS(rpc_s.rpc_Runit, rpc_s.rpc_Bunit, rpc->rpc_H);
- VUNITIZE(rpc_s.rpc_Runit);
-
- /* plot parabolic contour curve of face containing V */
- VSETALL(rpc_H, 0.0);
- rpc_plot_parabolic_curve(vhead, &rpc_s, pts, rpc_H, 1.0);
- rpc_plot_parabolic_curve(vhead, &rpc_s, pts, rpc_H, -1.0);
-
- /* plot parabolic contour curve of opposing face */
- VMOVE(rpc_H, rpc->rpc_H);
- rpc_plot_parabolic_curve(vhead, &rpc_s, pts, rpc_H, 1.0);
- rpc_plot_parabolic_curve(vhead, &rpc_s, pts, rpc_H, -1.0);
-}
-
-static void
-rpc_plot_curve_connections(
- struct bu_list *vhead,
- struct rt_rpc_internal *rpc,
- struct rt_pt_node *pts,
- fastf_t rscale)
-{
- struct rt_pt_node *node;
- vect_t rpc_V, VH, Ru, Bu, R, B, RB;
- point_t p;
-
- VMOVE(rpc_V, rpc->rpc_V);
- VADD2(VH, rpc_V, rpc->rpc_H);
-
- VMOVE(Bu, rpc->rpc_B);
- VUNITIZE(Bu);
-
- VCROSS(Ru, Bu, rpc->rpc_H);
- VUNITIZE(Ru);
-
- VSCALE(R, Ru, rscale * pts->p[Y]);
- VSCALE(B, Bu, -pts->p[Z]);
- VADD2(RB, R, B);
-
- node = pts;
- while (node != NULL) {
- /* calculate face contour point */
- VSCALE(R, Ru, rscale * node->p[Y]);
- VSCALE(B, Bu, -node->p[Z]);
- VADD2(RB, R, B);
-
- /* start at point on face containing V */
- VADD2(p, rpc_V, RB);
- RT_ADD_VLIST(vhead, p, BN_VLIST_LINE_MOVE);
-
- /* draw to corresponding point on opposing face */
- VADD2(p, VH, RB);
- RT_ADD_VLIST(vhead, p, BN_VLIST_LINE_DRAW);
-
- node = node->next;
- }
-}
-
-int
-rt_rpc_adaptive_plot(struct rt_db_internal *ip, const struct rt_view_info *info)
-{
- point_t p;
- vect_t rpc_R;
- int num_curve_points;
- struct rt_rpc_internal *rpc;
- struct rt_pt_node *pts, *node, *tmp;
-
- BU_CK_LIST_HEAD(info->vhead);
- RT_CK_DB_INTERNAL(ip);
-
- rpc = (struct rt_rpc_internal *)ip->idb_ptr;
- if (!rpc_is_valid(rpc)) {
- return -2;
- }
-
- num_curve_points = sqrt(primitive_diagonal_samples(ip, info)) / 4.0;
-
- if (num_curve_points < 3) {
- num_curve_points = 3;
- }
-
- VCROSS(rpc_R, rpc->rpc_B, rpc->rpc_H);
- VUNITIZE(rpc_R);
- VSCALE(rpc_R, rpc_R, rpc->rpc_r);
-
- pts = rpc_parabolic_curve(MAGNITUDE(rpc->rpc_B), rpc->rpc_r, num_curve_points);
-
- rpc_plot_parabolas(info->vhead, rpc, pts);
-
- /* connect both halves of the parabolic contours of the opposing faces */
- rpc_plot_curve_connections(info->vhead, rpc, pts, 1.0);
- rpc_plot_curve_connections(info->vhead, rpc, pts, -1.0);
-
- /* plot rectangular face */
- VADD2(p, rpc->rpc_V, rpc_R);
- RT_ADD_VLIST(info->vhead, p, BN_VLIST_LINE_MOVE);
-
- VADD2(p, p, rpc->rpc_H);
- RT_ADD_VLIST(info->vhead, p, BN_VLIST_LINE_DRAW);
-
- VJOIN1(p, p, -2.0, rpc_R);
- RT_ADD_VLIST(info->vhead, p, BN_VLIST_LINE_DRAW);
-
- VJOIN1(p, p, -1.0, rpc->rpc_H);
- RT_ADD_VLIST(info->vhead, p, BN_VLIST_LINE_DRAW);
-
- VJOIN1(p, p, 2.0, rpc_R);
- RT_ADD_VLIST(info->vhead, p, BN_VLIST_LINE_DRAW);
-
- node = pts;
- while (node != NULL) {
- tmp = node;
- node = node->next;
-
- bu_free(tmp, "rt_pt_node");
- }
-
- return 0;
-}
-
/**
* R T _ R P C _ P L O T
*/
@@ -885,24 +680,37 @@
struct rt_rpc_internal *xip;
fastf_t *front;
fastf_t *back;
- fastf_t b, dtol, h, ntol, rh;
+ fastf_t b, dtol, f, h, ntol, rh;
int i, n;
+ mat_t R;
+ mat_t invR;
struct rt_pt_node *old, *pos, *pts;
- vect_t Bu, Hu, Ru, B, R;
+ vect_t Bu, Hu, Ru;
BU_CK_LIST_HEAD(vhead);
RT_CK_DB_INTERNAL(ip);
-
xip = (struct rt_rpc_internal *)ip->idb_ptr;
- if (!rpc_is_valid(xip)) {
- return -2;
- }
+ RT_RPC_CK_MAGIC(xip);
/* compute |B| |H| */
b = MAGNITUDE(xip->rpc_B); /* breadth */
rh = xip->rpc_r; /* rectangular halfwidth */
h = MAGNITUDE(xip->rpc_H); /* height */
+ /* Check for |H| > 0, |B| > 0, |R| > 0 */
+ if (NEAR_ZERO(h, RT_LEN_TOL) || NEAR_ZERO(b, RT_LEN_TOL)
+ || NEAR_ZERO(rh, RT_LEN_TOL)) {
+ bu_log("rt_rpc_plot(): zero length H, B, or rh\n");
+ return -2; /* BAD */
+ }
+
+ /* Check for B.H == 0 */
+ f = VDOT(xip->rpc_B, xip->rpc_H) / (b * h);
+ if (! NEAR_ZERO(f, RT_DOT_TOL)) {
+ bu_log("rt_rpc_plot(): B not perpendicular to H, f=%f\n", f);
+ return -3; /* BAD */
+ }
+
/* make unit vectors in B, H, and BxH directions */
VMOVE(Hu, xip->rpc_H);
VUNITIZE(Hu);
@@ -910,11 +718,40 @@
VUNITIZE(Bu);
VCROSS(Ru, Bu, Hu);
- if (rh < b) {
- dtol = primitive_get_absolute_tolerance(ttol, 2.0 * rh);
+ /* Compute R and Rinv matrices */
+ MAT_IDN(R);
+ VREVERSE(&R[0], Hu);
+ VMOVE(&R[4], Ru);
+ VREVERSE(&R[8], Bu);
+ bn_mat_trn(invR, R); /* inv of rot mat is trn */
+
+ /*
+ * Establish tolerances
+ */
+ if (ttol->rel <= 0.0 || ttol->rel >= 1.0) {
+ dtol = 0.0; /* none */
} else {
- dtol = primitive_get_absolute_tolerance(ttol, 2.0 * b);
+ /* Convert rel to absolute by scaling by smallest side */
+ if (rh < b)
+ dtol = ttol->rel * 2 * rh;
+ else
+ dtol = ttol->rel * 2 * b;
}
+ if (ttol->abs <= 0.0) {
+ if (dtol <= 0.0) {
+ /* No tolerance given, use a default */
+ if (rh < b)
+ dtol = 2 * 0.10 * rh; /* 10% */
+ else
+ dtol = 2 * 0.10 * b; /* 10% */
+ } else {
+ /* Use absolute-ized relative tolerance */
+ }
+ } else {
+ /* Absolute tolerance was given, pick smaller */
+ if (ttol->rel <= 0.0 || dtol > ttol->abs)
+ dtol = ttol->abs;
+ }
/* To ensure normal tolerance, remain below this angle */
if (ttol->norm > 0.0)
@@ -923,6 +760,7 @@
/* tolerate everything */
ntol = bn_pi;
+#if 1
/* initial parabola approximation is a single segment */
pts = (struct rt_pt_node *)bu_malloc(sizeof(struct rt_pt_node), "rt_pt_node");
pts->next = (struct rt_pt_node *)bu_malloc(sizeof(struct rt_pt_node), "rt_pt_node");
@@ -942,24 +780,56 @@
pos = pts;
i = 0;
while (pos) {
- /* get corresponding rpc contour point in B-R plane from the parabola
- * point in the Y-Z plane
- */
- VSCALE(R, Ru, pos->p[Y]);
- VSCALE(B, Bu, -pos->p[Z]);
- VADD2(&front[i], R, B);
-
+ /* rotate back to original position */
+ MAT4X3VEC(&front[i], invR, pos->p);
/* move to origin vertex origin */
VADD2(&front[i], &front[i], xip->rpc_V);
-
/* extrude front to create back plate */
VADD2(&back[i], &front[i], xip->rpc_H);
+ i += 3;
+ old = pos;
+ pos = pos->next;
+ bu_free((char *)old, "rt_pt_node");
+ }
+#else
+ /* initial parabola approximation is a single segment */
+ pts = (struct rt_pt_node *)bu_malloc(sizeof(struct rt_pt_node), "rt_pt_node");
+ pts->next = (struct rt_pt_node *)bu_malloc(sizeof(struct rt_pt_node), "rt_pt_node");
+ pts->next->next = NULL;
+ VSET(pts->p, 0, 0, -b);
+ VSET(pts->next->p, 0, rh, 0);
+ /* 2 endpoints in 1st approximation */
+ n = 2;
+ /* recursively break segment 'til within error tolerances */
+ n += rt_mk_parabola(pts, rh, b, dtol, ntol);
+ /* get mem for arrays */
+ front = (fastf_t *)bu_malloc((2*3*n-1) * sizeof(fastf_t), "fastf_t");
+ back = (fastf_t *)bu_malloc((2*3*n-1) * sizeof(fastf_t), "fastf_t");
+
+ /* generate front & back plates in world coordinates */
+ pos = pts;
+ i = 0;
+ while (pos) {
+ /* rotate back to original position */
+ MAT4X3VEC(&front[i], invR, pos->p);
+ /* move to origin vertex origin */
+ VADD2(&front[i], &front[i], xip->rpc_V);
+ /* extrude front to create back plate */
+ VADD2(&back[i], &front[i], xip->rpc_H);
i += 3;
old = pos;
pos = pos->next;
bu_free((char *)old, "rt_pt_node");
}
+ for (i = 3*n; i < 6*n-3; i+=3) {
+ VMOVE(&front[i], &front[6*n-i-6]);
+ front[i+1] = -front[i+1];
+ VMOVE(&back[i], &back[6*n-i-6]);
+ back[i+1] = -back[i+1];
+ }
+ n = 2*n - 1;
+#endif
/* Draw the front */
RT_ADD_VLIST(vhead, &front[(n-1)*ELEMENTS_PER_VECT],
@@ -992,7 +862,7 @@
*
* Approximate a parabola with line segments. The initial single
* segment is broken at the point farthest from the parabola if
- * that point is not already within the distance and normal error
+ * that point is not aleady within the distance and normal error
* tolerances. The two resulting segments are passed recursively
* to this routine until each segment is within tolerance.
*/
@@ -1061,7 +931,7 @@
rt_rpc_tess(struct nmgregion **r, struct model *m, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol)
{
int i, j, n;
- fastf_t b, *back, *front, h, rh;
+ fastf_t b, *back, f, *front, h, rh;
fastf_t dtol, ntol;
vect_t Bu, Hu, Ru;
mat_t R;
@@ -1079,17 +949,28 @@
RT_CK_TESS_TOL(ttol);
RT_CK_DB_INTERNAL(ip);
-
xip = (struct rt_rpc_internal *)ip->idb_ptr;
- if (!rpc_is_valid(xip)) {
- return -2;
- }
+ RT_RPC_CK_MAGIC(xip);
/* compute |B| |H| */
b = MAGNITUDE(xip->rpc_B); /* breadth */
rh = xip->rpc_r; /* rectangular halfwidth */
h = MAGNITUDE(xip->rpc_H); /* height */
+ /* Check for |H| > 0, |B| > 0, |R| > 0 */
+ if (NEAR_ZERO(h, RT_LEN_TOL) || NEAR_ZERO(b, RT_LEN_TOL)
+ || NEAR_ZERO(rh, RT_LEN_TOL)) {
+ bu_log("rt_rpc_tess(): zero length H, B, or rh\n");
+ return -2; /* BAD */
+ }
+
+ /* Check for B.H == 0 */
+ f = VDOT(xip->rpc_B, xip->rpc_H) / (b * h);
+ if (! NEAR_ZERO(f, RT_DOT_TOL)) {
+ bu_log("rt_rpc_tess(): B not perpendicular to H, f=%f\n", f);
+ return -3; /* BAD */
+ }
+
/* make unit vectors in B, H, and BxH directions */
VMOVE(Hu, xip->rpc_H);
VUNITIZE(Hu);
@@ -1104,11 +985,33 @@
VREVERSE(&R[8], Bu);
bn_mat_trn(invR, R); /* inv of rot mat is trn */
- if (rh < b) {
- dtol = primitive_get_absolute_tolerance(ttol, 2.0 * rh);
+ /*
+ * Establish tolerances
+ */
+ if (ttol->rel <= 0.0 || ttol->rel >= 1.0) {
+ dtol = 0.0; /* none */
} else {
- dtol = primitive_get_absolute_tolerance(ttol, 2.0 * b);
+ /* Convert rel to absolute by scaling by smallest side */
+ if (rh < b)
+ dtol = ttol->rel * 2 * rh;
+ else
+ dtol = ttol->rel * 2 * b;
}
+ if (ttol->abs <= 0.0) {
+ if (dtol <= 0.0) {
+ /* No tolerance given, use a default */
+ if (rh < b)
+ dtol = 2 * 0.10 * rh; /* 10% */
+ else
+ dtol = 2 * 0.10 * b; /* 10% */
+ } else {
+ /* Use absolute-ized relative tolerance */
+ }
+ } else {
+ /* Absolute tolerance was given, pick smaller */
+ if (ttol->rel <= 0.0 || dtol > ttol->abs)
+ dtol = ttol->abs;
+ }
/* To ensure normal tolerance, remain below this angle */
if (ttol->norm > 0.0)
@@ -1649,37 +1552,7 @@
*area = 2.0 * area_base + area_rect + area_shell;
}
-static int
-rpc_is_valid(struct rt_rpc_internal *rpc)
-{
- fastf_t mag_h, mag_b, cos_angle_bh;
- vect_t rpc_H, rpc_B;
- RT_RPC_CK_MAGIC(rpc);
-
- VMOVE(rpc_H, rpc->rpc_H);
- mag_h = MAGNITUDE(rpc_H);
-
- VMOVE(rpc_B, rpc->rpc_B);
- mag_b = MAGNITUDE(rpc_B);
-
- /* Check for |H| > 0, |B| > 0, |R| > 0 */
- if (NEAR_ZERO(mag_h, RT_LEN_TOL)
- || NEAR_ZERO(mag_b, RT_LEN_TOL)
- || NEAR_ZERO(rpc->rpc_r, RT_LEN_TOL))
- {
- return 0;
- }
-
- /* check B and H are orthogonal */
- cos_angle_bh = VDOT(rpc_B, rpc_H) / (mag_b * mag_h);
- if (!NEAR_ZERO(cos_angle_bh, RT_DOT_TOL)) {
- return 0;
- }
-
- return 1;
-}
-
/*
* Local Variables:
* mode: C
Index: src/librt/primitives/rpc/rpc_brep.cpp
===================================================================
--- src/librt/primitives/rpc/rpc_brep.cpp (revision 53222)
+++ src/librt/primitives/rpc/rpc_brep.cpp (working copy)
@@ -84,7 +84,7 @@
parabnurbscurve->SetCV(1, ON_3dPoint(ep2));
parabnurbscurve->SetCV(2, ON_3dPoint(ep3));
- // Also need a straight line from the beginning to the end to
+ // Also need a staight line from the beginning to the end to
// complete the loop.
ON_LineCurve* straightedge = new ON_LineCurve(onp3, onp1);
Index: src/librt/primitives/ars/ars.c
===================================================================
--- src/librt/primitives/ars/ars.c (revision 53222)
+++ src/librt/primitives/ars/ars.c (working copy)
@@ -1160,7 +1160,7 @@
}
bu_vls_printf(logstr, " }");
}
- } else if (!isdigit((int)attr[1])) {
+ } else if (!isdigit(attr[1])) {
bu_vls_printf(logstr,
"ERROR: illegal argument, must be NC, PPC, C, C#, or C#P#\n");
return BRLCAD_ERROR;
@@ -1169,7 +1169,7 @@
ptr = strchr(attr, 'P');
if (ptr) {
/* a specific point on a specific curve */
- if (!isdigit((int)*(ptr+1))) {
+ if (!isdigit(*(ptr+1))) {
bu_vls_printf(logstr,
"ERROR: illegal argument, must be NC, PPC, C, C#, or C#P#\n");
return BRLCAD_ERROR;
@@ -1274,7 +1274,7 @@
ars->pts_per_curve = i;
}
} else if (argv[0][0] == 'C') {
- if (isdigit((int)argv[0][1])) {
+ if (isdigit(argv[0][1])) {
char *ptr;
/* a specific curve */
Index: src/librt/primitives/ehy/ehy.c
===================================================================
--- src/librt/primitives/ehy/ehy.c (revision 53222)
+++ src/librt/primitives/ehy/ehy.c (working copy)
@@ -106,7 +106,7 @@
* NORMALS. Given the point W on the surface of the ehy, what is the
* vector normal to the tangent plane at that point?
*
- * Map W onto the unit ehy, i.e.: W' = S(R(W - V)).
+ * Map W onto the unit ehy, ie: W' = S(R(W - V)).
*
* Plane on unit ehy at W' has a normal vector N' where
*
@@ -185,9 +185,6 @@
{ {'\0', '\0', '\0', '\0'}, 0, (char *)NULL, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL }
};
-
-static int ehy_is_valid(struct rt_ehy_internal *ehy);
-
/**
* R T _ E H Y _ B B O X
*
@@ -264,12 +261,8 @@
struct ehy_specific *ehy;
fastf_t magsq_h;
-#if 0
- /* unused compile error */
- fastf_t mag_a;
-#endif
- fastf_t mag_h;
- fastf_t c, r1, r2;
+ fastf_t mag_a, mag_h;
+ fastf_t c, f, r1, r2;
mat_t R;
mat_t Rinv;
mat_t S;
@@ -277,21 +270,27 @@
RT_CK_DB_INTERNAL(ip);
xip = (struct rt_ehy_internal *)ip->idb_ptr;
+ RT_EHY_CK_MAGIC(xip);
- if (!ehy_is_valid(xip)) {
- return -2;
- }
-
-#if 0
- /* unused compile error */
- mag_a = MAGSQ(xip->ehy_Au); /* a is unit vector, so |A|^2 == |A| */
-#endif
- magsq_h = MAGSQ(xip->ehy_H);
- mag_h = sqrt(magsq_h);
+ /* compute |A| |H| */
+ mag_a = sqrt(MAGSQ(xip->ehy_Au));
+ mag_h = sqrt(magsq_h = MAGSQ(xip->ehy_H));
r1 = xip->ehy_r1;
r2 = xip->ehy_r2;
c = xip->ehy_c;
+ /* Check for |H| > 0, |A| == 1, r1 > 0, r2 > 0, c > 0 */
+ if (NEAR_ZERO(mag_h, RT_LEN_TOL)
+ || !NEAR_EQUAL(mag_a, 1.0, RT_LEN_TOL)
+ || r1 < 0.0 || r2 < 0.0 || c < 0.0) {
+ return -2; /* BAD, too small */
+ }
+ /* Check for A.H == 0 */
+ f = VDOT(xip->ehy_Au, xip->ehy_H) / mag_h;
+ if (!NEAR_ZERO(f, RT_DOT_TOL)) {
+ return -2; /* BAD */
+ }
+
/*
* EHY is ok
*/
@@ -672,246 +671,14 @@
return 0;
}
-/* Our canonical hyperbola in the Y-Z plane has equation
- * z = +- (a/b) * sqrt(b^2 + y^2), and opens toward +Z and -Z with asymptote
- * origin at the origin.
- *
- * The contour of an ehy in the plane H-R (where R is one of the ehy axes A or
- * B) is the positive half of a hyperbola with asymptote origin at
- * ((|H| + c)Hu), opening toward -H. We can transform this hyperbola to get an
- * equivalent canonical hyperbola in the Y-Z plane, opening toward +Z (-H) with
- * asymptote origin at the origin.
- *
- * This hyperbola passes through the point (r, |H| + a) (where r = |A| or |B|,
- * and a = c). If we plug the point (r, |H| + a) into our canonical equation,
- * we can derive b from |H|, a, and r.
- *
- * |H| + a = (a/b) * sqrt(b^2 + r^2)
- * (|H| + a) / a = b * sqrt(b^2 + r^2)
- * (|H| + a)^2 / a^2 = 1 + (r^2 / b^2)
- * ((|H| + a)^2 - a^2) / a^2 = r^2 / b^2
- * (a^2 * r^2) / ((|H| + a)^2 - a^2) = b^2
- * (ar) / sqrt((|H| + a)^2 - a^2) = b
- * (ar) / sqrt(|H| (|H| + 2a)) = b
- */
-static fastf_t
-ehy_hyperbola_b(fastf_t mag_h, fastf_t c, fastf_t r)
-{
- return (c * r) / sqrt(mag_h * (mag_h + 2.0 * c));
-}
-/* The contour of an ehy in the plane H-R (where R is one of the ehy axes A or
- * B) is the positive half of a hyperbola with asymptote origin at
- * ((|H| + c)Hu), opening toward -H. We can transform this hyperbola to get an
- * equivalent hyperbola in the Y-Z plane, opening toward +Z (-H) with asymptote
- * origin at (0, -(|H| + c)).
- *
- * The part of this hyperbola that passes between (0, -(|H| + c)) and (r, 0)
- * (r = |A| or |B|) is approximated by num_points points (including (0, -|H|)
- * and (r, 0)).
- *
- * The constructed point list is returned (NULL returned on error). Because the
- * above transformation puts the ehy vertex at the origin and the hyperbola
- * asymptote origin at (0, -|H| + c), multiplying the z values by -1 gives
- * corresponding distances along the ehy height vector H.
- */
-static struct rt_pt_node *
-ehy_hyperbolic_curve(fastf_t mag_h, fastf_t c, fastf_t r, int num_points)
-{
- int count;
- struct rt_pt_node *curve;
-
- curve = (struct rt_pt_node *)bu_malloc(sizeof(struct rt_pt_node), "rt_pt_node");
- curve->next = (struct rt_pt_node *)bu_malloc(sizeof(struct rt_pt_node), "rt_pt_node");
-
- curve->next->next = NULL;
- VSET(curve->p, 0, 0, -mag_h);
- VSET(curve->next->p, 0, r, 0);
-
- count = approximate_hyperbolic_curve(curve, c, ehy_hyperbola_b(mag_h, c, r), num_points - 2);
-
- if (count != (num_points - 2)) {
- return NULL;
- }
-
- return curve;
-}
-
-/* The contour of an ehy in the plane H-R (where R is one of the ehy axes A or
- * B) is the positive half of a hyperbola with asymptote origin at
- * ((|H| + c)Hu), opening toward -H. We can transform this hyperbola to get an
- * equivalent hyperbola in the Y-Z plane, with asymptote origin at
- * (0, |H| + a) (a = c) opening toward +Z.
- *
- * The equation for this hyperbola is a variant of the equation for our
- * canonical hyperbola in the Y-Z plane (z = (a/b) * sqrt(y^2 + b^2)):
- * z = (|H| + a) - (a/b) * sqrt(y^2 + b^2)
- *
- * Solving this equation for y yields:
- * y = (b/a) * sqrt((|H| + a - z)^2 - a^2)
- *
- * Substituting b = (ar) / sqrt(|H| (|H| + 2a)) (see above comment):
- *
- * y = (r / sqrt(|H| (|H| + 2a))) * sqrt((|H| + a - z)^2 - a^2)
- * = r * sqrt( ((|H| + a - z)^2 - a^2) / (|H| (|H| + 2a))) )
- */
-static fastf_t
-ehy_hyperbola_y(fastf_t mag_H, fastf_t c, fastf_t r, fastf_t z)
-{
- fastf_t n, d;
-
- n = pow(mag_H + c - z, 2) - c * c;
- d = mag_H * (mag_H + 2.0 * c);
-
- return r * sqrt(n / d);
-}
-
-/* Plot the elliptical cross section of the given ehy at distance h along the
- * ehy height vector (h >= 0, h <= |H|) consisting of num_points points.
- */
-static void
-ehy_plot_ellipse(
- struct bu_list *vhead,
- struct rt_ehy_internal *ehy,
- fastf_t h,
- fastf_t num_points)
-{
- fastf_t mag_H;
- vect_t V, Hu, Au, Bu, A, B, cross_section_plane;
-
- VMOVE(V, ehy->ehy_V);
-
- mag_H = MAGNITUDE(ehy->ehy_H);
- VSCALE(Hu, ehy->ehy_H, 1.0 / mag_H);
-
- VMOVE(Au, ehy->ehy_Au);
- VCROSS(Bu, Au, Hu);
-
- /* calculate semi-major and semi-minor axis for the elliptical
- * cross-section at distance h along H
- */
- VSCALE(A, Au, ehy_hyperbola_y(mag_H, ehy->ehy_c, ehy->ehy_r1, h));
- VSCALE(B, Bu, ehy_hyperbola_y(mag_H, ehy->ehy_c, ehy->ehy_r2, h));
- VJOIN1(cross_section_plane, V, h, Hu);
-
- plot_ellipse(vhead, cross_section_plane, A, B, num_points);
-}
-
-static void
-ehy_plot_hyperbola(
- struct bu_list *vhead,
- struct rt_ehy_internal *ehy,
- struct rt_pt_node *pts,
- vect_t Ru,
- fastf_t r)
-{
- point_t p;
- vect_t ehy_V, Hu;
- fastf_t mag_H, c, z;
- struct rt_pt_node *node;
-
- VMOVE(ehy_V, ehy->ehy_V);
- mag_H = MAGNITUDE(ehy->ehy_H);
- VSCALE(Hu, ehy->ehy_H, 1.0 / mag_H);
- c = ehy->ehy_c;
-
- z = pts->p[Z];
- VJOIN2(p, ehy_V, ehy_hyperbola_y(mag_H, c, r, -z), Ru, -z, Hu);
- RT_ADD_VLIST(vhead, p, BN_VLIST_LINE_MOVE);
-
- node = pts->next;
- while (node != NULL) {
- z = node->p[Z];
- VJOIN2(p, ehy_V, ehy_hyperbola_y(mag_H, c, r, -z), Ru, -z, Hu);
-
- RT_ADD_VLIST(vhead, p, BN_VLIST_LINE_DRAW);
-
- node = node->next;
- }
-}
-
-int
-rt_ehy_adaptive_plot(struct rt_db_internal *ip, const struct rt_view_info *info)
-{
- vect_t ehy_H, Hu, Au, Bu;
- fastf_t mag_H, z, c, r1, r2;
- int i, num_curve_points, num_ellipse_points;
- struct rt_ehy_internal *ehy;
- struct rt_pt_node *pts_r1, *pts_r2, *node, *node1, *node2;
-
- num_curve_points = sqrt(primitive_diagonal_samples(ip, info)) / 4.0;
-
- if (num_curve_points < 3) {
- num_curve_points = 3;
- }
-
- num_ellipse_points = 4 * num_curve_points;
-
- BU_CK_LIST_HEAD(info->vhead);
- RT_CK_DB_INTERNAL(ip);
- ehy = (struct rt_ehy_internal *)ip->idb_ptr;
- RT_EHY_CK_MAGIC(ehy);
-
- VMOVE(ehy_H, ehy->ehy_H);
-
- mag_H = MAGNITUDE(ehy_H);
- VSCALE(Hu, ehy->ehy_H, 1.0 / mag_H);
-
- VMOVE(Au, ehy->ehy_Au);
- VCROSS(Bu, Au, Hu);
-
- r1 = ehy->ehy_r1;
- r2 = ehy->ehy_r2;
- c = ehy->ehy_c;
-
- pts_r1 = ehy_hyperbolic_curve(mag_H, c, r1, num_curve_points);
- pts_r2 = ehy_hyperbolic_curve(mag_H, c, r2, num_curve_points);
-
- if (pts_r1 == NULL || pts_r2 == NULL) {
- return -1;
- }
-
- node1 = pts_r1;
- node2 = pts_r2;
- for (i = 0; i < num_curve_points; ++i) {
- /* Select cross-section to draw by averaging the z values and flip over y-axis
- * to get a distance along H.
- */
- z = (node1->p[Z] + node2->p[Z]) / 2.0;
- ehy_plot_ellipse(info->vhead, ehy, -z, num_ellipse_points);
-
- node1 = node1->next;
- node2 = node2->next;
- }
-
- ehy_plot_hyperbola(info->vhead, ehy, pts_r1, Au, r1);
- ehy_plot_hyperbola(info->vhead, ehy, pts_r1, Au, -r1);
- ehy_plot_hyperbola(info->vhead, ehy, pts_r1, Bu, r2);
- ehy_plot_hyperbola(info->vhead, ehy, pts_r1, Bu, -r2);
-
- node1 = pts_r1;
- node2 = pts_r2;
- for (i = 0; i < num_curve_points; ++i) {
- node = node1;
- bu_free(node, "rt_pt_node");
-
- node = node2;
- bu_free(node, "rt_pt_node");
-
- node1 = node1->next;
- node2 = node2->next;
- }
-
- return 0;
-}
-
/**
* R T _ E H Y _ P L O T
*/
int
rt_ehy_plot(struct bu_list *vhead, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *UNUSED(tol), const struct rt_view_info *UNUSED(info))
{
- fastf_t c, dtol, mag_h, ntol, r1, r2;
+ fastf_t c, dtol, f, mag_a, mag_h, ntol, r1, r2;
fastf_t **ellipses, theta_prev, theta_new;
int *pts_dbl, i, j, nseg;
int jj, na, nb, nell, recalc_b;
@@ -925,16 +692,31 @@
BU_CK_LIST_HEAD(vhead);
RT_CK_DB_INTERNAL(ip);
xip = (struct rt_ehy_internal *)ip->idb_ptr;
+ RT_EHY_CK_MAGIC(xip);
- if (!ehy_is_valid(xip)) {
- return -2;
- }
+ /*
+ * make sure ehy description is valid
+ */
+ /* compute |A| |H| */
+ mag_a = MAGSQ(xip->ehy_Au); /* should already be unit vector */
mag_h = MAGNITUDE(xip->ehy_H);
+ c = xip->ehy_c;
r1 = xip->ehy_r1;
r2 = xip->ehy_r2;
- c = xip->ehy_c;
+ /* Check for |H| > 0, |A| == 1, r1 > 0, r2 > 0, c > 0 */
+ if (NEAR_ZERO(mag_h, RT_LEN_TOL)
+ || !NEAR_EQUAL(mag_a, 1.0, RT_LEN_TOL)
+ || r1 <= 0.0 || r2 <= 0.0 || c <= 0.) {
+ return -2; /* BAD */
+ }
+ /* Check for A.H == 0 */
+ f = VDOT(xip->ehy_Au, xip->ehy_H) / mag_h;
+ if (! NEAR_ZERO(f, RT_DOT_TOL)) {
+ return -2; /* BAD */
+ }
+
/* make unit vectors in A, H, and BxH directions */
VMOVE(Hu, xip->ehy_H);
VUNITIZE(Hu);
@@ -948,13 +730,32 @@
VREVERSE(&R[8], Hu);
bn_mat_trn(invR, R); /* inv of rot mat is trn */
- dtol = primitive_get_absolute_tolerance(ttol, 2.0 * xip->ehy_r2);
+ /*
+ * Establish tolerances
+ */
+ if (ttol->rel <= 0.0 || ttol->rel >= 1.0)
+ dtol = 0.0; /* none */
+ else
+ /* Convert rel to absolute by scaling by smallest side */
+ dtol = ttol->rel * 2 * r2;
+ if (ttol->abs <= 0.0) {
+ if (dtol <= 0.0) {
+ /* No tolerance given, use a default */
+ dtol = 2 * 0.10 * r2; /* 10% */
+ }
+ /* Use absolute-ized relative tolerance */
+ } else {
+ /* Absolute tolerance was given, pick smaller */
+ if (ttol->rel <= 0.0 || dtol > ttol->abs)
+ dtol = ttol->abs;
+ }
- /* stay below ntol to ensure normal tolerance */
- ntol = M_PI;
- if (ttol->norm > 0.0) {
+ /* To ensure normal tolerance, remain below this angle */
+ if (ttol->norm > 0.0)
ntol = ttol->norm;
- }
+ else
+ /* tolerate everything */
+ ntol = bn_pi;
/*
* build ehy from 2 hyperbolas
@@ -1158,11 +959,7 @@
int
rt_ehy_tess(struct nmgregion **r, struct model *m, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol)
{
-#if 0
- /* unused compile error */
- fastf_t mag_a;
-#endif
- fastf_t c, dtol, mag_h, ntol, r1, r2, cprime;
+ fastf_t c, dtol, f, mag_a, mag_h, ntol, r1, r2, cprime;
fastf_t **ellipses, theta_prev, theta_new;
int *pts_dbl, face, i, j, nseg;
int jj, na, nb, nell, recalc_b;
@@ -1186,21 +983,32 @@
RT_CK_DB_INTERNAL(ip);
xip = (struct rt_ehy_internal *)ip->idb_ptr;
+ RT_EHY_CK_MAGIC(xip);
- if (!ehy_is_valid(xip)) {
- return 1;
- }
+ /*
+ * make sure ehy description is valid
+ */
-#if 0
- /* unused compile error */
- mag_a = MAGSQ(xip->ehy_Au); /* a is unit vector, so |A|^2 == |A| */
-#endif
+ /* compute |A| |H| */
+ mag_a = MAGSQ(xip->ehy_Au); /* should already be unit vector */
mag_h = MAGNITUDE(xip->ehy_H);
c = xip->ehy_c;
cprime = c / mag_h;
r1 = xip->ehy_r1;
r2 = xip->ehy_r2;
+ /* Check for |H| > 0, |A| == 1, r1 > 0, r2 > 0, c > 0 */
+ if (NEAR_ZERO(mag_h, RT_LEN_TOL)
+ || !NEAR_EQUAL(mag_a, 1.0, RT_LEN_TOL)
+ || r1 <= 0.0 || r2 <= 0.0 || c <= 0.) {
+ return 1; /* BAD */
+ }
+ /* Check for A.H == 0 */
+ f = VDOT(xip->ehy_Au, xip->ehy_H) / mag_h;
+ if (! NEAR_ZERO(f, RT_DOT_TOL)) {
+ return 1; /* BAD */
+ }
+
/* make unit vectors in A, H, and BxH directions */
VMOVE(Hu, xip->ehy_H);
VUNITIZE(Hu);
@@ -1224,13 +1032,32 @@
bn_mat_mul(SoR, S, R);
bn_mat_mul(invRoS, invR, S);
- dtol = primitive_get_absolute_tolerance(ttol, 2.0 * xip->ehy_r2);
+ /*
+ * Establish tolerances
+ */
+ if (ttol->rel <= 0.0 || ttol->rel >= 1.0)
+ dtol = 0.0; /* none */
+ else
+ /* Convert rel to absolute by scaling by smallest side */
+ dtol = ttol->rel * 2 * r2;
+ if (ttol->abs <= 0.0) {
+ if (dtol <= 0.0) {
+ /* No tolerance given, use a default */
+ dtol = 2 * 0.10 * r2; /* 10% */
+ }
+ /* Use absolute-ized relative tolerance */
+ } else {
+ /* Absolute tolerance was given, pick smaller */
+ if (ttol->rel <= 0.0 || dtol > ttol->abs)
+ dtol = ttol->abs;
+ }
- /* stay below ntol to ensure normal tolerance */
- ntol = M_PI;
- if (ttol->norm > 0.0) {
+ /* To ensure normal tolerance, remain below this angle */
+ if (ttol->norm > 0.0)
ntol = ttol->norm;
- }
+ else
+ /* tolerate everything */
+ ntol = bn_pi;
/*
* build ehy from 2 hyperbolas
@@ -1932,43 +1759,7 @@
return 0; /* OK */
}
-static int
-ehy_is_valid(struct rt_ehy_internal *ehy)
-{
- fastf_t mag_h, cos_angle_ah;
- vect_t a, h;
- RT_EHY_CK_MAGIC(ehy);
-
- if (!(ehy->ehy_r1 > 0.0 && ehy->ehy_r2 > 0.0 && ehy->ehy_c > 0.0)) {
- return 0;
- }
-
- VMOVE(h, ehy->ehy_H);
- VMOVE(a, ehy->ehy_Au);
-
- /* Check that A is a unit vector. If it is, then it should be true that
- * |A| == |A|^2 == 1.0.
- */
- if (!NEAR_EQUAL(MAGSQ(a), 1.0, RT_LEN_TOL)) {
- return 0;
- }
-
- /* check that |H| > 0.0 */
- mag_h = MAGNITUDE(h);
- if (NEAR_ZERO(mag_h, RT_LEN_TOL)) {
- return 0;
- }
-
- /* check that A and H are orthogonal */
- cos_angle_ah = VDOT(a, h) / mag_h;
- if (!NEAR_ZERO(cos_angle_ah, RT_DOT_TOL)) {
- return 0;
- }
-
- return 1;
-}
-
/** @} */
/*
* Local Variables:
Index: src/librt/primitives/ehy/ehy_brep.cpp
===================================================================
--- src/librt/primitives/ehy/ehy_brep.cpp (revision 53222)
+++ src/librt/primitives/ehy/ehy_brep.cpp (working copy)
@@ -112,7 +112,7 @@
(*b)->SetTrimIsoFlags(bface);
delete ellcurve1;
- // Now, the hard part. Need an elliptical hyperbolic NURBS surface
+ // Now, the hard part. Need an elliptical hyperboloic NURBS surface
// First step is to create a nurbs curve.
double intercept_calc = (eip->ehy_c)*(eip->ehy_c)/(MAGNITUDE(eip->ehy_H) + eip->ehy_c);
Index: src/librt/primitives/eto/eto.c
===================================================================
--- src/librt/primitives/eto/eto.c (revision 53222)
+++ src/librt/primitives/eto/eto.c (working copy)
@@ -41,7 +41,6 @@
#include "../../librt_private.h"
-static int eto_is_valid(struct rt_eto_internal *eto);
/*
* The ETO has the following input fields:
@@ -62,7 +61,7 @@
*
* Through a series of Transformations, this set will be transformed
* into a set of points on an eto centered at the origin which lies on
- * the X-Y plane (i.e., N is on the Z axis).
+ * the X-Y plane (ie, N is on the Z axis).
*
* { (x', y', z') | (x', y', z') is an eto at origin }
*
@@ -109,13 +108,13 @@
* Wx**2 = Dx**2 * t**2 + 2 * Dx * Px + Px**2
*
* The real roots of the equation in 't' are the intersect points
- * along the parametric line.
+ * along the parameteric line.
*
* NORMALS. Given the point W on the eto, what is the vector normal
* to the tangent plane at that point?
*
- * Map W onto the eto, i.e.: W' = R(W - V). In this case, we find W'
- * by solving the parametric line given k.
+ * Map W onto the eto, ie: W' = R(W - V). In this case, we find W'
+ * by solving the parameteric line given k.
*
* The gradient of the eto at W' is in fact the
* normal vector.
@@ -232,9 +231,7 @@
if (rtip) RT_CK_RTI(rtip);
tip = (struct rt_eto_internal *)ip->idb_ptr;
- if (!eto_is_valid(tip)) {
- return 1;
- }
+ RT_ETO_CK_MAGIC(tip);
/* Solid is OK, compute constant terms now */
BU_GET(eto, struct eto_specific);
@@ -243,6 +240,11 @@
eto->eto_r = tip->eto_r;
eto->eto_rd = tip->eto_rd;
eto->eto_rc = MAGNITUDE(tip->eto_C);
+ if (NEAR_ZERO(eto->eto_r, 0.0001) || NEAR_ZERO(eto->eto_rd, 0.0001)
+ || NEAR_ZERO(eto->eto_rc, 0.0001)) {
+ bu_log("eto(%s): r, rd, or rc zero length\n", stp->st_name);
+ return 1;
+ }
VMOVE(eto->eto_V, tip->eto_V);
VMOVE(eto->eto_N, tip->eto_N);
@@ -748,7 +750,7 @@
*
* Approximate one fourth (1st quadrant) of an ellipse with line
* segments. The initial single segment is broken at the point
- * farthest from the ellipse if that point is not already within the
+ * farthest from the ellipse if that point is not aleady within the
* distance and normal error tolerances. The two resulting segments
* are passed recursively to this routine until each segment is within
* tolerance.
@@ -879,17 +881,18 @@
fastf_t radian, radian_step;
vect_t ellipse_A, ellipse_B, contour_A, contour_B, I, J;
vect_t center, cross_AN, eto_V, eto_N, eto_A, eto_B;
- fastf_t mag_A, mag_B, mag_N, mag_ai, mag_aj, mag_bi, mag_bj;
+ fastf_t mag_N, mag_ai, mag_aj, mag_bi, mag_bj;
+ /* fastf_t mag_B, mag_A; */
int i, samples, num_cross_sections, points_per_cross_section;
BU_CK_LIST_HEAD(info->vhead);
RT_CK_DB_INTERNAL(ip);
eto = (struct rt_eto_internal *)ip->idb_ptr;
- if (!eto_is_valid(eto)) {
+ /* if (!eto_is_valid(eto)) {
return 1;
}
-
+*/
samples = sqrt(primitive_diagonal_samples(ip, info));
if (samples < 8) {
@@ -916,12 +919,12 @@
VCROSS(eto_A, eto_N, cross_AN);
VUNITIZE(eto_A);
VSCALE(eto_A, eto_A, eto->eto_r);
- mag_A = MAGNITUDE(eto_A);
+ /*mag_A = MAGNITUDE(eto_A);*/
VCROSS(eto_B, eto_N, eto_A);
VUNITIZE(eto_B);
VSCALE(eto_B, eto_B, eto->eto_r);
- mag_B = MAGNITUDE(eto_B);
+ /*mag_B = MAGNITUDE(eto_B);*/
/* We want to be able to plot any of the ellipses that result from
* intersecting the eto with a plane containing N. The center point of any
@@ -1015,21 +1018,46 @@
BU_CK_LIST_HEAD(vhead);
RT_CK_DB_INTERNAL(ip);
-
tip = (struct rt_eto_internal *)ip->idb_ptr;
- if (!eto_is_valid(tip)) {
- return 1;
- }
+ RT_ETO_CK_MAGIC(tip);
a = MAGNITUDE(tip->eto_C);
b = tip->eto_rd;
- if (tip->eto_r < b) {
- dtol = primitive_get_absolute_tolerance(ttol, 2.0 * tip->eto_r);
+ if (NEAR_ZERO(tip->eto_r, 0.0001) || NEAR_ZERO(b, 0.0001)
+ || NEAR_ZERO(a, 0.0001)) {
+ bu_log("eto_plot: r, rd, or rc zero length\n");
+ return 1;
+ }
+
+ /* Establish tolerances */
+ if (ttol->rel <= 0.0 || ttol->rel >= 1.0) {
+ dtol = 0.0; /* none */
} else {
- dtol = primitive_get_absolute_tolerance(ttol, 2.0 * b);
+ /*
+ * Convert relative to absolute by scaling smallest of radius
+ * and semi-minor axis
+ */
+ if (tip->eto_r < b)
+ dtol = ttol->rel * 2 * tip->eto_r;
+ else
+ dtol = ttol->rel * 2 * b;
}
-
+ if (ttol->abs <= 0.0) {
+ if (dtol <= 0.0) {
+ /* No tolerance given, use a default */
+ if (tip->eto_r < b)
+ dtol = 2 * 0.10 * tip->eto_r; /* 10% */
+ else
+ dtol = 2 * 0.10 * b; /* 10% */
+ } else {
+ /* Use absolute-ized relative tolerance */
+ }
+ } else {
+ /* Absolute tolerance was given, pick smaller */
+ if (ttol->rel <= 0.0 || dtol > ttol->abs)
+ dtol = ttol->abs;
+ }
/* To ensure normal tolerance, remain below this angle */
if (ttol->norm > 0.0)
ntol = ttol->norm;
@@ -1145,12 +1173,34 @@
goto failure;
}
- if (tip->eto_r < b) {
- dtol = primitive_get_absolute_tolerance(ttol, 2.0 * tip->eto_r);
+ /* Establish tolerances */
+ if (ttol->rel <= 0.0 || ttol->rel >= 1.0) {
+ dtol = 0.0; /* none */
} else {
- dtol = primitive_get_absolute_tolerance(ttol, 2.0 * b);
+ /*
+ * Convert relative to absolute by scaling smallest of
+ * radius and semi-minor axis
+ */
+ if (tip->eto_r < b)
+ dtol = ttol->rel * 2 * tip->eto_r;
+ else
+ dtol = ttol->rel * 2 * b;
}
-
+ if (ttol->abs <= 0.0) {
+ if (dtol <= 0.0) {
+ /* No tolerance given, use a default */
+ if (tip->eto_r < b)
+ dtol = 2 * 0.10 * tip->eto_r; /* 10% */
+ else
+ dtol = 2 * 0.10 * b; /* 10% */
+ } else {
+ /* Use absolute-ized relative tolerance */
+ }
+ } else {
+ /* Absolute tolerance was given, pick smaller */
+ if (ttol->rel <= 0.0 || dtol > ttol->abs)
+ dtol = ttol->abs;
+ }
/* To ensure normal tolerance, remain below this angle */
if (ttol->norm > 0.0)
ntol = ttol->norm;
@@ -1373,11 +1423,8 @@
RT_CK_DB_INTERNAL(ip);
if (ip->idb_type != ID_ETO) return -1;
-
tip = (struct rt_eto_internal *)ip->idb_ptr;
- if (!eto_is_valid(tip)) {
- return -1;
- }
+ RT_ETO_CK_MAGIC(tip);
BU_CK_EXTERNAL(ep);
ep->ext_nbytes = sizeof(union record);
@@ -1387,6 +1434,19 @@
eto->s.s_id = ID_SOLID;
eto->s.s_type = ETO;
+ if (MAGNITUDE(tip->eto_C) < RT_LEN_TOL
+ || MAGNITUDE(tip->eto_N) < RT_LEN_TOL
+ || tip->eto_r < RT_LEN_TOL
+ || tip->eto_rd < RT_LEN_TOL) {
+ bu_log("rt_eto_export4: not all dimensions positive!\n");
+ return -1;
+ }
+
+ if (tip->eto_rd > MAGNITUDE(tip->eto_C)) {
+ bu_log("rt_eto_export4: semi-minor axis cannot be longer than semi-major axis!\n");
+ return -1;
+ }
+
/* Warning: type conversion */
VSCALE(&eto->s.s_values[0*3], tip->eto_V, local2mm);
VSCALE(&eto->s.s_values[1*3], tip->eto_N, local2mm);
@@ -1435,7 +1495,8 @@
tip->eto_r = vec[3*3] / mat[15];
tip->eto_rd = vec[3*3+1] / mat[15];
- if (!eto_is_valid(tip)) {
+ if (tip->eto_r <= SMALL || tip->eto_rd <= SMALL) {
+ bu_log("rt_eto_import4: zero length R or Rd vector\n");
return -1;
}
@@ -1458,16 +1519,26 @@
RT_CK_DB_INTERNAL(ip);
if (ip->idb_type != ID_ETO) return -1;
-
tip = (struct rt_eto_internal *)ip->idb_ptr;
- if (!eto_is_valid(tip)) {
- return -1;
- }
+ RT_ETO_CK_MAGIC(tip);
BU_CK_EXTERNAL(ep);
ep->ext_nbytes = SIZEOF_NETWORK_DOUBLE * 11;
ep->ext_buf = (genptr_t)bu_malloc(ep->ext_nbytes, "eto external");
+ if (MAGNITUDE(tip->eto_C) < RT_LEN_TOL
+ || MAGNITUDE(tip->eto_N) < RT_LEN_TOL
+ || tip->eto_r < RT_LEN_TOL
+ || tip->eto_rd < RT_LEN_TOL) {
+ bu_log("rt_eto_export4: not all dimensions positive!\n");
+ return -1;
+ }
+
+ if (tip->eto_rd > MAGNITUDE(tip->eto_C)) {
+ bu_log("rt_eto_export4: semi-minor axis cannot be longer than semi-major axis!\n");
+ return -1;
+ }
+
/* scale 'em into local buffer */
VSCALE(&vec[0*3], tip->eto_V, local2mm);
VSCALE(&vec[1*3], tip->eto_N, local2mm);
@@ -1608,28 +1679,7 @@
*area = 2.0 * M_PI * tip->eto_r * circum;
}
-static int
-eto_is_valid(struct rt_eto_internal *eto)
-{
- RT_ETO_CK_MAGIC(eto);
- /* check all vector magnitudes are positive */
- if (MAGNITUDE(eto->eto_N) < RT_LEN_TOL
- || MAGNITUDE(eto->eto_C) < RT_LEN_TOL
- || eto->eto_r < RT_LEN_TOL
- || eto->eto_rd < RT_LEN_TOL)
- {
- return 0;
- }
-
- /* require major axis to be longer than minor axis */
- if (eto->eto_rd > MAGNITUDE(eto->eto_C)) {
- return 0;
- }
-
- return 1;
-}
-
/** @} */
/*
* Local Variables:
Index: src/librt/primitives/brep/brep_debug.cpp
===================================================================
--- src/librt/primitives/brep/brep_debug.cpp (revision 53222)
+++ src/librt/primitives/brep/brep_debug.cpp (working copy)
@@ -45,6 +45,7 @@
#include "rtgeom.h"
#include "wdb.h"
+#define fastf_t double
#ifdef __cplusplus
extern "C" {
@@ -93,7 +94,7 @@
RT_ADD_VLIST(vhead, valp[d], BN_VLIST_LINE_DRAW);
#define BB_PLOT_VLIST(min, max) { \
- fastf_t pt[8][3]; \
+ double pt[8][3]; \
VSET(pt[0], max[X], min[Y], min[Z]); \
VSET(pt[1], max[X], max[Y], min[Z]); \
VSET(pt[2], max[X], max[Y], max[Z]); \
@@ -110,8 +111,7 @@
void
plotsurfaceleafs(SurfaceTree* surf) {
- vect_t min;
- vect_t max;
+ double min[3], max[3];
std::list<BBNode*> leaves;
surf->getLeaves(leaves);
@@ -155,7 +155,7 @@
plotsurfaceleafs(SurfaceTree* surf, struct bn_vlblock *vbp, bool dim3d)
{
register struct bu_list *vhead;
- fastf_t min[3], max[3];
+ double min[3], max[3];
std::list<BBNode*> leaves;
surf->getLeaves(leaves);
@@ -196,8 +196,7 @@
plottrimleafs(SurfaceTree* st, struct bn_vlblock *vbp, bool dim3d)
{
register struct bu_list *vhead;
- vect_t min;
- vect_t max;
+ double min[3], max[3];
std::list<BRNode*> leaves;
st->ctree->getLeaves(leaves);
@@ -238,14 +237,13 @@
void
plotleaf3d(BBNode* bb)
{
- vect_t min;
- vect_t max;
- fastf_t u, v;
+ double min[3], max[3];
+ double u, v;
ON_2dPoint uv[2];
int trim1_status;
int trim2_status;
- fastf_t closesttrim1;
- fastf_t closesttrim2;
+ double closesttrim1;
+ double closesttrim2;
if (bb->m_trimmed) {
COLOR_PLOT(255, 0, 0);
@@ -298,8 +296,7 @@
void
plotleafuv(BBNode* bb)
{
- vect_t min;
- vect_t max;
+ double min[3], max[3];
if (bb->m_trimmed) {
COLOR_PLOT(255, 0, 0);
@@ -326,8 +323,8 @@
{
register struct bu_list *vhead;
const ON_Surface* surf = face.SurfaceOf();
- fastf_t umin, umax;
- fastf_t pt1[3], pt2[3];
+ double umin, umax;
+ double pt1[3], pt2[3];
ON_2dPoint from, to;
ON_TextLog tl(stderr);
@@ -369,8 +366,8 @@
{
register struct bu_list *vhead;
const ON_Surface* surf = face.SurfaceOf();
- fastf_t umin, umax;
- fastf_t pt1[3], pt2[3];
+ double umin, umax;
+ double pt1[3], pt2[3];
ON_2dPoint from, to;
ON_TextLog tl(stderr);
@@ -410,9 +407,9 @@
{
register struct bu_list *vhead;
const ON_Surface* surf = face.SurfaceOf();
- fastf_t umin, umax, urange;
- fastf_t vmin, vmax, vrange;
- fastf_t pt1[3], pt2[3];
+ double umin, umax, urange;
+ double vmin, vmax, vrange;
+ double pt1[3], pt2[3];
ON_2dPoint from, to;
ON_TextLog tl(stderr);
@@ -460,8 +457,8 @@
register struct bu_list *vhead;
ON_BrepFace *face= trim.Face();
const ON_Surface* surf = face->SurfaceOf();
- fastf_t umin, umax;
- fastf_t pt1[3], pt2[3];
+ double umin, umax;
+ double pt1[3], pt2[3];
ON_2dPoint from, to;
ON_TextLog tl(stderr);
@@ -497,8 +494,8 @@
{
register struct bu_list *vhead;
const ON_Surface* surf = face.SurfaceOf();
- fastf_t umin, umax;
- fastf_t pt1[3], pt2[3];
+ double umin, umax;
+ double pt1[3], pt2[3];
ON_2dPoint from, to;
ON_TextLog tl(stderr);
@@ -515,13 +512,13 @@
//trimCurve->Dump(tl);
int knotcnt = trimCurve->SpanCount();
- fastf_t *knots = new fastf_t[knotcnt + 1];
+ double *knots = new double[knotcnt + 1];
trimCurve->GetSpanVector(knots);
for (int k = 1; k <= knotcnt; k++) {
- fastf_t dist = knots[k] - knots[k-1];
- fastf_t step = dist/plotres;
- for (fastf_t t=knots[k-1]+step; t<=knots[k]; t=t+step) {
+ double dist = knots[k] - knots[k-1];
+ double step = dist/plotres;
+ for (double t=knots[k-1]+step; t<=knots[k]; t=t+step) {
ON_3dPoint p = trimCurve->PointAt(t);
p = surf->PointAt(p.x, p.y);
ON_3dPoint prev = trimCurve->PointAt(t-step*0.1);
@@ -557,7 +554,7 @@
plotsurface(ON_Surface &surf, struct bn_vlblock *vbp, int isocurveres, int gridres, const int red = 255, const int green = 218, const int blue = 185)
{
register struct bu_list *vhead;
- fastf_t pt1[3], pt2[3];
+ double pt1[3], pt2[3];
ON_2dPoint from, to;
vhead = rt_vlblock_find(vbp, red, green, blue);
@@ -594,7 +591,7 @@
plotsurfacenormals(ON_Surface &surf, struct bn_vlblock *vbp, int gridres)
{
register struct bu_list *vhead;
- fastf_t pt1[3], pt2[3];
+ double pt1[3], pt2[3];
ON_2dPoint from, to;
vhead = rt_vlblock_find(vbp, GREEN);
@@ -622,14 +619,14 @@
plotsurfaceknots(ON_Surface &surf, struct bn_vlblock *vbp)
{
register struct bu_list *vhead;
- fastf_t pt1[3], pt2[3];
+ double pt1[3], pt2[3];
ON_2dPoint from, to;
int spanu_cnt = surf.SpanCount(0);
int spanv_cnt = surf.SpanCount(1);
- fastf_t *spanu = NULL;
- fastf_t *spanv = NULL;
- spanu = new fastf_t[spanu_cnt+1];
- spanv = new fastf_t[spanv_cnt+1];
+ double *spanu = NULL;
+ double *spanv = NULL;
+ spanu = new double[spanu_cnt+1];
+ spanv = new double[spanv_cnt+1];
surf.GetSpanVector(0, spanu);
surf.GetSpanVector(1, spanv);
@@ -658,7 +655,7 @@
plotcurve(ON_Curve &curve, struct bn_vlblock *vbp, int plotres, const int red = 255, const int green = 255, const int blue = 0)
{
register struct bu_list *vhead;
- fastf_t pt1[3], pt2[3];
+ double pt1[3], pt2[3];
ON_2dPoint from, to;
vhead = rt_vlblock_find(vbp, red, green, blue);
@@ -673,7 +670,7 @@
*/
int knotcnt = curve.SpanCount();
- fastf_t *knots = new fastf_t[knotcnt + 1];
+ double *knots = new double[knotcnt + 1];
curve.GetSpanVector(knots);
for (int i = 1; i <= knotcnt; i++) {
@@ -855,8 +852,8 @@
int knotlength1 = nsrf->m_order[1] + nsrf->m_cv_count[1] - 2;
int order0 = nsrf->m_order[0];
int order1 = nsrf->m_order[1];
- fastf_t *knot0 = nsrf->m_knot[0];
- fastf_t *knot1 = nsrf->m_knot[1];
+ double *knot0 = nsrf->m_knot[0];
+ double *knot1 = nsrf->m_knot[1];
int cnt = 0;
bu_vls_printf(vls, "bezier patches:\n");
for (int i = 0; i < knotlength0; ++i) {
@@ -1145,7 +1142,7 @@
c2->GetNurbForm(*nc2, 0.0);
int knotlength = nc2->m_order + nc2->m_cv_count - 2;
int order = nc2->m_order;
- fastf_t *knot = nc2->m_knot;
+ double *knot = nc2->m_knot;
dump.Print("trim[%2d]: domain(%g, %g)\n", ti, nc2->Domain()[0], nc2->Domain()[1]);
int cnt = 0;
dump.Print("NURBS converts to Bezier\n");
@@ -1441,7 +1438,7 @@
ucount = ns->m_cv_count[0];
vcount = ns->m_cv_count[1];
ON_3dPoint cp;
- fastf_t pt1[3], pt2[3];
+ double pt1[3], pt2[3];
register struct bu_list *vhead;
surf->Dump(tl);
vhead = rt_vlblock_find(vbp, PEACH);
@@ -1478,7 +1475,7 @@
ucount = ns->m_cv_count[0];
vcount = ns->m_cv_count[1];
ON_3dPoint cp;
- fastf_t pt1[3], pt2[3];
+ double pt1[3], pt2[3];
register struct bu_list *vhead;
vhead = rt_vlblock_find(vbp, PEACH);
for (int i = 0; i < ucount; ++i) {
@@ -1521,10 +1518,10 @@
plotFace(SurfaceTree* st, struct bn_vlblock *vbp, int UNUSED(isocurveres), int gridres)
{
register struct bu_list *vhead;
- fastf_t pt1[3], pt2[3];
+ double pt1[3], pt2[3];
ON_2dPoint from, to;
std::list<BRNode*> m_trims_above_or_right;
- std::list<fastf_t> trim_hits;
+ std::list<double> trim_hits;
vhead = rt_vlblock_find(vbp, PEACH);
@@ -1568,9 +1565,9 @@
if ((hit_cnt > 1) && ((hit_cnt % 2) == 0)) {
//bu_log("U - %f\n", pt.x);
while (!trim_hits.empty()) {
- fastf_t tfrom = trim_hits.front();
+ double tfrom = trim_hits.front();
trim_hits.pop_front();
- fastf_t tto = trim_hits.front();
+ double tto = trim_hits.front();
trim_hits.pop_front();
//bu_log("\tfrom - %f, to - %f\n", tfrom, tto);
fastf_t deltay = (tto-tfrom)/50.0;
@@ -1623,9 +1620,9 @@
if ((hit_cnt > 1) && ((hit_cnt % 2) == 0)) {
//bu_log("V - %f\n", pt.y);
while (!trim_hits.empty()) {
- fastf_t tfrom = trim_hits.front();
+ double tfrom = trim_hits.front();
trim_hits.pop_front();
- fastf_t tto = trim_hits.front();
+ double tto = trim_hits.front();
trim_hits.pop_front();
//bu_log("\tfrom - %f, to - %f\n", tfrom, tto);
fastf_t deltax = (tto-tfrom)/50.0;
@@ -1655,15 +1652,15 @@
drawisoUCheckForTrim(SurfaceTree* st, struct bn_vlblock *vbp, fastf_t from, fastf_t to, fastf_t v, int UNUSED(curveres))
{
register struct bu_list *vhead;
- fastf_t pt1[3], pt2[3];
+ double pt1[3], pt2[3];
std::list<BRNode*> m_trims_right;
- std::list<fastf_t> trim_hits;
+ std::list<double> trim_hits;
vhead = rt_vlblock_find(vbp, YELLOW);
const ON_Surface *surf = st->getSurface();
CurveTree *ctree = st->ctree;
- fastf_t umin, umax;
+ double umin, umax;
surf->GetDomain(0, &umin, &umax);
m_trims_right.clear();
@@ -1706,7 +1703,7 @@
if ((hit_cnt % 2) != 0) {
//bu_log("V - %f\n", pt.y);
if (!trim_hits.empty()) {
- fastf_t end = trim_hits.front();
+ double end = trim_hits.front();
trim_hits.pop_front();
//bu_log("\tfrom - %f, to - %f\n", from, to);
fastf_t deltax = (end - from) / 50.0;
@@ -1741,12 +1738,12 @@
}
*/
while (!trim_hits.empty()) {
- fastf_t start = trim_hits.front();
+ double start = trim_hits.front();
if (start < from) {
start = from;
}
trim_hits.pop_front();
- fastf_t end = trim_hits.front();
+ double end = trim_hits.front();
if (end > to) {
end = to;
}
@@ -1783,15 +1780,15 @@
drawisoVCheckForTrim(SurfaceTree* st, struct bn_vlblock *vbp, fastf_t from, fastf_t to, fastf_t u, int UNUSED(curveres))
{
register struct bu_list *vhead;
- fastf_t pt1[3], pt2[3];
+ double pt1[3], pt2[3];
std::list<BRNode*> m_trims_above;
- std::list<fastf_t> trim_hits;
+ std::list<double> trim_hits;
vhead = rt_vlblock_find(vbp, YELLOW);
const ON_Surface *surf = st->getSurface();
CurveTree *ctree = st->ctree;
- fastf_t vmin, vmax;
+ double vmin, vmax;
surf->GetDomain(1, &vmin, &vmax);
m_trims_above.clear();
@@ -1835,7 +1832,7 @@
if ((hit_cnt % 2) != 0) { //odd starting inside
//bu_log("V - %f\n", pt.y);
if (!trim_hits.empty()) {
- fastf_t end = trim_hits.front();
+ double end = trim_hits.front();
trim_hits.pop_front();
//bu_log("\tfrom - %f, to - %f\n", from, to);
fastf_t deltay = (end - from) / 50.0;
@@ -1871,12 +1868,12 @@
}
*/
while (!trim_hits.empty()) {
- fastf_t start = trim_hits.front();
+ double start = trim_hits.front();
trim_hits.pop_front();
if (start < from) {
start = from;
}
- fastf_t end = trim_hits.front();
+ double end = trim_hits.front();
trim_hits.pop_front();
if (end > to) {
end = to;
@@ -1911,7 +1908,7 @@
drawisoU(SurfaceTree* st, struct bn_vlblock *vbp, fastf_t from, fastf_t to, fastf_t v, int curveres)
{
register struct bu_list *vhead;
- fastf_t pt1[3], pt2[3];
+ double pt1[3], pt2[3];
fastf_t deltau = (to - from) / curveres;
const ON_Surface *surf = st->getSurface();
@@ -1937,7 +1934,7 @@
drawisoV(SurfaceTree* st, struct bn_vlblock *vbp, fastf_t from, fastf_t to, fastf_t u, int curveres)
{
register struct bu_list *vhead;
- fastf_t pt1[3], pt2[3];
+ double pt1[3], pt2[3];
fastf_t deltav = (to - from) / curveres;
const ON_Surface *surf = st->getSurface();
Index: src/librt/primitives/brep/brep.cpp
===================================================================
--- src/librt/primitives/brep/brep.cpp (revision 53222)
+++ src/librt/primitives/brep/brep.cpp (working copy)
@@ -49,6 +49,7 @@
#include "brep_debug.h"
+#include "nurbs.h"
#define BN_VMATH_PREFIX_INDICES 1
#define ROOT_TOL 1.E-7
@@ -348,16 +349,12 @@
int
rt_brep_bbox(struct rt_db_internal *ip, point_t *min, point_t *max) {
struct rt_brep_internal* bi;
- ON_3dPoint dmin, dmax;
RT_CK_DB_INTERNAL(ip);
bi = (struct rt_brep_internal*)ip->idb_ptr;
RT_BREP_CK_MAGIC(bi);
- bi->brep->GetBBox(dmin, dmax);
- VMOVE(*min, dmin);
- VMOVE(*max, dmax);
-
+ bi->brep->GetBBox(*min, *max);
return 0;
}
@@ -650,25 +647,17 @@
int
utah_newton_solver_test(const BBNode* sbv, const ON_Surface* surf, const ON_Ray& r, ON_2dPoint* ouv, double* t, ON_3dVector* N, bool& converged, ON_2dPoint* suv, const int count, const int iu, const int iv)
{
- int i = 0;
+ int i;
int intersects = 0;
- double j11 = 0.0;
- double j12 = 0.0;
- double j21 = 0.0;
- double j22 = 0.0;
- double f = 0.0;
- double g = 0.0;
- double rootdist = 0.0;
- double oldrootdist = 0.0;
- double J = 0.0;
- double invdetJ = 0.0;
- double du = 0.0;
- double dv = 0.0;
- double cdu = 0.0;
- double cdv = 0.0;
+ double j11, j12, j21, j22;
+ double f, g;
+ double rootdist, oldrootdist;
+ double J, invdetJ;
+ double du, dv;
+ double cdu, cdv;
ON_3dVector p1, p2;
- double p1d = 0.0, p2d = 0.0;
+ double p1d = 0, p2d = 0;
int errantcount = 0;
utah_ray_planes(r, p1, p1d, p2, p2d);
@@ -1058,25 +1047,22 @@
if (converged) {
for (int i = 0; i < numhits; i++) {
- double closesttrim;
+ fastf_t closesttrim;
BRNode* trimBR = NULL;
- int trim_status = sbv->isTrimmed(ouv[i], &trimBR, closesttrim);
+ int trim_status = ((BBNode*) sbv)->isTrimmed(ouv[i], &trimBR, closesttrim);
if (trim_status != 1) {
ON_3dPoint _pt;
ON_3dVector _norm(N[i]);
- vect_t vpt;
- vect_t vnorm;
_pt = ray.m_origin + (ray.m_dir * t[i]);
- VMOVE(vpt, _pt);
if (face->m_bRev) {
//bu_log("Reversing normal for Face:%d\n", face->m_face_index);
_norm.Reverse();
}
- VMOVE(vnorm, _norm);
hit_count += 1;
uv[0] = ouv[i].x;
uv[1] = ouv[i].y;
- brep_hit bh(*face, t[i], ray, vpt, vnorm, uv);
+ brep_hit bh(*face, t[i], ray, (const fastf_t*) _pt,
+ (const fastf_t*) _norm, uv);
bh.trimmed = false;
if (trimBR != NULL) {
bh.m_adj_face_index = trimBR->m_adj_face_index;
@@ -1090,7 +1076,7 @@
bh.closeToEdge = false;
bh.hit = brep_hit::CLEAN_HIT;
}
- if (VDOT(ray.m_dir, vnorm) < 0.0)
+ if (VDOT(ray.m_dir, _norm) < 0.0)
bh.direction = brep_hit::ENTERING;
else
bh.direction = brep_hit::LEAVING;
@@ -1100,19 +1086,16 @@
} else if (fabs(closesttrim) < BREP_EDGE_MISS_TOLERANCE) {
ON_3dPoint _pt;
ON_3dVector _norm(N[i]);
- vect_t vpt;
- vect_t vnorm;
_pt = ray.m_origin + (ray.m_dir * t[i]);
- VMOVE(vpt, _pt);
if (face->m_bRev) {
//bu_log("Reversing normal for Face:%d\n", face->m_face_index);
_norm.Reverse();
}
- VMOVE(vnorm, _norm);
hit_count += 1;
uv[0] = ouv[i].x;
uv[1] = ouv[i].y;
- brep_hit bh(*face, t[i], ray, vpt, vnorm, uv);
+ brep_hit bh(*face, t[i], ray, (const fastf_t*) _pt,
+ (const fastf_t*) _norm, uv);
bh.trimmed = true;
bh.closeToEdge = true;
if (trimBR != NULL) {
@@ -1121,7 +1104,7 @@
bh.m_adj_face_index = -99;
}
bh.hit = brep_hit::NEAR_MISS;
- if (VDOT(ray.m_dir, vnorm) < 0.0)
+ if (VDOT(ray.m_dir, _norm) < 0.0)
bh.direction = brep_hit::ENTERING;
else
bh.direction = brep_hit::LEAVING;
@@ -1145,13 +1128,13 @@
ON_2dPoint ouv(uv[0], uv[1]);
int found = BREP_INTERSECT_ROOT_DIVERGED;
bool converged = false;
- double closesttrim;
+ fastf_t closesttrim;
utah_newton_solver(surf, ray, ouv, t, N, converged);
/*
* DDR. The utah people are using this t_min which represents the
* last point hit along the ray to ensure we are looking at points
- * further down the ray. I haven't implemented this I'm not sure
+ * futher down the ray. I haven't implemented this I'm not sure
* we need it
*
* if (converged && (t > 1.e-2) && (t < t_min) && (!utah_isTrimmed(ouv, face))) hit = true;
@@ -1191,14 +1174,10 @@
if (hit) {
ON_3dPoint _pt;
ON_3dVector _norm(N);
- vect_t vpt;
- vect_t vnorm;
_pt = ray.m_origin + (ray.m_dir*t);
- VMOVE(vpt, _pt);
if (face->m_bRev) _norm.Reverse();
- VMOVE(vnorm, _norm);
hit_count += 1;
- hits.push_back(brep_hit(*face, ray, vpt, vnorm, uv));
+ hits.push_back(brep_hit(*face, ray, (const fastf_t*)_pt, (const fastf_t*)_norm, uv));
hits.back().sbv = sbv;
found = BREP_INTERSECT_FOUND;
}
@@ -1220,7 +1199,7 @@
ON_3dVector su;
ON_3dVector sv;
plane_ray pr;
- double closesttrim;
+ fastf_t closesttrim;
brep_get_plane_ray(ray, pr);
@@ -1248,13 +1227,9 @@
if ((found > 0) && (trim_status != 1)) {
ON_3dPoint _pt;
ON_3dVector _norm;
- vect_t vpt;
- vect_t vnorm;
surf->EvNormal(uv[0], uv[1], _pt, _norm);
- VMOVE(vpt, _pt);
if (face->m_bRev) _norm.Reverse();
- VMOVE(vnorm, _norm);
- hits.push_back(brep_hit(*face, ray, vpt, vnorm, uv));
+ hits.push_back(brep_hit(*face, ray, (const fastf_t*)_pt, (const fastf_t*)_norm, uv));
hits.back().sbv = sbv;
if (!sbv->m_u.Includes(uv[0]) || !sbv->m_v.Includes(uv[1])) {
@@ -3219,10 +3194,10 @@
IntersectPoint tmp_pt;
tmp_pt.m_pt = intersect_pt[k];
tmp_pt.m_seg = CVCount_sum + CV[k].first;
- tmp_pt.m_t = (int)parameter[k].first;
+ tmp_pt.m_t = parameter[k].first;
tmp_pt.m_type = j;
tmp_pt.m_seg_for_rank = CV[k].second;
- tmp_pt.m_t_for_rank = (int)parameter[k].second;
+ tmp_pt.m_t_for_rank = parameter[k].second;
intersect.Append(tmp_pt);
}
if (intersect_pt.Count())
@@ -3464,7 +3439,7 @@
delete curve_pt;
} else if (loop[k]->CVCount() == 2) {
// A closed curve with two control points
- // TODO: Sometimes we need a singular trim.
+ // TODO: Sometimes we need a sigular trim.
ON_3dPointArray ptarray(101);
for (int l = 0; l <= 100; l++) {
ON_3dPoint pt2d;
Index: src/librt/primitives/sph/sph.c
===================================================================
--- src/librt/primitives/sph/sph.c (revision 53222)
+++ src/librt/primitives/sph/sph.c (working copy)
@@ -218,7 +218,7 @@
(struct sph_specific *)stp->st_specific;
register struct seg *segp;
- vect_t ov; /* ray origin to center (V - P) */
+ vect_t ov; /* ray orgin to center (V - P) */
fastf_t magsq_ov; /* length squared of ov */
fastf_t b; /* second term of quadratic eqn */
fastf_t root; /* root of radical */
@@ -273,7 +273,7 @@
register struct sph_specific *sph;
register int i;
- vect_t ov; /* ray origin to center (V - P) */
+ vect_t ov; /* ray orgin to center (V - P) */
fastf_t magsq_ov; /* length squared of ov */
fastf_t b; /* second term of quadratic eqn */
fastf_t root; /* root of radical */
Index: src/librt/primitives/cline/cline.c
===================================================================
--- src/librt/primitives/cline/cline.c (revision 53222)
+++ src/librt/primitives/cline/cline.c (working copy)
@@ -245,7 +245,7 @@
dist[1] = dist[2];
}
- /* volume mode */
+ /* vloume mode */
RT_GET_SEG(segp, ap->a_resource);
segp->seg_stp = stp;
Index: src/librt/primitives/superell/superell_brep.cpp
===================================================================
--- src/librt/primitives/superell/superell_brep.cpp (revision 53222)
+++ src/librt/primitives/superell/superell_brep.cpp (working copy)
@@ -86,7 +86,7 @@
// When both e and n <= 2, this can generate an ideal b-rep for superell, otherwise cannot.
if (sip->e <= 2 && sip->n <= 2) {
for (int i = 0; i < surf->CVCount(0); i++) {
- fastf_t tmp_weight = 0.0;
+ fastf_t tmp_weight;
switch (i) {
case 0:
case 4:
@@ -105,7 +105,7 @@
bu_log("Should not reach here!\n");
}
for (int j = 0; j < surf->CVCount(1); j++) {
- fastf_t new_weight = 0.0;
+ fastf_t new_weight;
switch (j) {
case 0:
case 2:
Index: src/librt/primitives/superell/superell.c
===================================================================
--- src/librt/primitives/superell/superell.c (revision 53222)
+++ src/librt/primitives/superell/superell.c (working copy)
@@ -23,8 +23,8 @@
*
* Intersect a ray with a Superquadratic Ellipsoid.
*
- * NOTICE: this primitive is incomplete and should be considered
- * experimental. This primitive will exhibit several
+ * NOTICE: this primitive is incomplete and should beconsidered
+ * experimental. this primitive will exhibit several
* instabilities in the existing root solver method.
*
*/
@@ -120,7 +120,7 @@
* NORMALS. Given the point W on the superellipsoid, what is the
* vector normal to the tangent plane at that point?
*
- * Map W onto the unit sphere, i.e.: W' = S(R(W - V)).
+ * Map W onto the unit sphere, ie: W' = S(R(W - V)).
*
* Plane on unit sphere at W' has a normal vector of the same value(!).
* N' = W'
@@ -164,7 +164,7 @@
double superell_invmsBu; /* 1.0 / |Bu|^2 */
double superell_invmsCu; /* 1.0 / |Cu|^2 */
vect_t superell_invsq;
- mat_t superell_SoR; /* matrix for local coordinate system, Scale(Rotate(V))*/
+ mat_t superell_SoR; /* matrix for local cordinate system, Scale(Rotate(V))*/
mat_t superell_invRSSR; /* invR(Scale(Scale(Rot(V)))) */
mat_t superell_invR; /* transposed rotation matrix */
};
@@ -434,7 +434,7 @@
MAT4X3VEC(newShotDir, superell->superell_SoR, rp->r_dir);
VUNITIZE(newShotDir);
- /* normalize distance from the superell. substitutes a corrected ray
+ /* normalize distance from the superell. substitues a corrected ray
* point, which contains a translation along the ray direction to the
* closest approach to vertex of the superell. Translating the ray
* along the direction of the ray to the closest point near the
Index: src/librt/primitives/arb8/arb8.c
===================================================================
--- src/librt/primitives/arb8/arb8.c (revision 53222)
+++ src/librt/primitives/arb8/arb8.c (working copy)
@@ -316,7 +316,7 @@
* R T _ A R B _ C E N T R O I D
*
* Find the center point for the arb whose values are in the s array,
- * with the given number of vertices. Return the point in center_pt.
+ * with the given number of verticies. Return the point in center_pt.
*/
void
rt_arb_centroid(point_t center_pt, const struct rt_arb_internal *arb, int npoints)
@@ -389,7 +389,7 @@
/* Pts are given clockwise, so reverse terms of cross prod. */
/* peqn = (C-A)x(B-A), which points inwards */
VCROSS(afp->peqn, P_A, ofp->arb_U);
- /* Check for co-linear, i.e., |(B-A)x(C-A)| ~= 0 */
+ /* Check for co-linear, ie, |(B-A)x(C-A)| ~= 0 */
f = MAGNITUDE(afp->peqn);
if (NEAR_ZERO(f, RT_SLOPPY_DOT_TOL)) {
return -1; /* BAD */
@@ -428,7 +428,7 @@
* points inwards, so we need to fix it here.
* Build a vector from the centroid to vertex A.
* If the surface normal points in the same direction,
- * then the vertices were given in CCW order;
+ * then the vertcies were given in CCW order;
* otherwise, vertices were given in CW order, and
* the normal needs to be flipped.
*/
@@ -889,7 +889,7 @@
if (ap) RT_CK_APPLICATION(ap);
- /* Initialize return values */
+ /* Intialize return values */
for (i = 0; i < n; i++) {
segp[i].seg_stp = stp[i]; /* Assume hit, if 0 then miss */
segp[i].seg_in.hit_dist = -INFINITY; /* used as in */
@@ -1042,7 +1042,7 @@
rt_db_free_internal(&intern);
if (ret != 0 || arbp->arb_opt == (struct oface *)0) {
- bu_log("rt_arb_uv(%s) dynamic setup failure st_specific=x%x, optp=x%x\n",
+ bu_log("rt_arb_uv(%s) dyanmic setup failure st_specific=x%x, optp=x%x\n",
stp->st_name,
stp->st_specific, arbp->arb_opt);
return;
@@ -1330,7 +1330,7 @@
char buf[256] = {0};
int i = 0;
int arb_type = -1;
- struct bn_tol tmp_tol; /* temporary tolerance */
+ struct bn_tol tmp_tol; /* temporay tolerance */
if (!str || !ip) return 0;
RT_CK_DB_INTERNAL(ip);
Index: src/librt/primitives/bspline/nurb_trim_util.c
===================================================================
--- src/librt/primitives/bspline/nurb_trim_util.c (revision 53222)
+++ src/librt/primitives/bspline/nurb_trim_util.c (working copy)
@@ -37,11 +37,11 @@
#include "nurb.h"
/**
- * Check to see if the curve control polygon wanders outside the
- * parametric range given. This is useful if a trimming curve
+ * Check to see if the curve conmtrol polygon wonders outside the
+ * parametric range given. This is usefull if a trimming curve
* control polygon is outside but the evaluated curve is not. We will
- * want to refine the curve so that it lies within the range;
- * otherwise it breaks the surface evaluation.
+ * want to refine the curve so that is lies within the range;
+ * otherwise it breaks the surface evaluation
*/
int
rt_nurb_crv_in_range(struct edge_g_cnurb *crv, fastf_t u_min, fastf_t u_max, fastf_t v_min, fastf_t v_max)
Index: src/librt/primitives/bspline/nurb_trim.c
===================================================================
--- src/librt/primitives/bspline/nurb_trim.c (revision 53222)
+++ src/librt/primitives/bspline/nurb_trim.c (working copy)
@@ -74,7 +74,7 @@
* It then uses a table look up to determine the whether its CASE{A,
* B, C}, One difference from the paper is the fact that if any of the
* points lie on the axis of the u, v quadrant system then the axis is
- * only in either Quadrant 1 or Quadrant 2 and not q3 or q4. This
+ * only in either Quadrant 1 or Quadrant 2 and not q3 or q4. THis
* handles the case of endpoint problems correctly.
*/
int
@@ -228,15 +228,15 @@
/**
* Process Case C curves;
*
- * A check is placed here to determine if the u, v is on the curve.
+ * A check is placed here to determin if the u, v is on the curve.
* Determine how many times the curve will cross the u, v axis. If the
* curve crosses an odd number of times than the point is IN, else the
- * point is OUT. Since a Case C curve need processing a call to clip
- * the curve so that it becomes either Case B or Case A is required
- * to determine the number of crossings accurately. Thus we need to keep
+ * point is OUT. Since a case C curve need processin a call to clip
+ * hte curve so that it becomes either Case B, or Case A is required
+ * to determine the number of crossing acurately. Thus we need to keep
* the original curve and expect the calling routine to free the
* storage. Additional curves are generated in this routine, each of
- * these new curves are processed, and then are deleted before exiting
+ * these new curves are proccesed, and then are deleted before exiting
* this procedure.
*/
int
@@ -249,7 +249,7 @@
int trim_flag = 0;
int caset;
- /* determine if the u, v values are on the curve */
+ /* determine if the the u, v values are on the curve */
if (rt_nurb_uv_dist(trim, u, v) == TRIM_ON) return TRIM_IN;
@@ -297,10 +297,10 @@
/**
* This routine will be called several times, once for each portion of
- * the trimming curve. It returns whether a line extended from the
+ * the trimming curve. It returns wheter a line extended from the the
* <u, v> point will cross the trimming curve an even or odd number of
* times. Or the <u, v> point could be on the curve in which case
- * TRIM_ON will be returned. The algorithm uses the approach taken Tom
+ * TRIM_ON will be returned. THe algorithm uses the approach taken Tom
* Sederburge and uses bezier clipping to produce caseA and caseB
* curves. If the original trimming curve is a CASE C curve then
* further processing is required.
@@ -369,15 +369,15 @@
/**
- * We try to clip a curve so that it can be either Case A or Case C.
- * Sometimes one of the curves is still Case C though, but it is much
- * smaller than the original, and further clipping will either show that
+ * We try and clip a curve so that it can be either Case A, or Case C.
+ * Sometimes one of the curves is still case C though, but it is much
+ * small than the original, and further clipping will either show that
* it is on the curve or provide all Case B or Case A curves. We try
- * to pick the best axis to clip against, but this may not always
+ * and pick the best axis to clip against, but this may not always
* work. One extra step that was included, that is not in the paper
* for curves but is for surfaces, is the fact that sometimes the
* curve is not clipped enough, if the maximum clip is less than .2
- * then we subdivide the curve in three equal parts, at .3 and .6 .
+ * than we sub divide the curve in three equal parts, at .3 and .6,
* Subdivision is done using the Oslo Algorithm, rather than the other
* methods which were prossed.
*/
@@ -466,7 +466,7 @@
if (!zero_changed)
return;
- /* Clip is not large enough, split in thirds and try again */
+ /* Clip is not large enough, split in thiords and try again */
if (umax - umin < .2) {
umin = .3; umax = .6;
Index: src/librt/primitives/bspline/nurb_norm.c
===================================================================
--- src/librt/primitives/bspline/nurb_norm.c (revision 53222)
+++ src/librt/primitives/bspline/nurb_norm.c (working copy)
@@ -21,7 +21,7 @@
/** @{ */
/** @file primitives/bspline/nurb_norm.c
*
- * Calculate and return the normal of a surface given the U, V
+ * Calulate and return the normal of a surface given the U, V
* parametric values.
*
*/
Index: src/librt/primitives/bspline/nurb_tess.c
===================================================================
--- src/librt/primitives/bspline/nurb_tess.c (revision 53222)
+++ src/librt/primitives/bspline/nurb_tess.c (working copy)
@@ -41,11 +41,11 @@
/**
* Algorithm -
*
- * See paper in Computer Aided Design (CAD) Volume 27, Number 1,
- * January 1995 TESSELATING TRIMMED NURBS SURFACES, Leslie A Piegl
+ * See paper in Computer Aided Design (CAD) Volumne 27, Number 1,
+ * January 1995 TESSELATING TRIMMMED NURBS SURFACES, Leslie A Piegl
* and Arnaud Richard.
*
- * There is a slight deviation from the paper; since libnurb
+ * There is a slight deviation from the paper, Since libnurb
* (rt_nurb_s_diff) differentiation correctly handles rational
* surfaces, no special processing for rational is needed.
*
Index: src/librt/primitives/bspline/nurb_plot.c
===================================================================
--- src/librt/primitives/bspline/nurb_plot.c (revision 53222)
+++ src/librt/primitives/bspline/nurb_plot.c (working copy)
@@ -21,7 +21,7 @@
/** @{ */
/** @file primitives/bspline/nurb_plot.c
*
- * Utilities for spline debugging.
+ * Utilities for spline debuging.
*
*/
/** @} */
Index: src/librt/primitives/bspline/nurb_poly.c
===================================================================
--- src/librt/primitives/bspline/nurb_poly.c (revision 53222)
+++ src/librt/primitives/bspline/nurb_poly.c (working copy)
@@ -22,7 +22,7 @@
/** @file primitives/bspline/nurb_poly.c
*
* Returns two polygons from a NURB surface.
- * Assumes that the surface is flat.
+ * Asumes that the surface is flat.
*
*/
/** @} */
Index: src/librt/primitives/bspline/nurb_eval.c
===================================================================
--- src/librt/primitives/bspline/nurb_eval.c (revision 53222)
+++ src/librt/primitives/bspline/nurb_eval.c (working copy)
@@ -43,7 +43,7 @@
* Algorithm -
*
* The algorithm uses the traditional COX-deBoor approach found in the
- * book "Practical Guide to Splines" Carl de Boor, pg 147 to evaluate a
+ * book "Pratical Guide to Splines" Carl de Boor, pg 147 to evaluate a
* parametric value on a curve. This is expanded to the surface.
*/
void
Index: src/librt/primitives/bspline/nurb_solve.c
===================================================================
--- src/librt/primitives/bspline/nurb_solve.c (revision 53222)
+++ src/librt/primitives/bspline/nurb_solve.c (working copy)
@@ -24,7 +24,7 @@
* Decompose a matrix into its LU decomposition using pivoting.
*
* These Procedures take a set of matrices of the form Ax = b and
- * allows one to solve the system by various means. The
+ * alows one to solve the system by various means. The
* rt_nurb_doolittle routine takes the system and creates a lu
* decomposition using pivoting to get the system in a desired
* form. Forward and backward substitution are then used to solve the
@@ -61,7 +61,7 @@
/* dimension of the matrix */
- /* Number of coordinates for mat_2 and solution */
+ /* Number of coordsinates for mat_2 and solution */
{
register int i, k;
fastf_t *y;
@@ -77,7 +77,7 @@
s = (fastf_t *) bu_malloc(sizeof (fastf_t) * dim,
"rt_nurb_solve: s");/* Create temp array */
- rt_nurb_doolittle (mat_1, mat_2, dim, coords);/* Create LU decomposition */
+ rt_nurb_doolittle (mat_1, mat_2, dim, coords);/* Create LU decomosition */
for (k =0; k < coords; k++) {
fastf_t * ptr;
@@ -110,7 +110,7 @@
/**
- * Create LU decomposition.
+ * Create LU decomosition.
* Modifies both mat_1 and mat_2 values.
*/
void
@@ -134,7 +134,7 @@
s = (fastf_t *) bu_malloc(sizeof (fastf_t) * row * row,
"rt_nurb_doolittle:s"); /* vector to check */
ds = (fastf_t *) bu_malloc(sizeof (fastf_t) * row,
- "rt_nurb_doolittle:ds"); /* if rows need to be swapped */
+ "rt_nurb_doolittle:ds"); /* if rows need to be swaped */
for (i = 0; i < row; i++) {
/* calculate the scaling factors */
@@ -158,7 +158,7 @@
for (i = k; i < row; i ++) {
/* check to see if rows need */
- /* to be swapped */
+ /* to be swaped */
ds[i] = d[i] * s[ i * row + k];
if (ds[max_pivot] < ds[i])
max_pivot = i;
@@ -205,7 +205,7 @@
void
-rt_nurb_forw_solve(const fastf_t *lu, const fastf_t *b, fastf_t *y, int n) /* spl_solve lower triangular matrix */
+rt_nurb_forw_solve(const fastf_t *lu, const fastf_t *b, fastf_t *y, int n) /* spl_solve lower trianglular matrix */
{
Index: src/librt/primitives/bspline/nurb_ray.c
===================================================================
--- src/librt/primitives/bspline/nurb_ray.c (revision 53222)
+++ src/librt/primitives/bspline/nurb_ray.c (working copy)
@@ -133,7 +133,7 @@
struct internal_convex_hull ch[20]; /* max order is 10 */
register fastf_t * mp1;
fastf_t * p1, *p2, *p3, *p4; /* corner points of the mesh */
- fastf_t v1[2], v2[2], v3[2]; /* vectors from corners */
+ fastf_t v1[2], v2[2], v3[2]; /* vectors from corneres */
struct internal_line l1;
fastf_t norm;
fastf_t value;
Index: src/librt/primitives/bspline/bspline_mirror.c
===================================================================
--- src/librt/primitives/bspline/bspline_mirror.c (revision 53222)
+++ src/librt/primitives/bspline/bspline_mirror.c (working copy)
@@ -93,7 +93,7 @@
int m;
int l;
- /* swap knot vectors between u and v */
+ /* swap knot vetcors between u and v */
ptr = nurb->srfs[i]->u.knots;
tmp = nurb->srfs[i]->u.k_size;
@@ -127,7 +127,7 @@
}
/* copy mirrored control points into new mesh
- * while swapping u and v */
+ * while swaping u and v */
m = 0;
for (j=0; j<orig_size[0]; j++) {
for (l=0; l<orig_size[1]; l++) {
Index: src/librt/primitives/bspline/nurb_interp.c
===================================================================
--- src/librt/primitives/bspline/nurb_interp.c (revision 53222)
+++ src/librt/primitives/bspline/nurb_interp.c (working copy)
@@ -21,7 +21,7 @@
/** @{ */
/** @file primitives/bspline/nurb_interp.c
*
- * Interpolation routines for fitting NURB curves and and surfaces to
+ * Interpolatopn routines for fitting NURB curves and and surfaces to
* existing data.
*
*/
@@ -102,7 +102,7 @@
crv->pt_type = RT_NURB_MAKE_PT_TYPE(3, RT_NURB_PT_XYZ, 0);
/* First set up Curve data structs */
- /* For now we will assume that all parameterizations are uniform */
+ /* For now we will assume that all paramerizations are uniform */
rt_nurb_kvknot(&crv->k, order, 0.0, 1.0, (n - order), (struct resource *)NULL);
@@ -175,7 +175,7 @@
srf->pt_type = RT_NURB_MAKE_PT_TYPE(3, RT_NURB_PT_XYZ, RT_NURB_PT_NONRAT);
/* the U knot vector replates to the points in a row therefore you
- * want to determine how many cols there are similar for the V knot
+ * want to determin how many cols there are similar for the V knot
* vector
*/
Index: src/librt/primitives/bspline/bspline.cpp
===================================================================
--- src/librt/primitives/bspline/bspline.cpp (revision 53222)
+++ src/librt/primitives/bspline/bspline.cpp (working copy)
@@ -62,7 +62,7 @@
#endif
struct nurb_specific {
- struct nurb_specific *next; /* next surface in the solid */
+ struct nurb_specific *next; /* next surface in the the solid */
struct face_g_snurb *srf; /* Original surface description */
struct bu_list bez_hd; /* List of Bezier face_g_snurbs */
};
@@ -626,7 +626,7 @@
int coords;
fastf_t bound;
point_t tmp_pt;
- fastf_t dtol;
+ fastf_t rel;
struct knot_vector tkv1,
tkv2;
fastf_t tess;
@@ -639,14 +639,33 @@
VSUB2(tmp_pt, n->min_pt, n->max_pt);
bound = MAGNITUDE(tmp_pt)/ 2.0;
+ /*
+ * Establish tolerances
+ */
+ if (ttol->rel <= 0.0 || ttol->rel >= 1.0) {
+ rel = 0.0; /* none */
+ } else {
+ /* Convert rel to absolute by scaling by diameter */
+ rel = ttol->rel * 2 * bound;
+ }
+ if (ttol->abs <= 0.0) {
+ if (rel <= 0.0) {
+ /* No tolerance given, use a default */
+ rel = 2 * 0.10 * bound; /* 10% */
+ } else {
+ /* Use absolute-ized relative tolerance */
+ }
+ } else {
+ /* Absolute tolerance was given, pick smaller */
+ if (ttol->rel <= 0.0 || rel > ttol->abs)
+ rel = ttol->abs;
+ }
- dtol = primitive_get_absolute_tolerance(ttol, 2.0 * bound);
-
if (n->order[0] < 3 || n->order[1] < 3) {
/* cannot use rt_nurb_par_edge() in this case */
tess = 0.25; /* hack for now */
} else
- tess = (fastf_t) rt_nurb_par_edge(n, dtol);
+ tess = (fastf_t) rt_nurb_par_edge(n, rel);
num_knots = (int)floor(1.0/((M_SQRT1_2 / 2.0) * tess));
@@ -934,7 +953,7 @@
/* Figure out how many recs to buffer by
* walking through the surfaces and
- * calculating the number of granules
+ * calculating the number of granuels
* needed for storage and add it to the total
*/
total_grans = 1; /* First gran for BSOLID record */
Index: src/librt/primitives/bspline/nurb_bound.c
===================================================================
--- src/librt/primitives/bspline/nurb_bound.c (revision 53222)
+++ src/librt/primitives/bspline/nurb_bound.c (working copy)
@@ -50,7 +50,7 @@
int
rt_nurb_s_bound(struct face_g_snurb *srf, fastf_t *bmin, fastf_t *bmax)
{
- register fastf_t *p_ptr; /* Mesh pointer */
+ register fastf_t *p_ptr; /* Mesh pointr */
register int coords; /* Elements per vector */
int i;
int rat;
@@ -91,7 +91,7 @@
int
rt_nurb_c_bound(struct edge_g_cnurb *crv, fastf_t *bmin, fastf_t *bmax)
{
- register fastf_t *p_ptr; /* Mesh pointer */
+ register fastf_t *p_ptr; /* Mesh pointr */
register int coords; /* Elements per vector */
int i;
int rat;
@@ -132,13 +132,13 @@
* rt_nurb_s_check(srf)
*
* Checks the NURB surface control points to make sure no one point is
- * near INFINITY, which probably means that the surface mesh is bad.
+ * near INIFITY, which probably means that the surface mesh is bad.
*/
int
rt_nurb_s_check(register struct face_g_snurb *srf)
{
- register fastf_t *mp; /* Mesh pointer */
+ register fastf_t *mp; /* Mesh pointr */
register int i;
mp = srf->ctl_points;
@@ -160,13 +160,13 @@
* rt_nurb_c_check(srf)
*
* Checks the NURB curve control points to make sure no one point is
- * near INFINITY, which probably means that the surface mesh is bad.
+ * near INIFITY, which probably means that the surface mesh is bad.
*/
int
rt_nurb_c_check(register struct edge_g_cnurb *crv)
{
- register fastf_t *mp; /* Mesh pointer */
+ register fastf_t *mp; /* Mesh pointr */
register int i;
mp = crv->ctl_points;
Index: src/librt/primitives/hf/hf.c
===================================================================
--- src/librt/primitives/hf/hf.c (revision 53222)
+++ src/librt/primitives/hf/hf.c (working copy)
@@ -328,7 +328,7 @@
*/
/*
- * Start finding the location of the opposite vertex to V
+ * Start finding the location of the oposite vertex to V
*/
VJOIN2(hf->hf_VO, hip->v, hip->xlen, hip->x, hip->ylen, hip->y);
@@ -653,7 +653,7 @@
}
/*
* This is the two hit situation which can cause interesting
- * problems. There are basically five different cases that must be
+ * problems. Three are basicly five different cases that must be
* dealt with and each one requires that the ray be classified
*
* 1) The ray has hit two different planes at two different
@@ -834,8 +834,8 @@
*/
for (j=-1; j>-7; j--) {
fastf_t dn; /* Direction dot Normal */
- fastf_t dxbdn; /* distance between d and b * dn */
- fastf_t s; /* actual distance in mm */
+ fastf_t dxbdn; /* distence beteen d and b * dn */
+ fastf_t s; /* actual distence in mm */
int allIndex;
switch (j) {
@@ -957,7 +957,7 @@
axis_plane_isect(oplane, out, rp, hf, xWidth, yWidth, &hp, &nhits);
/*
- * Gee, we've gotten much closer, we know that we hit the
+ * Gee, we've gotten much closer, we know that we hit the the
* solid. Now it's time to see which cell we hit. The Key here is
* to use a fast DDA to check ONLY the cells we are interested in.
* The basic idea and some of the pseudo code comes from:
Index: src/librt/primitives/rec/rec.c
===================================================================
--- src/librt/primitives/rec/rec.c (revision 53222)
+++ src/librt/primitives/rec/rec.c (working copy)
@@ -21,7 +21,7 @@
/** @{ */
/** @file primitives/rec/rec.c
*
- * Intersect a ray with a Right Elliptical Cylinder. This is a special
+ * Intersect a ray with a Right Eliptical Cylinder. This is a special
* (but common) case of the TGC, which is handled separately.
*
* Algorithm -
@@ -77,7 +77,7 @@
* c = ((Px'**2 + Py'**2) - r**2) / (Dx'**2 + Dy'**2)
* r = 1.0
*
- * The quadratic formula yields k (which is constant):
+ * The qudratic formula yields k (which is constant):
*
* k = [ -b +/- sqrt(b**2 - 4 * c ] / 2.0
*
@@ -100,10 +100,10 @@
* NORMALS. Given the point W on the surface of the cylinder, what is
* the vector normal to the tangent plane at that point?
*
- * Map W onto the unit cylinder, i.e.: W' = S(R(W - V)).
+ * Map W onto the unit cylinder, ie: W' = S(R(W - V)).
*
* Plane on unit cylinder at W' has a normal vector N' of the same
- * value as W' in x and y, with z set to zero, i.e., (Wx', Wy', 0)
+ * value as W' in x and y, with z set to zero, ie, (Wx', Wy', 0)
*
* The plane transforms back to the tangent plane at W, and this new
* plane (on the original cylinder) has a normal vector of N, viz:
@@ -459,7 +459,7 @@
if (ZERO(dprime[X]) && ZERO(dprime[Y]))
goto check_plates;
- /* Find roots of the equation, using formula for quadratic w/ a=1 */
+ /* Find roots of the equation, using forumla for quadratic w/ a=1 */
{
fastf_t b; /* coeff of polynomial */
fastf_t root; /* root of radical */
@@ -627,7 +627,7 @@
if (ap) RT_CK_APPLICATION(ap);
- /* for each ray/right_elliptical_cylinder pair */
+ /* for each ray/right_eliptical_cylinder pair */
for (i = 0; i < n; i++) {
if (stp[i] == 0) continue; /* stp[i] == 0 signals skip ray */
@@ -642,7 +642,7 @@
if (ZERO(dprime[X]) && ZERO(dprime[Y]))
goto check_plates;
- /* Find roots of eqn, using formula for quadratic w/ a=1 */
+ /* Find roots of eqn, using forumla for quadratic w/ a=1 */
b = 2 * (dprime[X]*pprime[X] + dprime[Y]*pprime[Y]) *
(dx2dy2 = 1 / (dprime[X]*dprime[X] + dprime[Y]*dprime[Y]));
if ((root = b*b - 4 * dx2dy2 *
Index: src/librt/primitives/tgc/tgc.c
===================================================================
--- src/librt/primitives/tgc/tgc.c (revision 53222)
+++ src/librt/primitives/tgc/tgc.c (working copy)
@@ -1282,7 +1282,7 @@
}
} else {
- /* If all conic intersections lie outside the plane, then
+ /* If all conic interections lie outside the plane, then
* check to see whether there are two planar intersections
* inside the governing ellipses.
*
@@ -1803,69 +1803,7 @@
ip->idb_ptr = GENPTR_NULL;
}
-struct ellipse {
- point_t center;
- vect_t axis_a;
- vect_t axis_b;
-};
-static void
-draw_lines_between_ellipses(struct bu_list *vhead, struct ellipse ellipse1, struct ellipse ellipse2, int num_lines)
-{
- int i;
- point_t ellipse1_point, ellipse2_point;
- fastf_t radian_step = 2.0 * M_PI / num_lines;
-
- for (i = 0; i < num_lines; ++i) {
- ellipse_point_at_radian(ellipse1_point, ellipse1.center,
- ellipse1.axis_a, ellipse1.axis_b, i * radian_step);
- ellipse_point_at_radian(ellipse2_point, ellipse2.center,
- ellipse2.axis_a, ellipse2.axis_b, i * radian_step);
-
- RT_ADD_VLIST(vhead, ellipse1_point, BN_VLIST_LINE_MOVE);
- RT_ADD_VLIST(vhead, ellipse2_point, BN_VLIST_LINE_DRAW);
- }
-}
-
-int
-rt_tgc_adaptive_plot(struct rt_db_internal *ip, const struct rt_view_info *info)
-{
- int samples;
- struct rt_tgc_internal *tip;
- struct ellipse ellipse1, ellipse2;
-
- BU_CK_LIST_HEAD(info->vhead);
- RT_CK_DB_INTERNAL(ip);
- tip = (struct rt_tgc_internal *)ip->idb_ptr;
- RT_TGC_CK_MAGIC(tip);
-
- samples = sqrt(primitive_diagonal_samples(ip, info));
- if (samples % 2 != 0) {
- ++samples;
- }
- if (samples < 6) {
- samples = 6;
- }
-
- VMOVE(ellipse1.center, tip->v);
- VMOVE(ellipse1.axis_a, tip->a);
- VMOVE(ellipse1.axis_b, tip->b);
- plot_ellipse(info->vhead, ellipse1.center, ellipse1.axis_a, ellipse1.axis_b,
- samples);
-
- VADD2(ellipse2.center, tip->v, tip->h);
- VMOVE(ellipse2.axis_a, tip->c);
- VMOVE(ellipse2.axis_b, tip->d);
- plot_ellipse(info->vhead, ellipse2.center, ellipse2.axis_a, ellipse2.axis_b,
- samples);
-
- samples /= 2;
-
- draw_lines_between_ellipses(info->vhead, ellipse1, ellipse2, samples);
-
- return 0;
-}
-
/**
* R T _ T G C _ P L O T
*/
@@ -2174,7 +2112,7 @@
/* and for complete ellipse */
nsegs *= 4;
- /* get number and placement of intermediate ellipses */
+ /* get nunber and placement of intermediate ellipses */
{
fastf_t ratios[4], max_ratio;
fastf_t new_ratio = 0;
@@ -3005,8 +2943,8 @@
}
-/* Create a cylinder with a top surface and a bottom surface
- * defined by the ellipsoids at the top and bottom of the
+/* Create a cylinder with a top surface and a bottom surfce
+ * defined by the ellipsods at the top and bottom of the
* cylinder, the top_mat, and bot_mat are applied to a unit circle
* for the top row of the surface and the bot row of the surface
* respectively.
Index: src/librt/primitives/sketch/sketch_tess.cpp
===================================================================
--- src/librt/primitives/sketch/sketch_tess.cpp (revision 53222)
+++ src/librt/primitives/sketch/sketch_tess.cpp (working copy)
@@ -90,7 +90,7 @@
/* NOTE: MINSTEP and MAXSTEP were determined by experimentation. If MINSTEP is
- * much smaller (i.e. 0.00001), approx_bezier() slows significantly on curves with
+ * much smaller (ie. 0.00001), approx_bezier() slows significantly on curves with
* high curvature over a large part of its domain. MAXSTEP represents a step
* size of 1/10th the domain of a Bezier curve, and MINSTEP represents 1/10000th.
*/
@@ -145,8 +145,8 @@
HIDDEN void
approx_bezier(const ON_BezierCurve& bezier, const ON_Arc& biarc, const struct bn_tol *tol, std::vector<ON_Arc>& approx)
{
- fastf_t t = 0.0, step = 0.0;
- fastf_t crv = 0.0, err = 0.0, max_t = 0.0, max_err = 0.0;
+ fastf_t t, step;
+ fastf_t crv, err, max_t, max_err = 0.0;
ON_3dPoint test;
ON_3dVector d1, d2;
Index: src/librt/primitives/sketch/sketch.c
===================================================================
--- src/librt/primitives/sketch/sketch.c (revision 53222)
+++ src/librt/primitives/sketch/sketch.c (working copy)
@@ -1163,8 +1163,8 @@
nbytes += 8 + (bseg->degree + 1) * 4;
break;
default:
- bu_log("rt_sketch_export4: unsupported segment type (x%x)\n", *lng);
- bu_bomb("rt_sketch_export4: unsupported segment type\n");
+ bu_log("rt_sketch_export4: unsupported segement type (x%x)\n", *lng);
+ bu_bomb("rt_sketch_export4: unsupported segement type\n");
}
}
@@ -1209,7 +1209,7 @@
uint32_t *lng;
fastf_t tmp_fastf;
- /* write segment type ID, and segment parameters */
+ /* write segment type ID, and segement parameters */
lng = (uint32_t *)sketch_ip->curve.segment[seg_no];
switch (*lng) {
case CURVE_LSEG_MAGIC:
@@ -1516,8 +1516,8 @@
ep->ext_nbytes += (bseg->degree + 1) * SIZEOF_NETWORK_LONG;
break;
default:
- bu_log("rt_sketch_export5: unsupported segment type (x%x)\n", *lng);
- bu_bomb("rt_sketch_export5: unsupported segment type\n");
+ bu_log("rt_sketch_export5: unsupported segement type (x%x)\n", *lng);
+ bu_bomb("rt_sketch_export5: unsupported segement type\n");
}
}
ep->ext_buf = (genptr_t)bu_malloc(ep->ext_nbytes, "sketch external");
@@ -1557,7 +1557,7 @@
uint32_t *lng;
fastf_t tmp_fastf;
- /* write segment type ID, and segment parameters */
+ /* write segment type ID, and segement parameters */
lng = (uint32_t *)sketch_ip->curve.segment[seg_no];
switch (*lng) {
case CURVE_LSEG_MAGIC:
@@ -2423,7 +2423,7 @@
if ((ret=get_tcl_curve(brlcad_interp, crv, tmp)) != TCL_OK)
return ret;
- } else if (*argv[0] == 'V' && isdigit((int)*(argv[0]+1))) {
+ } else if (*argv[0] == 'V' && isdigit(*(argv[0]+1))) {
/* changing a specific vertex */
long vert_no;
fastf_t *new_vert;
Index: src/librt/primitives/sketch/sketch_brep.cpp
===================================================================
--- src/librt/primitives/sketch/sketch_brep.cpp (revision 53222)
+++ src/librt/primitives/sketch/sketch_brep.cpp (working copy)
@@ -19,7 +19,7 @@
*/
/** @file sketch_brep.cpp
*
- * Convert a sketch to b-rep form (does not create a solid brep)
+ * Convert a sketch to b-rep form (does not creat a solid brep)
*
*/
Index: src/librt/primitives/nmg/nmg_ck.c
===================================================================
--- src/librt/primitives/nmg/nmg_ck.c (revision 53222)
+++ src/librt/primitives/nmg/nmg_ck.c (working copy)
@@ -345,7 +345,7 @@
case OT_SAME : break;
case OT_OPPOSITE: break;
case OT_UNSPEC : break;
- default : bu_bomb("nmg_veu() unknown loopuse orientation\n");
+ default : bu_bomb("nmg_veu() unknown loopuse orintation\n");
break;
}
@@ -431,7 +431,7 @@
case OT_BOOLPLACE: break;
default:
bu_log("lu=x%x, orientation=%d\n", lu, lu->orientation);
- bu_bomb("nmg_vlu() unknown loopuse orientation\n");
+ bu_bomb("nmg_vlu() unknown loopuse orintation\n");
break;
}
if (lu->lumate_p->orientation != lu->orientation)
@@ -546,7 +546,7 @@
bu_bomb("nmg_vfu() faceuse of \"OPPOSITE\" orientation has mate that is not \"SAME\" orientation\n");
break;
case OT_UNSPEC : break;
- default : bu_bomb("nmg_vfu() unknown faceuse orientation\n"); break;
+ default : bu_bomb("nmg_vfu() unknown faceuse orintation\n"); break;
}
NMG_CK_FACE(fu->f_p);
@@ -753,7 +753,7 @@
}
if (*eu->eumate_p->up.magic_p != *eu->up.magic_p) {
- bu_strlcat(errstr, "nmg_ck_eu() eumate has different kind of parent\n", len);
+ bu_strlcat(errstr, "nmg_ck_eu() eumate has differnt kind of parent\n", len);
bu_bomb(errstr);
}
if (*eu->up.magic_p == NMG_SHELL_MAGIC) {
@@ -1039,7 +1039,7 @@
/** N M G _ C K _ E G _ V E R T S
*
* Check if vertices from edgeuses using this edge geometry
- * actually lie on the edge geometry.
+ * actually lie on the edge geomatry.
*
* "eg" must be LSEG
* returns number of vertices not on edge line
@@ -1196,7 +1196,7 @@
* N M G _ C K _ L U E U
*
* check all the edgeuses of a loopuse to make sure these children
- * know who their parent really is.
+ * know who thier parent really is.
*/
void
nmg_ck_lueu(const struct loopuse *cklu, const char *s)
Index: src/librt/primitives/nmg/nmg_visit.c
===================================================================
--- src/librt/primitives/nmg/nmg_visit.c (revision 53222)
+++ src/librt/primitives/nmg/nmg_visit.c (working copy)
@@ -25,7 +25,7 @@
* visit all the data structures "below" a given structure.
*
* The caller provides a pointer to the structure to start at,
- * a table of "handlers" for each kind of structure,
+ * a table of "handlers" for each kind of strucuture,
* and a generic pointer for private state which will be sent along
* to the user's handlers.
* For non-leaf structures, there are two handlers, one called
Index: src/librt/primitives/nmg/nmg_tri.c
===================================================================
--- src/librt/primitives/nmg/nmg_tri.c (revision 53222)
+++ src/librt/primitives/nmg/nmg_tri.c (working copy)
@@ -461,7 +461,7 @@
"2D coordinate list");
/* we use the 0 index entry in the table as the head of the sorted