Revision: 76322
http://sourceforge.net/p/brlcad/code/76322
Author: starseeker
Date: 2020-07-14 14:35:53 +0000 (Tue, 14 Jul 2020)
Log Message:
-----------
add 3d plot for polygons
Modified Paths:
--------------
brlcad/trunk/include/bg/polygon.h
brlcad/trunk/include/bg/polygon_types.h
brlcad/trunk/src/libbg/polygon.c
Modified: brlcad/trunk/include/bg/polygon.h
===================================================================
--- brlcad/trunk/include/bg/polygon.h 2020-07-14 14:08:18 UTC (rev 76321)
+++ brlcad/trunk/include/bg/polygon.h 2020-07-14 14:35:53 UTC (rev 76322)
@@ -60,6 +60,7 @@
fastf_t iscale
);
+/* model2view and view2model may be NULL, if the polygons are coplanar */
BG_EXPORT struct bg_polygon *
bg_clip_polygon(
bg_clip_t op,
@@ -70,6 +71,7 @@
matp_t view2model
);
+/* model2view and view2model may be NULL, if the polygons are coplanar */
BG_EXPORT struct bg_polygon *
bg_clip_polygons(
bg_clip_t op,
@@ -284,6 +286,7 @@
/* Debugging functions - do not use */
BG_EXPORT extern void bg_polygon_plot_2d(const char *filename, const point2d_t
*pnts, int npnts, int r, int g, int b);
+BG_EXPORT extern void bg_polygon_plot(const char *filename, const point_t
*pnts, int npnts, int r, int g, int b);
BG_EXPORT extern void bg_tri_plot_2d(const char *filename, const int *faces,
int num_faces, const point2d_t *pnts, int r, int g, int b);
__END_DECLS
Modified: brlcad/trunk/include/bg/polygon_types.h
===================================================================
--- brlcad/trunk/include/bg/polygon_types.h 2020-07-14 14:08:18 UTC (rev
76321)
+++ brlcad/trunk/include/bg/polygon_types.h 2020-07-14 14:35:53 UTC (rev
76322)
@@ -57,6 +57,8 @@
int gp_line_style;
};
+#define BG_POLYGON_NULL {0, NULL, NULL, {0, 0, 0}, 0, 0}
+
struct bg_polygons {
size_t num_polygons;
struct bg_polygon *polygon;
Modified: brlcad/trunk/src/libbg/polygon.c
===================================================================
--- brlcad/trunk/src/libbg/polygon.c 2020-07-14 14:08:18 UTC (rev 76321)
+++ brlcad/trunk/src/libbg/polygon.c 2020-07-14 14:35:53 UTC (rev 76322)
@@ -247,6 +247,27 @@
fclose(plot_file);
}
+void
+bg_polygon_plot(const char *filename, const point_t *pnts, int npnts, int r,
int g, int b)
+{
+ point_t bnp;
+ FILE* plot_file = fopen(filename, "w");
+ pl_color(plot_file, r, g, b);
+
+ VSET(bnp, pnts[0][X], pnts[0][Y], 0);
+ pdv_3move(plot_file, bnp);
+
+ for (int i = 1; i < npnts; i++) {
+ VSET(bnp, pnts[i][X], pnts[i][Y], pnts[i][Z]);
+ pdv_3cont(plot_file, bnp);
+ }
+
+ VSET(bnp, pnts[0][X], pnts[0][Y], pnts[0][Z]);
+ pdv_3cont(plot_file, bnp);
+
+ fclose(plot_file);
+}
+
/*
* Local Variables:
* mode: C
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits