Added clipping outer layers to the interface for selecting points in the volume so...
authorabokinsky <abokinsky@ba61647d-9d00-f842-95cd-605cb4296b96>
Tue, 6 Mar 2018 14:53:08 +0000 (14:53 +0000)
committerabokinsky <abokinsky@ba61647d-9d00-f842-95cd-605cb4296b96>
Tue, 6 Mar 2018 14:53:08 +0000 (14:53 +0000)
git-svn-id: https://citdcbmipav.cit.nih.gov/repos-pub/mipav/trunk@15399 ba61647d-9d00-f842-95cd-605cb4296b96

mipav/src/gov/nih/mipav/view/renderer/WildMagic/VolumeTriPlanarRender.java
mipav/src/gov/nih/mipav/view/renderer/WildMagic/VolumeTriPlanarRenderBase.java

index 943b112..2dfbcc9 100644 (file)
@@ -1383,6 +1383,7 @@ implements GLEventListener, KeyListener, MouseMotionListener,  MouseListener, Na
                                        Vector3f maxPt = new Vector3f();\r
                                        if ( m_kSlices.GetDisplay() )\r
                                        {\r
+                                               // pick on the slices\r
                                                m_kPicker.Execute(m_kSlices.GetScene(),kPos,kDir,0.0f,\r
                                                                Float.MAX_VALUE);\r
                                                if (m_kPicker.Records.size() > 0)\r
@@ -1450,6 +1451,7 @@ implements GLEventListener, KeyListener, MouseMotionListener,  MouseListener, Na
                                                }\r
                                        }\r
                                                \r
+                                       // pick in the volume.\r
                                        m_kPicker.Execute(m_kVolumeRayCast.GetScene(),kPos,kDir,0.0f,\r
                                                        Float.MAX_VALUE);\r
 \r
@@ -1488,11 +1490,27 @@ implements GLEventListener, KeyListener, MouseMotionListener,  MouseListener, Na
                                                        Vector3f p0 = new Vector3f(firstIntersectionPoint);\r
                                                        Vector3f p1 = new Vector3f(secondIntersectionPoint);\r
                                                        Vector3f step = Vector3f.sub(p1, p0);\r
