Revision: 73056
          http://sourceforge.net/p/brlcad/code/73056
Author:   starseeker
Date:     2019-05-13 16:10:40 +0000 (Mon, 13 May 2019)
Log Message:
-----------
Add extern and export pieces for MSVC, switch api to hiding C++ types

Modified Paths:
--------------
    brlcad/trunk/include/brep/cdt.h
    brlcad/trunk/src/libbrep/cdt.cpp
    brlcad/trunk/src/libged/shape_recognition.cpp
    brlcad/trunk/src/librt/primitives/brep/brep.cpp
    brlcad/trunk/src/librt/primitives/brep/brep_debug.cpp

Modified: brlcad/trunk/include/brep/cdt.h
===================================================================
--- brlcad/trunk/include/brep/cdt.h     2019-05-13 15:27:11 UTC (rev 73055)
+++ brlcad/trunk/include/brep/cdt.h     2019-05-13 16:10:40 UTC (rev 73056)
@@ -35,98 +35,102 @@
 
 __BEGIN_DECLS
 
-#ifdef __cplusplus
-extern "C++" {
+/* Container that holds the state of a triangulation */
+struct ON_Brep_CDT_State;
 
-    /* Container that holds the state of a triangulation */
-    struct ON_Brep_CDT_State;
+/* Create and initialize a CDT state with default tolerances.  bv
+ * must be a pointer to an ON_Brep object. */
+struct ON_Brep_CDT_State *ON_Brep_CDT_Create(void *bv);
 
-    /* Create and initialize a CDT state with default tolerances. */
-    struct ON_Brep_CDT_State *ON_Brep_CDT_Create(ON_Brep *brep);
+/* Destroy a CDT state */
+void ON_Brep_CDT_Destroy(struct ON_Brep_CDT_State *s);
 
-    /* Destroy a CDT state */
-    void ON_Brep_CDT_Destroy(struct ON_Brep_CDT_State *s);
+struct ON_Brep_CDT_Tols {
+    fastf_t abs;
+    fastf_t rel;
+    fastf_t norm;
+    fastf_t dist;
+};
+/* Set/get the CDT tolerances. */
+extern BREP_EXPORT void
+ON_Brep_CDT_Tol_Set(struct ON_Brep_CDT_State *s, const struct ON_Brep_CDT_Tols 
*t);
+extern BREP_EXPORT void
+ON_Brep_CDT_Tol_Get(struct ON_Brep_CDT_Tols *t, const struct ON_Brep_CDT_State 
*s);
 
-    struct ON_Brep_CDT_Tols {
-       fastf_t abs;
-       fastf_t rel;
-       fastf_t norm;
-       fastf_t dist;
-    };
-    /* Set/get the CDT tolerances. */
-    void ON_Brep_CDT_Tol_Set(struct ON_Brep_CDT_State *s, const struct 
ON_Brep_CDT_Tols *t);
-    void ON_Brep_CDT_Tol_Get(struct ON_Brep_CDT_Tols *t, const struct 
ON_Brep_CDT_State *s);
+/* Return the ON_Brep associated with state s. */
+extern BREP_EXPORT void *
+ON_Brep_CDT_Brep(struct ON_Brep_CDT_State *s);
 
-    /* Return the ON_Brep associated with state s. */
-    ON_Brep *ON_Brep_CDT_brep(struct ON_Brep_CDT_State *s);
+/* Given a state, produce a triangulation.  Returns 0 if a solid, valid
+ * triangulation was produced, 1 if a triangulation was produced but it
+ * isn't solid, and -1 if no triangulation could be produced. If faces is
+ * non-null, the triangulation will only attempt to triangulate the
+ * specified face(s) and the return code will be the number of successfully
+ * triangulated faces.  If the CDT tolerances have been updated since the
+ * last Tessellate call, the old tessellation information will be replaced. */
+extern BREP_EXPORT int
+ON_Brep_CDT_Tessellate(struct ON_Brep_CDT_State *s, int face_cnt, int *faces);
 
-    /* Given a state, produce a triangulation.  Returns 0 if a solid, valid
-     * triangulation was produced, 1 if a triangulation was produced but it
-     * isn't solid, and -1 if no triangulation could be produced. If faces is
-     * non-null, the triangulation will only attempt to triangulate the
-     * specified face(s) and the return code will be the number of successfully
-     * triangulated faces.  If the CDT tolerances have been updated since the
-     * last Tessellate call, the old tessellation information will be 
replaced. */
-    int ON_Brep_CDT_Tessellate(struct ON_Brep_CDT_State *s, std::vector<int> 
*faces);
+/* Given a state, report the status of its triangulation. -3 indicates a
+ * failed attempt to tessellate, -2 indicates a non-solid tessellation is
+ * present after an attempt to tessellate all faces, -1 is a state which
+ * has had no tessellation attempt made, 0 indicates a solid, valid full
+ * brep tessellation is present, and >0 indicates that number of faces has
+ * been tessellated but not the full brep. */
+extern BREP_EXPORT int
+ON_Brep_CDT_Status(struct ON_Brep_CDT_State *s);
 
-    /* Given a state, report the status of its triangulation. -3 indicates a
-     * failed attempt to tessellate, -2 indicates a non-solid tessellation is
-     * present after an attempt to tessellate all faces, -1 is a state which
-     * has had no tessellation attempt made, 0 indicates a solid, valid full
-     * brep tessellation is present, and >0 indicates that number of faces has
-     * been tessellated but not the full brep. */
-    int ON_Brep_CDT_Status(struct ON_Brep_CDT_State *s);
+/* Construct a vlist plot from the tessellation.  Modes are:
+ *
+ * 0 - shaded 3D triangles
+ * 1 - 3D triangle wireframe
+ * 2 - 2D triangle wireframe (from parametric space)
+ *
+ * Returns 0 if vlist was successfully generated, else -1
+ */
+extern BREP_EXPORT int
+ON_Brep_CDT_VList(
+       struct bn_vlblock *vbp,
+       struct bu_list *vlfree,
+       struct bu_color *c,
+       int mode,
+       const struct ON_Brep_CDT_State *s);
 
-    /* Construct a vlist plot from the tessellation.  Modes are:
-     *
-     * 0 - shaded 3D triangles
-     * 1 - 3D triangle wireframe
-     * 2 - 2D triangle wireframe (from parametric space)
-     *
-     * Returns 0 if vlist was successfully generated, else -1
-     */
-    int ON_Brep_CDT_VList(
-           struct bn_vlblock *vbp,
-           struct bu_list *vlfree,
-           struct bu_color *c,
-           int mode,
-           const struct ON_Brep_CDT_State *s);
-
 #if 0
-    /* Given two or more triangulation states, refine them to clear any face
-     * overlaps introduced by the triangulation.  If any of the states are
-     * un-tessellated, first perform the tessellation indicated by the state
-     * settings and then proceed to resolve after all states have an initial
-     * tessellation.  Returns 0 if no changes were needed, the number of
-     * updated CDT states if changes were made, and -1 if one or more
-     * unresolvable overlaps were encountered.  Individual CDT states may
-     * subsequently be queried for other information about their specific
-     * states with other function calls - this function returns only the
-     * overall result. */
-    int ON_Brep_CDT_Ovlp_Resolve(struct ON_Brep_CDT_State **s_a, int s_cnt);
+/* Given two or more triangulation states, refine them to clear any face
+ * overlaps introduced by the triangulation.  If any of the states are
+ * un-tessellated, first perform the tessellation indicated by the state
+ * settings and then proceed to resolve after all states have an initial
+ * tessellation.  Returns 0 if no changes were needed, the number of
+ * updated CDT states if changes were made, and -1 if one or more
+ * unresolvable overlaps were encountered.  Individual CDT states may
+ * subsequently be queried for other information about their specific
+ * states with other function calls - this function returns only the
+ * overall result. */
+extern BREP_EXPORT int
+ON_Brep_CDT_Ovlp_Resolve(struct ON_Brep_CDT_State **s_a, int s_cnt);
 
-    /* Report the number of other tessellation states which manifest 
unresolvable
-     * overlaps with state s.  If the ovlps argument is non-null, populate with
-     * the problematic states.  If no resolve step was performed on s, return 
-1 */
-    int ON_Brep_CDT_UnResolvable_Ovlps(std::vector<struct ON_Brep_CDT_State *> 
*ovlps, struct ON_Brep_CDT_State *s);
+/* Report the number of other tessellation states which manifest unresolvable
+ * overlaps with state s.  If the ovlps argument is non-null, populate with
+ * the problematic states.  If no resolve step was performed on s, return -1 */
+extern BREP_EXPORT int
+ON_Brep_CDT_UnResolvable_Ovlps(std::vector<struct ON_Brep_CDT_State *> *ovlps, 
struct ON_Brep_CDT_State *s);
 #endif
 
-    /* Retrieve the face, vertex and normal information from a tessellation 
state
-     * in the form of integer and fastf_t arrays. */
-    int ON_Brep_CDT_Mesh(
-           int **faces, int *fcnt,
-           fastf_t **vertices, int *vcnt,
-           int **face_normals, int *fn_cnt,
-           fastf_t **normals, int *ncnt,
-           struct ON_Brep_CDT_State *s);
+/* Retrieve the face, vertex and normal information from a tessellation state
+ * in the form of integer and fastf_t arrays. */
+extern BREP_EXPORT int
+ON_Brep_CDT_Mesh(
+       int **faces, int *fcnt,
+       fastf_t **vertices, int *vcnt,
+       int **face_normals, int *fn_cnt,
+       fastf_t **normals, int *ncnt,
+       struct ON_Brep_CDT_State *s);
 
 
-} /* extern C++ */
 
 __END_DECLS
 
