# SoIntersectionDetectionAction.h

    00001 #ifndef COIN_SOINTERSECTIONDETECTIONACTION_H
    00002 #define COIN_SOINTERSECTIONDETECTIONACTION_H
    00003
    00004 /**************************************************************************\
    00005  *
    00006  *  This file is part of the Coin 3D visualization library.
    00007  *  Copyright (C) 1998-2003 by Systems in Motion.  All rights reserved.
    00008  *
    00009  *  This library is free software; you can redistribute it and/or
    00010  *  modify it under the terms of the GNU General Public License
    00011  *  ("GPL") version 2 as published by the Free Software Foundation.
    00012  *  See the file LICENSE.GPL at the root directory of this source
    00013  *  distribution for additional information about the GNU GPL.
    00014  *
    00015  *  For using Coin with software that can not be combined with the GNU
    00016  *  GPL, and for taking advantage of the additional benefits of our
    00017  *  support services, please contact Systems in Motion about acquiring
    00018  *  a Coin Professional Edition License.
    00019  *
    00020  *  See <URL:http://www.coin3d.org> for  more information.
    00021  *
    00022  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
    00023  *  <URL:http://www.sim.no>.
    00024  *
    00025 \**************************************************************************/
    00026
    00027 #include <Inventor/actions/SoSubAction.h>
    00028 #include <Inventor/actions/SoAction.h>
    00029 #include <Inventor/actions/SoCallbackAction.h>
    00030
    00031 struct SoIntersectingPrimitive {
    00032   SoPath * path;
    00033   enum PrimitiveType {
    00034     SEGMENT = 2,
    00035     LINE_SEGMENT = 2,
    00036     TRIANGLE = 3
    00037   } type;
    00038   SbVec3f vertex[3];
    00039   SbVec3f xf_vertex[3];
    00040 };
    00041
    00042 class SoIntersectionDetectionActionP;
    00043
    00044 class COIN_DLL_API SoIntersectionDetectionAction : public SoAction {
    00045   typedef SoAction hinherited;
    00046   SO_ACTION_HEADER(SoIntersectionDetectionAction);
    00047 public:
    00048   static void initClass(void);
    00049   SoIntersectionDetectionAction(void);
    00050   virtual ~SoIntersectionDetectionAction(void);
    00051
    00052   enum Resp {
    00053     NEXT_PRIMITIVE,
    00054     NEXT_SHAPE,
    00055     ABORT
    00056   };
    00057
    00058   typedef SoCallbackAction::Response SoIntersectionVisitationCB(void * closure, const SoPath * where);
    00059   typedef SbBool SoIntersectionFilterCB(void * closure, const SoPath * p1, const SoPath * p2);
    00060   typedef Resp SoIntersectionCB(void * closure, const SoIntersectingPrimitive * p1, const SoIntersectingPrimitive * p2);
    00061
    00062   void setIntersectionDetectionEpsilon(float epsilon);
    00063   float getIntersectionDetectionEpsilon(void) const;
    00064
    00065   static void setIntersectionEpsilon(float epsilon);
    00066   static float getIntersectionEpsilon(void);
    00067
    00068   void setTypeEnabled(SoType type, SbBool enable);
    00069   SbBool isTypeEnabled(SoType type, SbBool checkgroups = FALSE) const;
    00070
    00071   void setManipsEnabled(SbBool enable);
    00072   SbBool isManipsEnabled(void) const;
    00073
    00074   void setDraggersEnabled(SbBool enable);
    00075   SbBool isDraggersEnabled(void) const;
    00076
    00077   void setShapeInternalsEnabled(SbBool enable);
    00078   SbBool isShapeInternalsEnabled(void) const;
    00079
    00080   void addVisitationCallback(SoType type, SoIntersectionVisitationCB * cb, void * closure);
    00081   void removeVisitationCallback(SoType type, SoIntersectionVisitationCB * cb, void * closure);
    00082
    00083   virtual void apply(SoNode * node);
    00084   virtual void apply(SoPath * path);
    00085   virtual void apply(const SoPathList & paths, SbBool obeysRules = FALSE);
    00086
    00087   virtual void setFilterCallback(SoIntersectionFilterCB * cb, void * closure = NULL);
    00088   virtual void addIntersectionCallback(SoIntersectionCB * cb, void * closure  = NULL);
    00089   virtual void removeIntersectionCallback(SoIntersectionCB * cb, void * closure  = NULL);
    00090
    00091 private:
    00092   SoIntersectionDetectionActionP * pimpl;
    00093 };
    00094
    00095 #endif // !COIN_SOINTERSECTIONDETECTIONACTION_H