BRL-CAD
librt_private.h
Go to the documentation of this file.
1 /* L I B R T _ P R I V A T E . H
2  * BRL-CAD
3  *
4  * Copyright (c) 2011-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @file librt_private.h
21  *
22  * These are declarations for functions that are for internal use by
23  * LIBRT but are not public API. NO CODE outside of LIBRT should use
24  * these functions.
25  *
26  * Non-public functions should NOT have an rt_*() or db_*() prefix.
27  * Consider using an _rt_, _db_, or other file-identifying prefix
28  * accordingly (e.g., ell_*() for functions defined in primitives/ell)
29  *
30  */
31 #ifndef LIBRT_LIBRT_PRIVATE_H
32 #define LIBRT_LIBRT_PRIVATE_H
33 
34 #include "common.h"
35 
36 #include "db.h"
37 #include "raytrace.h"
38 
39 /* approximation formula for the circumference of an ellipse */
40 #define ELL_CIRCUMFERENCE(a, b) M_PI * ((a) + (b)) * \
41  (1.0 + (3.0 * ((((a) - b))/((a) + (b))) * ((((a) - b))/((a) + (b))))) \
42  / (10.0 + sqrt(4.0 - 3.0 * ((((a) - b))/((a) + (b))) * ((((a) - b))/((a) + (b)))))
43 
45 
46 /* db_flip.c */
47 
48 /**
49  * function similar to ntohs() but always flips the bytes.
50  * used for v4 compatibility.
51  */
52 extern short flip_short(short s);
53 
54 /**
55  * function similar to ntohf() but always flips the types.
56  * used for v4 compatibility.
57  */
58 extern fastf_t flip_dbfloat(dbfloat_t d);
59 
60 /**
61  * function that flips a dbfloat_t[3] vector into fastf_t[3]
62  */
63 extern void flip_fastf_float(fastf_t *ff, const dbfloat_t *fp, int n, int flip);
64 
65 /**
66  * function that flips a dbfloat_t[16] matrix into fastf_t[16]
67  */
68 extern void flip_mat_dbmat(fastf_t *ff, const dbfloat_t *dbp, int flip);
69 
70 /**
71  * function that flips a fastf_t[16] matrix into dbfloat_t[16]
72  */
73 extern void flip_dbmat_mat(dbfloat_t *dbp, const fastf_t *ff);
74 
75 
76 /**
77  * return angle required for smallest side to fall within tolerances
78  * for ellipse. Smallest side is a side with an endpoint at (a, 0, 0)
79  * where a is the semi-major axis.
80  */
81 extern fastf_t ell_angle(fastf_t *p1, fastf_t a, fastf_t b, fastf_t dtol, fastf_t ntol);
82 
83 /**
84  * used by rt_shootray_bundle()
85  * FIXME: non-public API shouldn't be using rt_ prefix
86  */
87 extern const union cutter *rt_advance_to_next_cell(struct rt_shootray_status *ssp);
88 
89 /**
90  * used by rt_shootray_bundle()
91  * FIXME: non-public API shouldn't be using rt_ prefix
92  */
93 extern void rt_plot_cell(const union cutter *cutp, struct rt_shootray_status *ssp, struct bu_list *waiting_segs_hd, struct rt_i *rtip);
94 
95 
97  const struct rt_tess_tol *ttol,
98  fastf_t rel_to_abs);
99 
101  struct rt_db_internal *ip,
102  const struct rt_view_info *info);
103 
104 extern int approximate_parabolic_curve(
105  struct rt_pt_node *pts,
106  fastf_t p,
107  int num_new_points);
108 
110  struct rt_db_internal *ip,
111  const struct rt_view_info *info);
112 
114  struct rt_pt_node *pts,
115  fastf_t a,
116  fastf_t b,
117  int num_new_points);
118 
119 extern void
121  point_t result,
122  const vect_t center,
123  const vect_t axis_a,
124  const vect_t axis_b,
125  fastf_t radian);
126 
127 extern void plot_ellipse(
128  struct bu_list *vhead,
129  const vect_t t,
130  const vect_t a,
131  const vect_t b,
132  int num_points);
133 
134 
135 /**
136  * Evaluate a Bezier curve at a particular parameter value. Fill in
137  * control points for resulting sub-curves if "Left" and "Right" are
138  * non-null.
139  */
140 extern void bezier(point2d_t *V, int degree, double t, point2d_t *Left, point2d_t *Right, point2d_t eval_pt, point2d_t normal );
141 
142 /**
143  * Given an equation in Bernstein-Bezier form, find all of the roots
144  * in the interval [0, 1]. Return the number of roots found.
145  */
146 extern int bezier_roots(point2d_t *w, int degree, point2d_t **intercept, point2d_t **normal, point2d_t ray_start, point2d_t ray_dir, point2d_t ray_perp, int depth, fastf_t epsilon);
147 
148 /**
149  * subdivide a 2D bezier curve at t=0.5
150  */
151 extern struct bezier_2d_list *bezier_subdivide(struct bezier_2d_list *bezier_hd, int degree, fastf_t epsilon, int depth);
152 
153 
154 /* db_fullpath.c */
155 
156 /**
157  * Function to test whether a path has a cyclic entry in it.
158  *
159  * @param fp [i] Full path to test
160  * @param name [i] String to use when checking path (optional). If NULL, use the name of the current directory pointer in fp.
161  * @return 1 if the path is cyclic, 0 if it is not.
162  */
163 extern int cyclic_path(const struct db_full_path *fp, const char *name);
164 
165 
166 /* db_diff.c */
167 
168 /**
169  * Function to convert an ft_get list of parameters into an avs.
170  * @return 0 if the conversion succeeds, -1 if it does not.
171  */
172 extern int tcl_list_to_avs(const char *tcl_list, struct bu_attribute_value_set *avs, int offset);
173 
175 
176 #endif /* LIBRT_LIBRT_PRIVATE_H */
177 
178 /*
179  * Local Variables:
180  * tab-width: 8
181  * mode: C
182  * indent-tabs-mode: t
183  * c-file-style: "stroustrup"
184  * End:
185  * ex: shiftwidth=4 tabstop=8
186  */
fastf_t flip_dbfloat(dbfloat_t d)
Definition: db_flip.c:58
int approximate_hyperbolic_curve(struct rt_pt_node *pts, fastf_t a, fastf_t b, int num_new_points)
int bezier_roots(point2d_t *w, int degree, point2d_t **intercept, point2d_t **normal, point2d_t ray_start, point2d_t ray_dir, point2d_t ray_perp, int depth, fastf_t epsilon)
Definition: bezier.c:308
Definition: list.h:118
if lu s
Definition: nmg_mod.c:3860
Definition: clone.c:90
fastf_t ell_angle(fastf_t *p1, fastf_t a, fastf_t b, fastf_t dtol, fastf_t ntol)
Definition: ell.c:1788
Header file for the BRL-CAD common definitions.
void rt_plot_cell(const union cutter *cutp, struct rt_shootray_status *ssp, struct bu_list *waiting_segs_hd, struct rt_i *rtip)
const union cutter * rt_advance_to_next_cell(struct rt_shootray_status *ssp)
void flip_fastf_float(fastf_t *ff, const dbfloat_t *fp, int n, int flip)
Definition: db_flip.c:74
int tcl_list_to_avs(const char *tcl_list, struct bu_attribute_value_set *avs, int offset)
Definition: db_diff.c:187
#define __BEGIN_DECLS
Definition: common.h:73
fastf_t primitive_get_absolute_tolerance(const struct rt_tess_tol *ttol, fastf_t rel_to_abs)
void flip_mat_dbmat(fastf_t *ff, const dbfloat_t *dbp, int flip)
Definition: db_flip.c:107
fastf_t primitive_curve_count(struct rt_db_internal *ip, const struct rt_view_info *info)
short flip_short(short s)
Definition: db_flip.c:47
void flip_dbmat_mat(dbfloat_t *dbp, const fastf_t *ff)
Definition: db_flip.c:166
int cyclic_path(const struct db_full_path *fp, const char *name)
Definition: db_fullpath.c:598
void bezier(point2d_t *V, int degree, double t, point2d_t *Left, point2d_t *Right, point2d_t eval_pt, point2d_t normal)
Definition: bezier.c:192
void plot_ellipse(struct bu_list *vhead, const vect_t t, const vect_t a, const vect_t b, int num_points)
#define __END_DECLS
Definition: common.h:74
void ellipse_point_at_radian(point_t result, const vect_t center, const vect_t axis_a, const vect_t axis_b, fastf_t radian)
double fastf_t
Definition: defines.h:300
struct bezier_2d_list * bezier_subdivide(struct bezier_2d_list *bezier_hd, int degree, fastf_t epsilon, int depth)
Definition: bezier.c:405
int approximate_parabolic_curve(struct rt_pt_node *pts, fastf_t p, int num_new_points)
fastf_t primitive_diagonal_samples(struct rt_db_internal *ip, const struct rt_view_info *info)