-#endif /* __cplusplus */
-
 /** @} */
 
 #endif  /* BREP_CDT_H */

Modified: brlcad/trunk/src/libbrep/cdt.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt.cpp    2019-05-13 15:27:11 UTC (rev 73055)
+++ brlcad/trunk/src/libbrep/cdt.cpp    2019-05-13 16:10:40 UTC (rev 73056)
@@ -2372,8 +2372,9 @@
 
 
 struct ON_Brep_CDT_State *
-ON_Brep_CDT_Create(ON_Brep *brep)
+ON_Brep_CDT_Create(void *bv)
 {
+    ON_Brep *brep = (ON_Brep *)bv;
     struct ON_Brep_CDT_State *cdt = new struct ON_Brep_CDT_State;
     cdt->brep = brep;
 
@@ -2457,10 +2458,10 @@
 }
 
 
-ON_Brep *
+void *
 ON_Brep_CDT_Brep(struct ON_Brep_CDT_State *s_cdt)
 {
-    return s_cdt->brep;
+    return (void *)s_cdt->brep;
 }
 
 void
@@ -2689,7 +2690,7 @@
 }
 
 int
-ON_Brep_CDT_Tessellate(struct ON_Brep_CDT_State *s_cdt, std::vector<int> 
*faces)
+ON_Brep_CDT_Tessellate(struct ON_Brep_CDT_State *s_cdt, int face_cnt, int 
*faces)
 {
 
     ON_wString wstr;
@@ -2829,7 +2830,7 @@
     int face_failures = 0;
     int face_successes = 0;
 
-    if (!faces) {
+    if ((face_cnt == 0) || !faces) {
 
        for (int face_index = 0; face_index < s_cdt->brep->m_F.Count(); 
face_index++) {
            ON_BrepFace &face = brep->m_F[face_index];
@@ -2842,9 +2843,9 @@
 
        }
     } else {
-       for (unsigned int i = 0; i < faces->size(); i++) {
-           if ((*faces)[i] < s_cdt->brep->m_F.Count()) {
-               ON_BrepFace &face = brep->m_F[(*faces)[i]];
+       for (int i = 0; i < face_cnt; i++) {
+           if (faces[i] < s_cdt->brep->m_F.Count()) {
+               ON_BrepFace &face = brep->m_F[faces[i]];
                if (ON_Brep_CDT_Face(s_cdt, &s_to_maxdist, face)) {
                    face_failures++;
                } else {

Modified: brlcad/trunk/src/libged/shape_recognition.cpp
===================================================================
--- brlcad/trunk/src/libged/shape_recognition.cpp       2019-05-13 15:27:11 UTC 
(rev 73055)
+++ brlcad/trunk/src/libged/shape_recognition.cpp       2019-05-13 16:10:40 UTC 
(rev 73056)
@@ -966,9 +966,9 @@
     cdttol.rel = ttol->rel;
     cdttol.norm = ttol->norm;
     cdttol.dist = tol->dist;
-    ON_Brep_CDT_State *s_cdt = ON_Brep_CDT_Create(bi->brep);
+    ON_Brep_CDT_State *s_cdt = ON_Brep_CDT_Create((void *)bi->brep);
     ON_Brep_CDT_Tol_Set(s_cdt, &cdttol);
-    ON_Brep_CDT_Tessellate(s_cdt, NULL);
+    ON_Brep_CDT_Tessellate(s_cdt, 0, NULL);
     ON_Brep_CDT_Mesh(&faces, &fcnt, &vertices, &vcnt, &face_normals, &fncnt, 
&normals, &ncnt, s_cdt);
     ON_Brep_CDT_Destroy(s_cdt);
 

Modified: brlcad/trunk/src/librt/primitives/brep/brep.cpp
===================================================================
--- brlcad/trunk/src/librt/primitives/brep/brep.cpp     2019-05-13 15:27:11 UTC 
(rev 73055)
+++ brlcad/trunk/src/librt/primitives/brep/brep.cpp     2019-05-13 16:10:40 UTC 
(rev 73056)
@@ -2655,9 +2655,9 @@
     cdttol.rel = ttol->rel;
     cdttol.norm = ttol->norm;
     cdttol.dist = tol->dist;
-    ON_Brep_CDT_State *s_cdt = ON_Brep_CDT_Create(bi->brep);
+    ON_Brep_CDT_State *s_cdt = ON_Brep_CDT_Create((void *)bi->brep);
     ON_Brep_CDT_Tol_Set(s_cdt, &cdttol);
-    if (ON_Brep_CDT_Tessellate(s_cdt, NULL)) {
+    if (ON_Brep_CDT_Tessellate(s_cdt, 0, NULL)) {
        // Couldn't get a solid mesh, we're done
        ON_Brep_CDT_Destroy(s_cdt);
        return -1;

Modified: brlcad/trunk/src/librt/primitives/brep/brep_debug.cpp
===================================================================
--- brlcad/trunk/src/librt/primitives/brep/brep_debug.cpp       2019-05-13 
15:27:11 UTC (rev 73055)
+++ brlcad/trunk/src/librt/primitives/brep/brep_debug.cpp       2019-05-13 
16:10:40 UTC (rev 73056)
@@ -3129,47 +3129,56 @@
                snprintf(commtag, 64, "_BC_FCDTN_");
                struct bu_color c;
                bu_color_from_str(&c, "255/255/0");
-               std::vector<int> faces;
+               int face_cnt = 0;
+               int *faces = (int *)bu_calloc(elements.size()+1, sizeof(int), 
"face array");
                std::set<int>::iterator f_it;
                for (f_it = elements.begin(); f_it != elements.end(); f_it++) {
-                   faces.push_back(*f_it);
+                   faces[face_cnt] = *f_it;
+                   face_cnt++;
                }
-               ON_Brep_CDT_State *s_cdt = ON_Brep_CDT_Create(bs->brep);
-               ON_Brep_CDT_Tessellate(s_cdt, &faces);
+               ON_Brep_CDT_State *s_cdt = ON_Brep_CDT_Create((void *)bs->brep);
+               ON_Brep_CDT_Tessellate(s_cdt, face_cnt, faces);
                ON_Brep_CDT_VList(vbp, &RTG.rtg_vlfree, &c, 0, s_cdt);
                ON_Brep_CDT_Destroy(s_cdt);
+               bu_free(faces, "free face array");
            } else if (BU_STR_EQUAL(part, "FCDTNw")) {
                snprintf(commtag, 64, "_BC_FCDT_");
                struct bu_color c;
                bu_color_from_str(&c, "255/255/0");
-               std::vector<int> faces;
+               int face_cnt = 0;
+               int *faces = (int *)bu_calloc(elements.size()+1, sizeof(int), 
"face array");
                std::set<int>::iterator f_it;
                for (f_it = elements.begin(); f_it != elements.end(); f_it++) {
-                   faces.push_back(*f_it);
+                   faces[face_cnt] = *f_it;
+                   face_cnt++;
                }
-               ON_Brep_CDT_State *s_cdt = ON_Brep_CDT_Create(bs->brep);
-               ON_Brep_CDT_Tessellate(s_cdt, &faces);
+               ON_Brep_CDT_State *s_cdt = ON_Brep_CDT_Create((void *)bs->brep);
+               ON_Brep_CDT_Tessellate(s_cdt, face_cnt, faces);
                ON_Brep_CDT_VList(vbp, &RTG.rtg_vlfree, &c, 1, s_cdt);
                ON_Brep_CDT_Destroy(s_cdt);
+               bu_free(faces, "free face array");
            } else if (BU_STR_EQUAL(part, "FCDTN2d")) {
                snprintf(commtag, 64, "_BC_FCDT_");
                struct bu_color c;
                bu_color_from_str(&c, "255/255/0");
-               std::vector<int> faces;
+               int face_cnt = 0;
+               int *faces = (int *)bu_calloc(elements.size()+1, sizeof(int), 
"face array");
                std::set<int>::iterator f_it;
                for (f_it = elements.begin(); f_it != elements.end(); f_it++) {
-                   faces.push_back(*f_it);
+                   faces[face_cnt] = *f_it;
+                   face_cnt++;
                }
-               ON_Brep_CDT_State *s_cdt = ON_Brep_CDT_Create(bs->brep);
-               ON_Brep_CDT_Tessellate(s_cdt, &faces);
+               ON_Brep_CDT_State *s_cdt = ON_Brep_CDT_Create((void *)bs->brep);
+               ON_Brep_CDT_Tessellate(s_cdt, face_cnt, faces);
                ON_Brep_CDT_VList(vbp, &RTG.rtg_vlfree, &c, 2, s_cdt);
                ON_Brep_CDT_Destroy(s_cdt);
+               bu_free(faces, "free face array");
            } else if (BU_STR_EQUAL(part, "CDT")) {
                snprintf(commtag, 64, "_BC_CDT_");
                struct bu_color c;
                bu_color_from_str(&c, "255/255/0");
-               ON_Brep_CDT_State *s_cdt = ON_Brep_CDT_Create(bs->brep);
-               ON_Brep_CDT_Tessellate(s_cdt, NULL);
+               ON_Brep_CDT_State *s_cdt = ON_Brep_CDT_Create((void *)bs->brep);
+               ON_Brep_CDT_Tessellate(s_cdt, 0, NULL);
                ON_Brep_CDT_VList(vbp, &RTG.rtg_vlfree, &c, 0, s_cdt);
                ON_Brep_CDT_Destroy(s_cdt);
            } else if (BU_STR_EQUAL(part, "FCDTw")) {

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

Reply via email to