Revision: 76249
http://sourceforge.net/p/brlcad/code/76249
Author: starseeker
Date: 2020-07-01 17:22:35 +0000 (Wed, 01 Jul 2020)
Log Message:
-----------
start shifting the polygon code
Modified Paths:
--------------
brlcad/trunk/include/dm/bview_util.h
brlcad/trunk/include/ged/view.h
brlcad/trunk/src/libdm/CMakeLists.txt
brlcad/trunk/src/libged/polyclip.cpp
brlcad/trunk/src/libtclcad/tclcad_obj.c
Added Paths:
-----------
brlcad/trunk/src/libdm/bview_polygon.cpp
Modified: brlcad/trunk/include/dm/bview_util.h
===================================================================
--- brlcad/trunk/include/dm/bview_util.h 2020-07-01 16:50:47 UTC (rev
76248)
+++ brlcad/trunk/include/dm/bview_util.h 2020-07-01 17:22:35 UTC (rev
76249)
@@ -37,6 +37,11 @@
DM_EXPORT void bview_update(struct bview *gvp);
+
+
+DM_EXPORT fastf_t find_polygon_area(bview_polygon *gpoly, fastf_t sf, matp_t
model2view, fastf_t size);
+
+
__END_DECLS
/** @} */
Modified: brlcad/trunk/include/ged/view.h
===================================================================
--- brlcad/trunk/include/ged/view.h 2020-07-01 16:50:47 UTC (rev 76248)
+++ brlcad/trunk/include/ged/view.h 2020-07-01 17:22:35 UTC (rev 76249)
@@ -152,7 +152,6 @@
GED_EXPORT extern bview_polygon *ged_clip_polygons(ClipType op, bview_polygons
*subj, bview_polygons *clip, fastf_t sf, matp_t model2view, matp_t view2model);
GED_EXPORT extern int ged_export_polygon(struct ged *gedp,
bview_data_polygon_state *gdpsp, size_t polygon_i, const char *sname);
GED_EXPORT extern bview_polygon *ged_import_polygon(struct ged *gedp, const
char *sname);
-GED_EXPORT extern fastf_t ged_find_polygon_area(bview_polygon *gpoly, fastf_t
sf, matp_t model2view, fastf_t size);
GED_EXPORT extern int ged_polygons_overlap(struct ged *gedp, bview_polygon
*polyA, bview_polygon *polyB);
GED_EXPORT extern void ged_polygon_fill_segments(struct ged *gedp,
bview_polygon *poly, vect2d_t vfilldir, fastf_t vfilldelta);
Modified: brlcad/trunk/src/libdm/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/libdm/CMakeLists.txt 2020-07-01 16:50:47 UTC (rev
76248)
+++ brlcad/trunk/src/libdm/CMakeLists.txt 2020-07-01 17:22:35 UTC (rev
76249)
@@ -11,7 +11,10 @@
)
# local includes
-set(DM_LOCAL_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
+set(DM_LOCAL_INCLUDE_DIRS
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${BRLCAD_SOURCE_DIR}/src/libbg
+ )
BRLCAD_LIB_INCLUDE_DIRS(dm DM_INCLUDE_DIRS DM_LOCAL_INCLUDE_DIRS)
@@ -58,6 +61,7 @@
adc.c
asize.c
axes.c
+ bview_polygon.cpp
bview_util.c
clip.c
dm-generic.c
Added: brlcad/trunk/src/libdm/bview_polygon.cpp
===================================================================
--- brlcad/trunk/src/libdm/bview_polygon.cpp (rev 0)
+++ brlcad/trunk/src/libdm/bview_polygon.cpp 2020-07-01 17:22:35 UTC (rev
76249)
@@ -0,0 +1,78 @@
+/* B V I E W _ P O L Y G O N . C P P
+ * BRL-CAD
+ *
+ * Copyright (c) 2020 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file bview_polygon.cpp
+ *
+ * Routines for dealing with bview polygons.
+ *
+ * TODO - these data types and routines really should be pushed
+ * down to libbg...
+ *
+ */
+
+#include "common.h"
+
+#include "clipper.hpp"
+
+#include "vmath.h"
+#include "bn/mat.h"
+#include "dm/defines.h"
+#include "dm/bview_util.h"
+
+fastf_t
+find_polygon_area(bview_polygon *gpoly, fastf_t sf, matp_t model2view, fastf_t
size)
+{
+ size_t j, k, n;
+ ClipperLib::Polygon poly;
+ fastf_t area = 0.0;
+
+ if (NEAR_ZERO(sf, SMALL_FASTF))
+ return 0.0;
+
+ for (j = 0; j < gpoly->gp_num_contours; ++j) {
+ n = gpoly->gp_contour[j].gpc_num_points;
+ poly.resize(n);
+ for (k = 0; k < n; k++) {
+ point_t vpoint;
+
+ /* Convert to view coordinates */
+ MAT4X3PNT(vpoint, model2view, gpoly->gp_contour[j].gpc_point[k]);
+
+ poly[k].X = (ClipperLib::long64)(vpoint[X] * sf);
+ poly[k].Y = (ClipperLib::long64)(vpoint[Y] * sf);
+ }
+
+ area += (fastf_t)ClipperLib::Area(poly);
+ }
+
+ sf = 1.0/(sf*sf) * size * size;
+
+ return (area * sf);
+}
+
+
+/*
+ * Local Variables:
+ * tab-width: 8
+ * mode: C
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
Property changes on: brlcad/trunk/src/libdm/bview_polygon.cpp
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: brlcad/trunk/src/libged/polyclip.cpp
===================================================================
--- brlcad/trunk/src/libged/polyclip.cpp 2020-07-01 16:50:47 UTC (rev
76248)
+++ brlcad/trunk/src/libged/polyclip.cpp 2020-07-01 17:22:35 UTC (rev
76249)
@@ -31,6 +31,7 @@
#include "clipper.hpp"
#include "bu/sort.h"
+#include "dm/bview_util.h"
#include "ged.h"
@@ -473,39 +474,6 @@
return gpp;
}
-
-fastf_t
-ged_find_polygon_area(bview_polygon *gpoly, fastf_t sf, matp_t model2view,
fastf_t size)
-{
- size_t j, k, n;
- ClipperLib::Polygon poly;
- fastf_t area = 0.0;
-
- if (NEAR_ZERO(sf, SMALL_FASTF))
- return 0.0;
-
- for (j = 0; j < gpoly->gp_num_contours; ++j) {
- n = gpoly->gp_contour[j].gpc_num_points;
- poly.resize(n);
- for (k = 0; k < n; k++) {
- point_t vpoint;
-
- /* Convert to view coordinates */
- MAT4X3PNT(vpoint, model2view, gpoly->gp_contour[j].gpc_point[k]);
-
- poly[k].X = (ClipperLib::long64)(vpoint[X] * sf);
- poly[k].Y = (ClipperLib::long64)(vpoint[Y] * sf);
- }
-
- area += (fastf_t)ClipperLib::Area(poly);
- }
-
- sf = 1.0/(sf*sf) * size * size;
-
- return (area * sf);
-}
-
-
typedef struct {
size_t pc_num_points;
point2d_t *pc_point;
Modified: brlcad/trunk/src/libtclcad/tclcad_obj.c
===================================================================
--- brlcad/trunk/src/libtclcad/tclcad_obj.c 2020-07-01 16:50:47 UTC (rev
76248)
+++ brlcad/trunk/src/libtclcad/tclcad_obj.c 2020-07-01 17:22:35 UTC (rev
76249)
@@ -62,7 +62,7 @@
#include "rt/solid.h"
#include "dm.h"
-#include "dm/bview.h"
+#include "dm/bview_util.h"
#include "icv/io.h"
#include "icv/ops.h"
@@ -4502,7 +4502,7 @@
i >= gdpsp->gdps_polygons.gp_num_polygons)
goto bad;
- area = ged_find_polygon_area(&gdpsp->gdps_polygons.gp_polygon[i],
CLIPPER_MAX,
+ area = find_polygon_area(&gdpsp->gdps_polygons.gp_polygon[i],
CLIPPER_MAX,
gdpsp->gdps_model2view, gdpsp->gdps_scale);
bu_vls_printf(gedp->ged_result_str, "%lf", area);
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