home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / i / iritsm3s.zip / irit / booleanl.h < prev    next >
C/C++ Source or Header  |  1991-11-18  |  5KB  |  101 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.     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.     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. #ifdef __MSDOS__
  66. #define ADJ_STACK_SIZE    1024        /* Adjacency of polygons stack size. */
  67. #else
  68. #define ADJ_STACK_SIZE    16386        /* Adjacency of polygons stack size. */
  69. #endif /* __MSDOS__ */
  70.  
  71. /* FatalError types are defined below. Usually, they will cause empty result.*/
  72. #define FTL_BOOL_NO_INTER    1    /* No intersection between operands. */
  73. #define FTL_BOOL_CTRL_BRK    2           /* Control break was pressed. */
  74. #define FTL_BOOL_FPE        3            /* Floating point error. */
  75.  
  76. /* Boolean operations types: */
  77. #define BOOL_OPER_OR    1
  78. #define BOOL_OPER_AND    2
  79. #define BOOL_OPER_SUB    3
  80. #define BOOL_OPER_NEG    4
  81. #define BOOL_OPER_CUT    5
  82. #define BOOL_OPER_MERGE    6
  83.  
  84. extern int BooleanOutputInterCurve;    /* Kind of output from boolean oper. */
  85.  
  86. /* Prototypes of local functions in Bool-Hi.c module: */
  87. void TestBooleanCtrlBrk(void);
  88. void FatalBooleanError(int ErrorType);
  89.  
  90. /* Prototypes of local functions in Bool-Low.c module: */
  91. ObjectStruct *BooleanLow1Out2(ObjectStruct *PObj1, ObjectStruct *PObj2);
  92. ObjectStruct *BooleanLow1In2(ObjectStruct *PObj1, ObjectStruct *PObj2);
  93. void SortOpenInterList(PolygonStruct *Pl, InterSegListStruct **POpen);
  94. VertexStruct *InterLoopToVrtxList(InterSegmentStruct *PIHead);
  95. VertexStruct *GenReverseVrtxList(VertexStruct *VIn);
  96. void LoopsFromInterList(PolygonStruct *Pl,
  97.         InterSegListStruct **PlClosed, InterSegListStruct **PlOpen);
  98. ObjectStruct *ExtractPolygons(ObjectStruct *PObj, int AinB);
  99.  
  100. #endif /* BOOLEAN_LH */
  101.