Revision: 73825
http://sourceforge.net/p/brlcad/code/73825
Author: starseeker
Date: 2019-09-04 18:42:32 +0000 (Wed, 04 Sep 2019)
Log Message:
-----------
Restore vlist and triangle plotting using new setup.
Modified Paths:
--------------
brlcad/trunk/include/brep/cdt.h
brlcad/trunk/src/libbrep/cdt.cpp
brlcad/trunk/src/libbrep/cdt2.cpp
brlcad/trunk/src/libbrep/cdt_mesh.cpp
brlcad/trunk/src/libbrep/cdt_mesh.h
brlcad/trunk/src/libbrep/cdt_surf2.cpp
brlcad/trunk/src/libbrep/cdt_util.cpp
Modified: brlcad/trunk/include/brep/cdt.h
===================================================================
--- brlcad/trunk/include/brep/cdt.h 2019-09-04 01:39:46 UTC (rev 73824)
+++ brlcad/trunk/include/brep/cdt.h 2019-09-04 18:42:32 UTC (rev 73825)
@@ -92,7 +92,7 @@
struct bu_list *vlfree,
struct bu_color *c,
int mode,
- const struct ON_Brep_CDT_State *s);
+ struct ON_Brep_CDT_State *s);
#if 0
/* Given two or more triangulation states, refine them to clear any face
Modified: brlcad/trunk/src/libbrep/cdt.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt.cpp 2019-09-04 01:39:46 UTC (rev 73824)
+++ brlcad/trunk/src/libbrep/cdt.cpp 2019-09-04 18:42:32 UTC (rev 73825)
@@ -132,30 +132,48 @@
// Now, the hard part - create local subsets, remesh them, and replace the
original
// triangles with the new ones.
-
-#if 0
- f->fmesh.set_brep_data(s_cdt->brep->m_F[fmesh->f_id].m_bRev,
s_cdt->edge_pnts, &f->s_cdt->fedges, f->singularities, f->on3_to_norm_map);
- f->fmesh.f_id = f->ind;
- f->fmesh.build(f->tris, f->p2t_to_on3_map);
-
- ret = (f->fmesh.repair()) ? 1 : -1;
- if (ret == -1) {
- bu_log("Face %d: triangulation FAILED!\n", f->ind);
- return -1;
+ if (!fmesh->repair()) {
+ bu_log("Face %d: repair FAILED!\n", fmesh->f_id);
+ return false;
}
- ret = (f->fmesh.valid()) ? 1 : -1;
- if (ret > 0) {
- bu_log("Face %d: successful triangulation after %d passes\n", f->ind,
cnt);
+ if (fmesh->valid()) {
+ bu_log("Face %d: successful triangulation after %d passes\n",
fmesh->f_id, cnt);
} else {
- bu_log("Face %d: triangulation produced invalid mesh!\n", f->ind);
+ bu_log("Face %d: triangulation produced invalid mesh!\n", fmesh->f_id);
}
- return ret;
-#endif
-
return true;
}
+void
+loop_edges(cdt_mesh::cdt_mesh_t *fmesh, cdt_mesh::cpolygon_t *loop)
+{
+ size_t vcnt = 1;
+ cdt_mesh::cpolyedge_t *pe = (*loop->poly.begin());
+ cdt_mesh::cpolyedge_t *first = pe;
+ cdt_mesh::cpolyedge_t *next = pe->next;
+
+ long p1_ind = fmesh->p2ind[fmesh->pnts[fmesh->p2d3d[loop->p2o[pe->v[0]]]]];
+ long p2_ind = fmesh->p2ind[fmesh->pnts[fmesh->p2d3d[loop->p2o[pe->v[1]]]]];
+ fmesh->ep.insert(p1_ind);
+ fmesh->ep.insert(p2_ind);
+ fmesh->brep_edges.insert(cdt_mesh::uedge_t(p1_ind, p2_ind));
+
+ while (first != next) {
+ vcnt++;
+ p1_ind = fmesh->p2ind[fmesh->pnts[fmesh->p2d3d[loop->p2o[next->v[0]]]]];
+ p2_ind = fmesh->p2ind[fmesh->pnts[fmesh->p2d3d[loop->p2o[next->v[1]]]]];
+ fmesh->ep.insert(p1_ind);
+ fmesh->ep.insert(p2_ind);
+ fmesh->brep_edges.insert(cdt_mesh::uedge_t(p1_ind, p2_ind));
+ next = next->next;
+ if (vcnt > loop->poly.size()) {
+ std::cerr << "infinite loop when reading loop edges\n";
+ return;
+ }
+ }
+}
+
static bool
do_triangulation(struct ON_Brep_CDT_State *s_cdt, int fi)
{
@@ -192,6 +210,8 @@
GetInteriorPoints(s_cdt, face.m_face_index);
cdt_mesh::cdt_mesh_t *fmesh = &s_cdt->fmeshes[face.m_face_index];
+ fmesh->f_id = face.m_face_index;
+ fmesh->m_bRev = face.m_bRev;
if (fmesh->cdt()) {
struct bu_vls fname = BU_VLS_INIT_ZERO;
bu_vls_sprintf(&fname, "%d-tris.plot3", face.m_face_index);
@@ -203,6 +223,22 @@
return false;
}
+ // List singularities
+ for (size_t i = 0; i < fmesh->pnts.size(); i++) {
+ ON_3dPoint *p3d = fmesh->pnts[i];
+ if (s_cdt->singular_vert_to_norms->find(p3d) !=
s_cdt->singular_vert_to_norms->end()) {
+ fmesh->sv.insert(fmesh->p2ind[p3d]);
+ }
+ }
+
+ // List edges
+ loop_edges(fmesh, &fmesh->outer_loop);
+ std::map<int, cdt_mesh::cpolygon_t*>::iterator i_it;
+ for (i_it = fmesh->inner_loops.begin(); i_it != fmesh->inner_loops.end();
i_it++) {
+ loop_edges(fmesh, i_it->second);
+ }
+ fmesh->boundary_edges_update();
+
/* The libbg triangulation is not guaranteed to have all the properties
* we want out of the box - trigger a series of checks */
return refine_triangulation(s_cdt, fmesh, 0, 0);
Modified: brlcad/trunk/src/libbrep/cdt2.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt2.cpp 2019-09-04 01:39:46 UTC (rev 73824)
+++ brlcad/trunk/src/libbrep/cdt2.cpp 2019-09-04 18:42:32 UTC (rev 73825)
@@ -1458,49 +1458,6 @@
plot_rtree_3d(s_cdt->edge_segs_3d[index], bu_vls_cstr(&fname));
}
-#if 0
- for (int index = 0; index < brep->m_F.Count(); index++) {
- ON_BrepFace &face = s_cdt->brep->m_F[index];
- int loop_cnt = face.LoopCount();
- double min_edge_seg_len = DBL_MAX;
- double max_edge_seg_len = 0;
- for (int li = 0; li < loop_cnt; li++) {
- const ON_BrepLoop *loop = face.Loop(li);
- for (int lti = 0; lti < loop->TrimCount(); lti++) {
- ON_BrepTrim *trim = loop->Trim(lti);
- ON_BrepEdge *edge = trim->Edge();
- if (!edge) continue;
- const ON_Curve* crv = edge->EdgeCurveOf();
- if (!crv) continue;
- std::set<cdt_mesh::bedge_seg_t *> &epsegs =
s_cdt->e2polysegs[edge->m_edge_index];
- if (!epsegs.size()) continue;
- std::set<cdt_mesh::bedge_seg_t *>::iterator e_it;
- for (e_it = epsegs.begin(); e_it != epsegs.end(); e_it++) {
- cdt_mesh::bedge_seg_t *b = *e_it;
- double seg_dist = b->e_start->DistanceTo(*b->e_end);
- min_edge_seg_len = (min_edge_seg_len > seg_dist) ? seg_dist
: min_edge_seg_len;
- max_edge_seg_len = (max_edge_seg_len < seg_dist) ? seg_dist
: max_edge_seg_len;
- }
- }
- }
- (*s_cdt->min_edge_seg_len)[index] = min_edge_seg_len;
- (*s_cdt->max_edge_seg_len)[index] = max_edge_seg_len;
-
- GetInteriorPoints(s_cdt, index);
- }
-
- for (int face_index = 0; face_index < brep->m_F.Count(); face_index++) {
- cdt_mesh::cdt_mesh_t *fmesh = &s_cdt->fmeshes[face_index];
- fmesh->cdt();
- struct bu_vls fname = BU_VLS_INIT_ZERO;
- bu_vls_sprintf(&fname, "%d-tris.plot3", face_index);
- fmesh->tris_plot(bu_vls_cstr(&fname));
- bu_vls_sprintf(&fname, "%d-tris_2d.plot3", face_index);
- fmesh->tris_plot_2d(bu_vls_cstr(&fname));
- bu_vls_free(&fname);
- }
-#endif
-
return 0;
}
Modified: brlcad/trunk/src/libbrep/cdt_mesh.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_mesh.cpp 2019-09-04 01:39:46 UTC (rev
73824)
+++ brlcad/trunk/src/libbrep/cdt_mesh.cpp 2019-09-04 18:42:32 UTC (rev
73825)
@@ -1477,13 +1477,12 @@
std::set<ON_3dPoint *> *e,
std::set<std::pair<ON_3dPoint *, ON_3dPoint *>> *original_b_edges,
std::set<ON_3dPoint *> *s,
- std::map<ON_3dPoint *, ON_3dPoint *> *n)
+ std::map<ON_3dPoint *, ON_3dPoint *> *UNUSED(n))
{
this->m_bRev = brev;
this->edge_pnts = e;
this->b_edges = original_b_edges;
this->singularities = s;
- this->normalmap = n;
}
std::set<uedge_t>
@@ -1603,19 +1602,9 @@
}
}
- // Populate normals
- std::set<ON_3dPoint *> uniq_n3d;
- std::map<ON_3dPoint *, ON_3dPoint *>::iterator n_it;
- for (n_it = normalmap->begin(); n_it != normalmap->end(); n_it++) {
- uniq_n3d.insert(n_it->second);
- }
- for (u_it = uniq_n3d.begin(); u_it != uniq_n3d.end(); u_it++) {
- this->normals.push_back(*u_it);
- this->n2ind[*u_it] = this->normals.size() - 1;
- }
- for (u_it = uniq_p3d.begin(); u_it != uniq_p3d.end(); u_it++) {
- nmap[p2ind[*u_it]] = n2ind[(*normalmap)[*u_it]];
- }
+ //for (u_it = uniq_p3d.begin(); u_it != uniq_p3d.end(); u_it++) {
+// nmap[p2ind[*u_it]] = n2ind[(*normalmap)[*u_it]];
+ // }
// From the triangles, populate the containers
for (s_it = cdttri->begin(); s_it != cdttri->end(); s_it++) {
@@ -2376,6 +2365,13 @@
tri3d.v[0] = p2ind[pnts[p2d3d[tri2d.v[0]]]];
tri3d.v[1] = p2ind[pnts[p2d3d[tri2d.v[1]]]];
tri3d.v[2] = p2ind[pnts[p2d3d[tri2d.v[2]]]];
+
+ if (m_bRev) {
+ long tmp = tri3d.v[1];
+ tri3d.v[1] = tri3d.v[2];
+ tri3d.v[2] = tmp;
+ }
+
tri_add(tri3d);
}
@@ -2918,7 +2914,6 @@
edge_pnts = NULL;
b_edges = NULL;
singularities = NULL;
- normalmap = NULL;
brep_edges.clear();
ep.clear();
Modified: brlcad/trunk/src/libbrep/cdt_mesh.h
===================================================================
--- brlcad/trunk/src/libbrep/cdt_mesh.h 2019-09-04 01:39:46 UTC (rev 73824)
+++ brlcad/trunk/src/libbrep/cdt_mesh.h 2019-09-04 18:42:32 UTC (rev 73825)
@@ -423,6 +423,7 @@
/* Mesh data set accessors */
std::set<uedge_t> get_boundary_edges();
+ void boundary_edges_update();
void update_problem_edges();
std::vector<triangle_t> face_neighbors(const triangle_t &f);
std::vector<triangle_t> vertex_face_neighbors(long vind);
@@ -464,8 +465,13 @@
std::map<ON_3dPoint *, long> n2ind;
std::map<long, long> nmap;
std::map<uedge_t, std::set<triangle_t>> uedges2tris;
- std::map<ON_3dPoint *, ON_3dPoint *> *normalmap;
+ // cdt_mesh index versions of Brep data
+ std::set<uedge_t> brep_edges;
+ std::set<long> ep; // Brep edge point vertex indices
+ std::set<long> sv; // Singularity vertex indices
+ bool m_bRev;
+
private:
/* Data containers */
std::map<long, std::set<edge_t>> v2edges;
@@ -477,16 +483,9 @@
std::set<std::pair<ON_3dPoint *, ON_3dPoint *>> *b_edges;
std::set<ON_3dPoint *> *singularities;
- // cdt_mesh index versions of Brep data
- std::set<uedge_t> brep_edges;
- std::set<long> ep; // Brep edge point vertex indices
- std::set<long> sv; // Singularity vertex indices
- bool m_bRev;
-
// Boundary edge information
std::set<uedge_t> boundary_edges;
bool boundary_edges_stale;
- void boundary_edges_update();
std::set<uedge_t> problem_edges;
edge_t find_boundary_oriented_edge(uedge_t &ue);
Modified: brlcad/trunk/src/libbrep/cdt_surf2.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_surf2.cpp 2019-09-04 01:39:46 UTC (rev
73824)
+++ brlcad/trunk/src/libbrep/cdt_surf2.cpp 2019-09-04 18:42:32 UTC (rev
73825)
@@ -907,7 +907,7 @@
nq = tq;
// Let the counter know we're going deeper
split_depth++;
- std::cout << "split_depth: " << split_depth << "\n";
+ //std::cout << "split_depth: " << split_depth << "\n";
}
}
Modified: brlcad/trunk/src/libbrep/cdt_util.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_util.cpp 2019-09-04 01:39:46 UTC (rev
73824)
+++ brlcad/trunk/src/libbrep/cdt_util.cpp 2019-09-04 18:42:32 UTC (rev
73825)
@@ -783,7 +783,7 @@
struct bu_list *vlfree,
int face_index,
int mode,
- const struct ON_Brep_CDT_State *s)
+ struct ON_Brep_CDT_State *s)
{
point_t pt[3] = {VINIT_ZERO, VINIT_ZERO, VINIT_ZERO};
vect_t nv[3] = {VINIT_ZERO, VINIT_ZERO, VINIT_ZERO};
@@ -792,10 +792,9 @@
point_t pt2 = VINIT_ZERO;
#endif
- struct ON_Brep_CDT_Face_State *f = (*s->faces)[face_index];
+ cdt_mesh::cdt_mesh_t *fmesh = &(s->fmeshes[face_index]);
std::set<cdt_mesh::triangle_t>::iterator tr_it;
- std::set<cdt_mesh::triangle_t> tris = f->fmesh.tris;
- std::map<ON_3dPoint *, ON_3dPoint *> *normalmap = f->on3_to_norm_map;
+ std::set<cdt_mesh::triangle_t> tris = fmesh->tris;
switch (mode) {
case 0:
@@ -802,13 +801,13 @@
// 3D shaded triangles
for (tr_it = tris.begin(); tr_it != tris.end(); tr_it++) {
for (size_t j = 0; j < 3; j++) {
- ON_3dPoint *p3d = f->fmesh.pnts[(*tr_it).v[j]];
+ ON_3dPoint *p3d = fmesh->pnts[(*tr_it).v[j]];
ON_3dPoint *onorm = NULL;
- if (f->s_cdt->singular_vert_to_norms->find(p3d) !=
f->s_cdt->singular_vert_to_norms->end()) {
+ if (s->singular_vert_to_norms->find(p3d) !=
s->singular_vert_to_norms->end()) {
// Use calculated normal for singularity points
- onorm = (*f->s_cdt->singular_vert_to_norms)[p3d];
+ onorm = (*s->singular_vert_to_norms)[p3d];
} else {
- onorm = (*normalmap)[p3d];
+ onorm = fmesh->normals[fmesh->nmap[(*tr_it).v[j]]];
}
VSET(pt[j], p3d->x, p3d->y, p3d->z);
VSET(nv[j], onorm->x, onorm->y, onorm->z);
@@ -829,7 +828,7 @@
// 3D wireframe
for (tr_it = tris.begin(); tr_it != tris.end(); tr_it++) {
for (size_t j = 0; j < 3; j++) {
- ON_3dPoint *p3d = f->fmesh.pnts[(*tr_it).v[j]];
+ ON_3dPoint *p3d = fmesh->pnts[(*tr_it).v[j]];
VSET(pt[j], p3d->x, p3d->y, p3d->z);
}
//tri one
@@ -877,7 +876,7 @@
struct bu_list *vlfree,
struct bu_color *c,
int mode,
- const struct ON_Brep_CDT_State *s)
+ struct ON_Brep_CDT_State *s)
{
int r, g, b;
struct bu_list *vhead = NULL;
@@ -900,7 +899,7 @@
}
for (int i = 0; i < s->brep->m_F.Count(); i++) {
- if ((*s->faces)[i] && (*s->faces)[i]->tris->size()) {
+ if (s->fmeshes[i].tris.size()) {
(void)ON_Brep_CDT_VList_Face(vhead, vlfree, i, mode, s);
}
}
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