Revision: 55635
          http://sourceforge.net/p/brlcad/code/55635
Author:   phoenixyjll
Date:     2013-06-03 13:34:52 +0000 (Mon, 03 Jun 2013)
Log Message:
-----------
Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the 
intersections.

Modified Paths:
--------------
    brlcad/trunk/include/brep.h
    brlcad/trunk/src/libbrep/intersect.cpp

Added Paths:
-----------
    brlcad/trunk/src/libbrep/px_event.cpp

Modified: brlcad/trunk/include/brep.h
===================================================================
--- brlcad/trunk/include/brep.h 2013-06-02 03:01:52 UTC (rev 55634)
+++ brlcad/trunk/include/brep.h 2013-06-03 13:34:52 UTC (rev 55635)
@@ -1784,6 +1784,177 @@
             const ON_Interval* surfaceB_udomain = 0,
             const ON_Interval* surfaceB_vdomain = 0);
 
+// The ON_PX_EVENT class is used to report point-point, point-curve
+// and point-surface intersection events.
+class ON_CLASS BREP_EXPORT ON_PX_EVENT
+{
+public:
+    // Default construction sets everything to zero.
+    ON_PX_EVENT();
+
+    /*
+      Description:
+       Compares point intersection events and sorts them in the 
+       canonical order.
+      Returns:
+       @untitled table
+       -1    this  < other
+        0    this == other
+       +1    this  > other
+      Remarks:
+       ON_PX_EVENT::Compare is used to sort intersection events into canonical
+       order.
+    */
+    static
+    int Compare(const ON_PX_EVENT* a, const ON_PX_EVENT* b);
+
+    /*
+      Description:
+       Check point intersection event values to make sure they are valid.
+      Parameters:
+       text_log - [in] If not null and an error is found, then a description
+                       of the error is printed to text_log.
+       intersection_tolerance - [in] 
+            0.0 or value used in intersection calculation.
+       pointA - [in] 
+            NULL or pointA passed to intersection calculation.
+       pointB - [in]
+            NULL or pointB passed to intersection calculation.
+       curveB - [in]
+            NULL or curveB passed to intersection calculation.
+       curveB_domain - [in]
+            NULL or curveB domain used in intersection calculation.
+       surfaceB - [in]
+            NULL or surfaceB passed to intersection calculation.
+       surfaceB_domain0 - [in]
+            NULL or surfaceB "u" domain used in intersection calculation.
+       surfaceB_domain1 - [in]
+            NULL or surfaceB "v" domain used in intersection calculation.
+      Returns:
+       True if event is valid.
+    */
+    bool IsValid(ON_TextLog* text_log,
+                double intersection_tolerance,
+                const class ON_3dPoint* pointA,
+                const class ON_3dPoint* pointB,
+                const class ON_Curve* curveB,
+                const class ON_Interval* curveB_domain,
+                const class ON_Surface* surfaceB,
+                const class ON_Interval* surfaceB_domain0,
+                const class ON_Interval* surfaceB_domain1) const;
+
+    void Dump(ON_TextLog& text_log) const;
+
+    enum TYPE { 
+       no_px_event =  0,
+       ppx_point   =  1, // point-point intersection
+       pcx_point   =  2, // point-curve intersection
+       psx_point   =  3, // point-surface intersection
+    };
+
+    TYPE m_type;
+
+    ON_3dPoint m_A;    // Point A in 3D space
+    ON_3dPoint m_B;    // Point B in 3D space
+
+    ON_2dPoint m_b;    // Point B in 2D space for the curve/surface
+                       // For a curve, m_b[1] == 0
+                       // For a point, m_b[0] == m_b[1] == 0
+
+    ON_3dPoint m_Mid;  // The mid-point of Point A and Point B
+    double m_radius;   // To trace the uncertainty area
+};
+
+/**
+ * An overload of ON_Intersect for point-point intersection.
+ *
+ * Description:
+ *   Intersect pointA with pointB.
+ *
+ * Parameters:
+ *   pointA - [in]
+ *
+ *   pointB - [in]
+ *
+ *   x - [out]
+ *     Intersection events are appended to this array.
+ *
+ *   tolerance - [in]
+ *     If the input intersection_tolerance <= 0.0, then 0.001 is used.
+ *
+ * Returns:
+ *    True for an intersection. False for no intersection.
+ */
+extern BREP_EXPORT bool
+ON_Intersect(const ON_3dPoint& pointA,
+            const ON_3dPoint& pointB,
+            ON_ClassArray<ON_PX_EVENT>& x,
+            double tolerance = 0.0);
+
+/**
+ * An overload of ON_Intersect for point-curve intersection.
+ *
+ * Description:
+ *   Intersect pointA with curveB.
+ *
+ * Parameters:
+ *   pointA - [in]
+ *
+ *   curveB - [in]
+ *
+ *   x - [out]
+ *     Intersection events are appended to this array.
+ *
+ *   tolerance - [in]
+ *     If the input intersection_tolerance <= 0.0, then 0.001 is used.
+ *
+ *   curveB_domain - [in]
+ *     optional restriction on curveB t domain
+ *
+ * Returns:
+ *    True for an intersection. False for no intersection.
+ */
+extern BREP_EXPORT bool
+ON_Intersect(const ON_3dPoint& pointA,
+            const ON_Curve& curveB,
+            ON_ClassArray<ON_PX_EVENT>& x,
+            double tolerance = 0.0,
+            const ON_Interval* curveB_domain = 0);
+
+/**
+ * An overload of ON_Intersect for point-surface intersection.
+ *
+ * Description:
+ *   Intersect pointA with surfaceB.
+ *
+ * Parameters:
+ *   pointA - [in]
+ *
+ *   surfaceB - [in]
+ *
+ *   x - [out]
+ *     Intersection events are appended to this array.
+ *
+ *   tolerance - [in]
+ *     If the input intersection_tolerance <= 0.0, then 0.001 is used.
+ *
+ *   surfaceB_udomain - [in]
+ *     optional restriction on surfaceB u domain
+ *
+ *   surfaceB_vdomain - [in]
+ *     optional restriction on surfaceB v domain
+ *
+ * Returns:
+ *    True for an intersection. False for no intersection.
+ */
+extern BREP_EXPORT bool
+ON_Intersect(const ON_3dPoint& pointA,
+            const ON_Surface& surfaceB,
+            ON_ClassArray<ON_PX_EVENT>& x,
+            double tolerance = 0.0,
+            const ON_Interval* surfaceB_udomain = 0,
+            const ON_Interval* surfaceB_vdomain = 0);
+
 } /* extern C++ */
 #endif
 

