# SbClip.h

    00001 #ifndef COIN_SBCLIP_H
    00002 #define COIN_SBCLIP_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/lists/SbList.h>
    00028 #include <Inventor/SbVec3f.h>
    00029 #include <stddef.h>
    00030
    00031 class SbPlane;
    00032 class SbVec2f;
    00033
    00034 typedef void * SbClipCallback(const SbVec3f & v0, void * vdata0,
    00035                               const SbVec3f & v1, void * vdata1,
    00036                               const SbVec3f & newvertex,
    00037                               void * userdata);
    00038
    00039 class COIN_DLL_API SbClip {
    00040 public:
    00041   SbClip(SbClipCallback * callback = NULL, void * userdata = NULL);
    00042
    00043   void addVertex(const SbVec3f &v, void * vdata = NULL);
    00044   void reset(void);
    00045
    00046   void clip(const SbPlane & plane);
    00047
    00048   int getNumVertices(void) const;
    00049   void getVertex(const int idx, SbVec3f & v, void ** vdata = NULL) const;
    00050   void * getVertexData(const int idx) const;
    00051
    00052 private:
    00053   class SbClipData {
    00054   public:
    00055     SbClipData(void) {}
    00056     SbClipData(const SbVec3f & v, void * data)
    00057       : vertex(v),
    00058         data(data) {}
    00059   public:
    00060     void get(SbVec3f &v, void *& data) {
    00061       v = this->vertex;
    00062       data = this->data;
    00063     }
    00064
    00065     SbVec3f vertex;
    00066     void * data;
    00067   };
    00068
    00069   SbClipCallback * callback;
    00070   void * cbdata;
    00071   SbList <SbClipData> array[2];
    00072   int curr;
    00073   void outputVertex(const SbVec3f &v, void * data);
    00074 };
    00075
    00076
    00077 #endif // !COIN_SBCLIP_H