Revision: 73841
          http://sourceforge.net/p/brlcad/code/73841
Author:   starseeker
Date:     2019-09-05 23:57:28 +0000 (Thu, 05 Sep 2019)
Log Message:
-----------
This works better for face 86 in NIST7-10 Solid1.s, but breaks a fair number of 
other faces...

Modified Paths:
--------------
    brlcad/trunk/src/libbrep/cdt.cpp
    brlcad/trunk/src/libbrep/cdt_mesh.cpp
    brlcad/trunk/src/libbrep/cdt_surf.cpp
    brlcad/trunk/src/libbrep/cdt_util.cpp

Modified: brlcad/trunk/src/libbrep/cdt.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt.cpp    2019-09-05 23:17:13 UTC (rev 73840)
+++ brlcad/trunk/src/libbrep/cdt.cpp    2019-09-05 23:57:28 UTC (rev 73841)
@@ -303,8 +303,18 @@
        // 3D points are globally unique, but normals are not - the same edge 
point may
        // have different normals from two faces at a sharp edge.  Calculate the
        // face normal for this point on this surface.
-       ON_3dPoint tmp1;
-       surface_EvNormal(trim->SurfaceOf(), cp.x, cp.y, tmp1, norm);
+       ON_Plane fplane;
+       const ON_Surface *s = trim->SurfaceOf();
+       if (s->IsPlanar(&fplane, BREP_PLANAR_TOL)) {
+           norm = fplane.Normal();
+       } else {
+           ON_3dPoint tmp1;
+           surface_EvNormal(trim->SurfaceOf(), cp.x, cp.y, tmp1, norm);
+       }
+       if (trim->Face()->m_bRev) {
+           norm = -1 * norm;
+       }
+       //std::cout << "Face " << trim->Face()->m_face_index << ", Loop " << 
trim->Loop()->m_loop_index << " norm: " << norm.x << "," << norm.y << "," << 
norm.z << "\n";
     }
     return norm;
 }
@@ -1328,9 +1338,7 @@
                            // have different normals from two faces at a sharp 
edge.  Calculate the
                            // face normal for this point on this surface.
                            norm = calc_trim_vnorm(*trim->Vertex(0), trim);
-                           if (face.m_bRev) {
-                               norm = -1 * norm;
-                           }
+                           //std::cout << "Face " << face.m_face_index << ", 
Loop " << loop->m_loop_index << ", Vert " << trim->Vertex(0)->m_vertex_index << 
" norm: " << norm.x << "," << norm.y << "," << norm.z << "\n";
                        } else {
                            // Surface sampling will need some information 
about singularities
                            s_cdt->strim_pnts[face_index][trim->m_trim_index] = 
op3d;
@@ -1365,9 +1373,7 @@
                            // have different normals from two faces at a sharp 
edge.  Calculate the
                            // face normal for this point on this surface.
                            norm = calc_trim_vnorm(*trim->Vertex(1), trim);
-                           if (face.m_bRev) {
-                               norm = -1 * norm;
-                           }
+                           //std::cout << "Face " << face.m_face_index << ", 
Loop " << loop->m_loop_index << ", Vert " << trim->Vertex(1)->m_vertex_index << 
" norm: " << norm.x << "," << norm.y << "," << norm.z << "\n";
                        } else {
                            // Surface sampling will need some information 
about singularities
                            s_cdt->strim_pnts[face_index][trim->m_trim_index] = 
cp3d;

Modified: brlcad/trunk/src/libbrep/cdt_mesh.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_mesh.cpp       2019-09-05 23:17:13 UTC (rev 
73840)
+++ brlcad/trunk/src/libbrep/cdt_mesh.cpp       2019-09-05 23:57:28 UTC (rev 
73841)
@@ -1581,6 +1581,9 @@
     ON_3dVector e2 = *p3 - *p1;
     ON_3dVector tdir = ON_CrossProduct(e1, e2);
     tdir.Unitize();
+    if (m_bRev) {
+       tdir = -1 * tdir;
+    }
     return tdir;
 }
 

Modified: brlcad/trunk/src/libbrep/cdt_surf.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_surf.cpp       2019-09-05 23:17:13 UTC (rev 
73840)
+++ brlcad/trunk/src/libbrep/cdt_surf.cpp       2019-09-05 23:57:28 UTC (rev 
73841)
@@ -435,8 +435,13 @@
        if (!surface_EvNormal(sinfo->s, n2dp.x, n2dp.y, p3d, norm)) {
            p3d = sinfo->s->PointAt(n2dp.x, n2dp.y);
        }
-       long f3ind = fmesh->add_point(new ON_3dPoint(p3d)); 
-       long fnind = fmesh->add_normal(new ON_3dPoint(norm)); 
+       if (fmesh->m_bRev) {
+           norm = -1 * norm;
+       }
+       //std::cout << "Face " << fmesh->f_id << " norm: " << norm.x << "," << 
norm.y << "," << norm.z << "\n";
+
+       long f3ind = fmesh->add_point(new ON_3dPoint(p3d));
+       long fnind = fmesh->add_normal(new ON_3dPoint(norm));
        fmesh->p2d3d[f_ind2d] = f3ind;
        fmesh->nmap[f3ind] = fnind;
     }

Modified: brlcad/trunk/src/libbrep/cdt_util.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_util.cpp       2019-09-05 23:17:13 UTC (rev 
73840)
+++ brlcad/trunk/src/libbrep/cdt_util.cpp       2019-09-05 23:57:28 UTC (rev 
73841)
@@ -479,9 +479,6 @@
                        onorm = *fmesh->normals[fmesh->nmap[(*tr_it).v[j]]];
                    }
                    VSET(pt[j], p3d->x, p3d->y, p3d->z);
-                   if (fmesh->m_bRev) {
-                       onorm = -1 * onorm;
-                   }
                    VSET(nv[j], onorm.x, onorm.y, onorm.z);
                }
                //tri one

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