Revision: 64383
          http://sourceforge.net/p/brlcad/code/64383
Author:   starseeker
Date:     2015-03-12 20:59:56 +0000 (Thu, 12 Mar 2015)
Log Message:
-----------
Avoid exactly coplanar cylinder/cone faces when the whole cone/cylinder is 
being subtracted - will probably need more checks like this in the _csg 
routines, but start with the toplevel...

Modified Paths:
--------------
    brlcad/trunk/src/libbrep/shape_recognition_cone.cpp
    brlcad/trunk/src/libbrep/shape_recognition_cylinder.cpp

Modified: brlcad/trunk/src/libbrep/shape_recognition_cone.cpp
===================================================================
--- brlcad/trunk/src/libbrep/shape_recognition_cone.cpp 2015-03-12 20:45:15 UTC 
(rev 64382)
+++ brlcad/trunk/src/libbrep/shape_recognition_cone.cpp 2015-03-12 20:59:56 UTC 
(rev 64383)
@@ -140,10 +140,27 @@
 
     data->type = CONE;
 
-    ON_3dVector hvect(cone.ApexPoint() - cone.BasePoint());
-
     data->negative_shape = negative_cone(data, *conic_surfaces.begin(), 
cone_tol);
 
+
+    ON_3dPoint center_bottom = cone.BasePoint();
+    ON_3dPoint center_top = cone.ApexPoint();
+
+    // If we've got a negative cylinder, bump the center points out
+    // very slightly
+    if (data->negative_shape == -1) {
+       ON_3dVector cvector(center_top - center_bottom);
+       double len = cvector.Length();
+       cvector.Unitize();
+       cvector = cvector * (len * 0.001);
+
+       center_top = center_top + cvector;
+       center_bottom = center_bottom - cvector;
+    }
+
+    ON_3dVector hvect(center_top - center_bottom);
+
+
     data->params->bool_op = (data->negative_shape == -1) ? '-' : 'u';
     data->params->origin[0] = cone.BasePoint().x;
     data->params->origin[1] = cone.BasePoint().y;

Modified: brlcad/trunk/src/libbrep/shape_recognition_cylinder.cpp
===================================================================
--- brlcad/trunk/src/libbrep/shape_recognition_cylinder.cpp     2015-03-12 
20:45:15 UTC (rev 64382)
+++ brlcad/trunk/src/libbrep/shape_recognition_cylinder.cpp     2015-03-12 
20:59:56 UTC (rev 64383)
@@ -192,7 +192,8 @@
     struct csg_object_params * obj;
     BU_GET(obj, struct csg_object_params);
 
-    ON_3dVector hvect(set2_c.Center() - set1_c.Center());
+    ON_3dPoint center_bottom = set1_c.Center();
+    ON_3dPoint center_top = set2_c.Center();
 
     // Flag the cylinder according to the negative or positive status of the
     // cylinder surface.  Whether it is actually subtracted from the
@@ -200,6 +201,21 @@
     // is determined later.
     data->negative_shape = negative_cylinder(data, 
*cylindrical_surfaces.begin(), cyl_tol);
 
+    // If we've got a negative cylinder, bump the center points out very 
slightly
+    // to avoid problems with raytracing - without this, NIST 2 sometimes shows
+    // a half-circle of shading in what should be a subtraction.
+    if (data->negative_shape == -1) {
+       ON_3dVector cvector(center_top - center_bottom);
+       double len = cvector.Length();
+       cvector.Unitize();
+       cvector = cvector * (len * 0.001);
+
+       center_top = center_top + cvector;
+       center_bottom = center_bottom - cvector;
+    }
+
+    ON_3dVector hvect(center_top - center_bottom);
+
     data->params->bool_op = (data->negative_shape == -1) ? '-' : 'u';
     data->params->origin[0] = set1_c.Center().x;
     data->params->origin[1] = set1_c.Center().y;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to