Modified: brlcad/trunk/src/libbrep/intersect.cpp
===================================================================
--- brlcad/trunk/src/libbrep/intersect.cpp      2013-06-02 03:01:52 UTC (rev 
55634)
+++ brlcad/trunk/src/libbrep/intersect.cpp      2013-06-03 13:34:52 UTC (rev 
55635)
@@ -36,6 +36,61 @@
 #include "brep.h"
 
 /**
+ * Point-point intersections (PPI)
+ */
+bool
+ON_Intersect(const ON_3dPoint& pointA,
+            const ON_3dPoint& pointB,
+            ON_ClassArray<ON_PX_EVENT>& x,
+            double tolerance)
+{
+    if (tolerance <= 0.0)
+       tolerance = 0.01;
+
+    if (pointA.DistanceTo(pointB) <= tolerance) {
+       ON_PX_EVENT Event;
+       Event.m_type = ON_PX_EVENT::ppx_point;
+       Event.m_A = pointA;
+       Event.m_B = pointB;
+       Event.m_Mid = (pointA + pointB) * 0.5;
+       Event.m_radius = pointA.DistanceTo(pointB) * 0.5;
+       x.Append(Event);
+       return true;
+    }
+    return false;
+}
+
+/**
+ * Point-curve intersections (PCI)
+ */
+bool
+ON_Intersect(const ON_3dPoint& pointA,
+            const ON_Curve& curveB,
+            ON_ClassArray<ON_PX_EVENT>& x,
+            double tolerance,
+            const ON_Interval* curveB_domain)
+{
+    // Implement later.
+    return false;
+}
+
+/**
+ * Point-surface intersections (PSI)
+ */
+bool
+ON_Intersect(const ON_3dPoint& pointA,
+            const ON_Surface& surfaceB,
+            ON_ClassArray<ON_PX_EVENT>& x,
+            double tolerance,
+            const ON_Interval* surfaceB_udomain,
+            const ON_Interval* surfaceB_vdomain)
+{
+    // Implement later.
+    return false;
+}
+
+
+/**
  * Surface-surface intersections (SSI)
  *
  * approach:

Added: brlcad/trunk/src/libbrep/px_event.cpp
===================================================================
--- brlcad/trunk/src/libbrep/px_event.cpp                               (rev 0)
+++ brlcad/trunk/src/libbrep/px_event.cpp       2013-06-03 13:34:52 UTC (rev 
55635)
@@ -0,0 +1,136 @@
+/*                  P X _ E V E N T . C P P
+ * BRL-CAD
+ *
+ * Copyright (c) 2013 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 px_event.cpp
+ *
+ * Implementation of ON_PX_EVENT.
+ *
+ */
+
+#include "common.h"
+#include "brep.h"
+
+ON_PX_EVENT::ON_PX_EVENT()
+{
+    memset(this,0,sizeof(*this));
+}
+
+int
+ON_PX_EVENT::Compare(const ON_PX_EVENT* a, const ON_PX_EVENT* b)
+{
+    if (!a) {
+       return b ? 1 : 0;
+    }
+
+    if (!b)
+       return -1;
+
+    return a->m_Mid < b->m_Mid;
+}
+
+bool
+ON_PX_EVENT::IsValid(ON_TextLog* text_log,
+                    double intersection_tolerance,
+                    const class ON_3dPoint* pointA,
+                    const class ON_3dPoint* pointB,
+                    const class ON_Curve* curveB,
+                    const class ON_Interval* curveB_domain,
+                    const class ON_Surface* surfaceB,
+                    const class ON_Interval* surfaceB_domain0,
+                    const class ON_Interval* surfaceB_domain1) const
+{
+    // Implement later.
+    return true;
+}
+
+void
+ON_PX_EVENT::Dump(ON_TextLog& text_log) const
+{
+    text_log.Print("m_type: ");
+    switch (m_type) {
+    case ON_PX_EVENT::no_px_event:
+       text_log.Print("no_px_event");
+       break;
+    case ON_PX_EVENT::ppx_point:
+       text_log.Print("ppx_point");
+       break;
+    case ON_PX_EVENT::pcx_point:
+       text_log.Print("pcx_point");
+       break;
+    case ON_PX_EVENT::psx_point:
+       text_log.Print("psx_point");
+       break;
+    default:
+       text_log.Print("illegal value");
+       break;
+    }
+    text_log.Print("\n");
+    text_log.PushIndent();
+
+    text_log.Print("Intersection Point: \n");
+    text_log.PushIndent();
+    text_log.Print(m_Mid);
+    text_log.PopIndent();
+    text_log.Print("With uncertainty radius: \n");
+    text_log.PushIndent();
+    text_log.Print(m_radius);
+    text_log.PopIndent();
+    text_log.PopIndent();
+
+    text_log.Print("pointA = \n");
+    text_log.PushIndent();
+    text_log.Print(m_A);
+    text_log.PopIndent();
+
+    switch (m_type) {
+    case ON_PX_EVENT::ppx_point:
+       text_log.Print("pointB = \n");
+       break;
+
+    case ON_PX_EVENT::pcx_point:
+       text_log.Print("curveB(");
+       text_log.Print(m_b[0]);
+       text_log.Print(") = \n");
+       break;
+
+    case ON_PX_EVENT::psx_point:
+       text_log.Print("surfaceB");
+       text_log.Print(m_b);
+       text_log.Print(" = \n");
+       break;
+
+    case ON_PX_EVENT::no_px_event:
+       break;
+    }
+
+    text_log.PushIndent();
+    text_log.Print(m_B);
+    text_log.PopIndent();
+
+    text_log.PopIndent();
+}
+
+// Local Variables:
+// tab-width: 8
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: t
+// c-file-style: "stroustrup"
+// End:
+// ex: shiftwidth=4 tabstop=8


Property changes on: brlcad/trunk/src/libbrep/px_event.cpp
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to