home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / IRIT / IRITS.ZIP / BOOLEANL.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-05  |  4.5 KB  |  95 lines

  1. /*****************************************************************************
  2. *   "Irit" - the 3d polygonal solid modeller.                     *
  3. *                                         *
  4. * Written by:  Gershon Elber                Ver 0.2, Mar. 1990   *
  5. ******************************************************************************
  6. *   Definitions, local to modules, of Boolean operation modules:         *
  7. *****************************************************************************/
  8.  
  9. #ifndef BOOLEAN_LH
  10. #define BOOLEAN_LH
  11.  
  12. /*   The following structure is used to keep the intersecting segments of    */
  13. /* each polygons, which the other object polygons. they are saved as a       */
  14. /* list of segments, which can form a closed loop (if totally internal) or   */
  15. /* an open one (in which the two ends intersects the polygon boundaries).    */
  16. /*   Note all the polygons of the two given objects must be convex!         */
  17. typedef struct InterSegmentStruct {
  18.     PointType PtSeg[2];               /* The two end points of the segment. */
  19.     /* If intersect polygon vertex, point on it. If internal to poly, NULL.  */
  20.     VertexStruct *V[2];
  21.     PolygonStruct *Pl;           /* Point on the (other) intersecting polygon. */
  22.     struct InterSegmentStruct *Pnext;
  23. } InterSegmentStruct;
  24.  
  25. /* Used to hold list of InterSegment polylines: */
  26. typedef struct InterSegListStruct {
  27.     struct InterSegmentStruct *PISeg,      /* Point to InterSegment Polyline. */
  28.     *PISegMaxX;               /* Used in closed loops handling. */
  29.     struct InterSegListStruct *Pnext;          /* Point to next polyline. */
  30. } InterSegListStruct;
  31.  
  32. /* Used in sorting of open loops: */
  33. typedef struct SortOpenStruct {
  34.     RealType Key;
  35.     struct InterSegListStruct *PLSeg;   /* Point to open loop with this key. */
  36.     struct SortOpenStruct *Pnext;           /* Point to next in list. */
  37. } SortOpenStruct;
  38.  
  39. /* The following are temporary flags used to mark the original vertices in   */
  40. /* the resulting object. Used to detected edges originated in the input         */
  41. /* object, and used to propagate the adjacencies.                 */
  42. #define ORIGINAL_TAG 0x10
  43.  
  44. #define    IS_ORIGINAL_VRTX(Vrtx)    ((Vrtx)->Tags & ORIGINAL_TAG)
  45. #define    SET_ORIGINAL_VRTX(Vrtx)    ((Vrtx)->Tags |= ORIGINAL_TAG)
  46. #define    RST_ORIGINAL_VRTX(Vrtx)    ((Vrtx)->Tags &= ~ORIGINAL_TAG)
  47.  
  48.  
  49. /* The following are temporary flags used to mark the polygons in the         */
  50. /* adjacencies propagation. Can use bit 4-7 of PolygonStruct Tags only.      */
  51. #define COMPLETE_TAG   0x10 /* Complete Tag - Polygon has no intersection.   */
  52. #define IN_OUTPUT_TAG  0x20 /* InOutput Tag - Polygon should be in output.   */
  53. #define ADJ_PUSHED_TAG 0x40 /* AdjPushed Tag - Polygon has been pushed.         */
  54.  
  55. #define    IS_COMPLETE_POLY(Poly)    ((Poly)->Tags & COMPLETE_TAG)
  56. #define    SET_COMPLETE_POLY(Poly)    ((Poly)->Tags |= COMPLETE_TAG)
  57. #define    RST_COMPLETE_POLY(Poly)    ((Poly)->Tags &= ~COMPLETE_TAG)
  58. #define    IS_INOUTPUT_POLY(Poly)    ((Poly)->Tags & IN_OUTPUT_TAG)
  59. #define    SET_INOUTPUT_POLY(Poly)    ((Poly)->Tags |= IN_OUTPUT_TAG)
  60. #define    RST_INOUTPUT_POLY(Poly)    ((Poly)->Tags &= ~IN_OUTPUT_TAG)
  61. #define    IS_ADJPUSHED_POLY(Poly)    ((Poly)->Tags & ADJ_PUSHED_TAG)
  62. #define    SET_ADJPUSHED_POLY(Poly) ((Poly)->Tags |= ADJ_PUSHED_TAG)
  63. #define    RST_ADJPUSHED_POLY(Poly) ((Poly)->Tags &= ~ADJ_PUSHED_TAG)
  64.  
  65. #define ADJ_STACK_SIZE    1024        /* Adjacency of polygons stack size. */
  66.  
  67. /* FatalError types are defined below. Usually, they will cause empty result.*/
  68. #define FTL_BOOL_NO_INTER    1    /* No intersection between operands. */
  69. #define FTL_BOOL_CTRL_BRK    2           /* Control break was pressed. */
  70. #define FTL_BOOL_FPE        3            /* Floating point error. */
  71.  
  72. /* Boolean operations types: */
  73. #define BOOL_OPEN_OR    1
  74. #define BOOL_OPEN_AND    2
  75. #define BOOL_OPEN_SUB    3
  76. #define BOOL_OPEN_NEG    4
  77.  
  78. extern int BooleanOutputInterCurve;    /* Kind of output from boolean oper. */
  79.  
  80. /* Prototypes of local functions in Bool-Hi.c module: */
  81. void TestBooleanCtrlBrk(void);
  82. void FatalBooleanError(int ErrorType);
  83.  
  84. /* Prototypes of local functions in Bool-Low.c module: */
  85. ObjectStruct *BooleanLow1Out2(ObjectStruct *PObj1, ObjectStruct *PObj2);
  86. ObjectStruct *BooleanLow1In2(ObjectStruct *PObj1, ObjectStruct *PObj2);
  87. void SortOpenInterList(PolygonStruct *Pl, InterSegListStruct **POpen);
  88. struct VertexStruct *InterLoopToVrtxList(InterSegmentStruct *PIHead);
  89. struct VertexStruct *GenReverseVrtxList(VertexStruct *VIn);
  90. void LoopsFromInterList(PolygonStruct *Pl,
  91.         InterSegListStruct **PlClosed, InterSegListStruct **PlOpen);
  92. ObjectStruct *ExtractPolygons(ObjectStruct *PObj, int AinB);
  93.  
  94. #endif /* BOOLEAN_LH */
  95.