+                                                       Vector3f test = new Vector3f();\r
                                                        float numSteps = step.length() + 1;\r
                                                        step.normalize();\r
                                                        for ( int i = 0; i < numSteps; i++ )\r
                                                        {\r
+                                                               // step along the ray and pick the voxel with the highest value:\r
                                                                p0.add(step);\r
+                                                               // test for clipping:\r
+                                                               if ( ellipsoidClip != null ) {\r
+                                                                       test.copy( p0 );\r
+                                                                       m_kVolumeRayCast.volumeToLocalCoords( test );\r
+                                                                       \r
+//                                                                     Vector3f scale = new Vector3f(m_kVolumeImageA.GetScaleX()/(m_kVolumeImageA.GetImage().getExtents()[0] - 1), \r
+//                                                                                     m_kVolumeImageA.GetScaleY()/(m_kVolumeImageA.GetImage().getExtents()[1] - 1), \r
+//                                                                                     m_kVolumeImageA.GetScaleZ()/(m_kVolumeImageA.GetImage().getExtents()[2] - 1)  );\r
+//                                                                     test = Vector3f.mult( p0, scale);\r
+                                                                       if ( !ellipsoidClipLocal.Contains(test) ) {\r
+                                                                               continue;\r
+                                                                       }\r
+//                                                                     System.err.println( i + " " + test );\r
+                                                               }\r
                                                                float value;\r
                                                                if ( m_kVolumeImageA.GetImage().isColorImage() )\r
                                                                {\r
@@ -1539,10 +1557,12 @@ implements GLEventListener, KeyListener, MouseMotionListener,  MouseListener, Na
                                                                boolean picked = false;\r
                                                                if ( is3DSelectionEnabled() )\r
                                                                {\r
+                                                                       // check for selecting an existing marker:\r
                                                                        picked = modify3DMarker( firstIntersectionPoint, secondIntersectionPoint, maxPt, rightMousePressed );\r
                                                                }\r
                                                                if ( !picked )\r
                                                                {\r
+                                                                       // add a new picked point:\r
                                                                        short id = (short) m_kVolumeImageA.GetImage().getVOIs().getUniqueID();\r
                                                                        int colorID = 0;\r
                                                                        VOI newTextVOI = new VOI((short) colorID, "annotation3d_" + id, VOI.ANNOTATION, -1.0f);\r
index 3c07649..779d5ec 100644 (file)
@@ -3860,7 +3860,8 @@ public class VolumeTriPlanarRenderBase extends GPURenderBase implements
     private int xFilter = 0;\r
     private int yFilter = 0;\r
     private int zFilter = 0;\r
-    private Ellipsoid3f ellipsoidClip = null;\r
+    protected Ellipsoid3f ellipsoidClip = null;\r
+    protected Ellipsoid3f ellipsoidClipLocal = null;\r
     private Box3f orientedBox = null;\r
     protected void applyClipFilter(boolean increase) {\r
                if (m_kVolumeRayCast == null) {\r
@@ -3898,6 +3899,11 @@ public class VolumeTriPlanarRenderBase extends GPURenderBase implements
 \r
 //                     ellipsoidClip =  new Ellipsoid3f( new Vector3f( m_fX/2f, m_fY/2f, m_fZ/2f), new Vector3f[]{Vector3f.UNIT_X, Vector3f.UNIT_Y, Vector3f.UNIT_Z}, new float[]{m_fX, m_fY, m_fZ} );\r
                        ellipsoidClip =  new Ellipsoid3f( new Vector3f( .5f, .5f, .5f ), new Vector3f[]{Vector3f.UNIT_X, Vector3f.UNIT_Y, Vector3f.UNIT_Z}, new float[]{m_fX, m_fY, m_fZ} );\r
+                       Vector3f center = new Vector3f(m_kVolumeRayCast.GetTranslate() ); center.neg();\r
+//                     ellipsoidClip =  new Ellipsoid3f( center, new Vector3f[]{Vector3f.UNIT_X, Vector3f.UNIT_Y, Vector3f.UNIT_Z}, new float[]{m_fX, m_fY, m_fZ} );\r
+                       ellipsoidClipLocal =  new Ellipsoid3f( center, new Vector3f[]{Vector3f.UNIT_X, Vector3f.UNIT_Y, Vector3f.UNIT_Z}, new float[]{m_fX, m_fY, m_fZ} );\r
+\r
+//                     System.err.println( center );\r
                        m_kVolumeRayCast.SetClipEllipsoid( ellipsoidClip, true );\r
                }\r
                \r
@@ -3911,6 +3917,7 @@ public class VolumeTriPlanarRenderBase extends GPURenderBase implements
                                ellipsoidClip.Extent[1] = (float) (0.05 * m_fY);\r
                                ellipsoidClip.Extent[2] = (float) (0.05 * m_fZ);\r
                        }\r
+                       ellipsoidClipLocal.Extent = ellipsoidClip.Extent;\r
 //                     System.err.println(ellipsoidClip.Extent[0] + "  " + ellipsoidClip.Extent[1] + "  " + ellipsoidClip.Extent[2] );\r
                        m_kVolumeRayCast.SetClipEllipsoid( ellipsoidClip, true );\r
                }\r
@@ -3928,6 +3935,7 @@ public class VolumeTriPlanarRenderBase extends GPURenderBase implements
                                ellipsoidClip.Extent[1] = m_fY;\r
                                ellipsoidClip.Extent[2] = m_fZ;\r
                        }\r
+                       ellipsoidClipLocal.Extent = ellipsoidClip.Extent;\r
                        m_kVolumeRayCast.SetClipEllipsoid( ellipsoidClip, true );\r
                }\r
                \r