OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / SGI / util / SGI / include / graphics / vtkImplicitBoolean.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkImplicitBoolean.h,v $
5   Language:  C++
6   Date:      $Date: 2002/02/01 06:30:45 $
7   Version:   $Revision: 1.1.1.1 $
8
9
10 Copyright (c) 1993-1998 Ken Martin, Will Schroeder, Bill Lorensen.
11
12 This software is copyrighted by Ken Martin, Will Schroeder and Bill Lorensen.
13 The following terms apply to all files associated with the software unless
14 explicitly disclaimed in individual files. This copyright specifically does
15 not apply to the related textbook "The Visualization Toolkit" ISBN
16 013199837-4 published by Prentice Hall which is covered by its own copyright.
17
18 The authors hereby grant permission to use, copy, and distribute this
19 software and its documentation for any purpose, provided that existing
20 copyright notices are retained in all copies and that this notice is included
21 verbatim in any distributions. Additionally, the authors grant permission to
22 modify this software and its documentation for any purpose, provided that
23 such modifications are not distributed without the explicit consent of the
24 authors and that existing copyright notices are retained in all copies. Some
25 of the algorithms implemented by this software are patented, observe all
26 applicable patent law.
27
28 IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
29 DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
30 OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
31 EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
34 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
35 PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE IS PROVIDED ON AN
36 "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
37 MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
38
39
40 =========================================================================*/
41 // .NAME vtkImplicitBoolean - implicit function consisting of boolean combinations of implicit functions
42 // .SECTION Description
43 // vtkImplicitBoolean is an implicit function consisting of boolean
44 // combinations of implicit functions. The class has a list of functions
45 // (FunctionList) that are combined according to a specified operator
46 // (VTK_UNION or VTK_INTERSECTION or VTK_DIFFERENCE). You can use nested
47 // combinations of vtkImplicitFunction's (and/or vtkImplicitBoolean) to create
48 // elaborate implicit functions.  vtkImplicitBoolean is a concrete
49 // implementation of vtkImplicitFunction.
50 //
51 // The operators work as follows. The VTK_UNION operator takes the minimum
52 // value of all implicit functions. The VTK_INTERSECTION operator takes the
53 // maximum value of all implicit functions. The VTK_DIFFERENCE operator
54 // subtracts the 2nd through last implicit functions from the first.
55
56
57 #ifndef __vtkImplicitBoolean_h
58 #define __vtkImplicitBoolean_h
59
60 #include "vtkImplicitFunction.h"
61 #include "vtkImplicitFunctionCollection.h"
62
63 #define VTK_UNION 0
64 #define VTK_INTERSECTION 1
65 #define VTK_DIFFERENCE 2
66 #define VTK_UNION_OF_MAGNITUDES 3
67
68 class VTK_EXPORT vtkImplicitBoolean : public vtkImplicitFunction
69 {
70 public:
71   vtkImplicitBoolean();
72   ~vtkImplicitBoolean();
73   static vtkImplicitBoolean *New() {return new vtkImplicitBoolean;};
74   const char *GetClassName() {return "vtkImplicitBoolean";};
75   void PrintSelf(ostream& os, vtkIndent indent);
76
77   // ImplicitFunction interface
78   float EvaluateFunction(float x[3]);
79   void EvaluateGradient(float x[3], float g[3]);
80
81   // Override modified time retrieval because of object dependencies.
82   unsigned long int GetMTime();
83
84   void AddFunction(vtkImplicitFunction *in);
85   void AddFunction(vtkImplicitFunction &in) {this->AddFunction(&in);};
86   void RemoveFunction(vtkImplicitFunction *in);
87   void RemoveFunction(vtkImplicitFunction &in) {this->RemoveFunction(&in);};
88   vtkImplicitFunctionCollection *GetFunction() {return &(this->FunctionList);};
89
90   // Description:
91   // Specify the type of boolean operation.
92   vtkSetClampMacro(OperationType,int,VTK_UNION,VTK_UNION_OF_MAGNITUDES);
93   vtkGetMacro(OperationType,int);
94   void SetOperationTypeToUnion() 
95     {this->SetOperationType(VTK_UNION);};
96   void SetOperationTypeToIntersection() 
97     {this->SetOperationType(VTK_INTERSECTION);};
98   void SetOperationTypeToDifference() 
99     {this->SetOperationType(VTK_DIFFERENCE);};
100   void SetOperationTypeToUnionOfMagnitudes() 
101     {this->SetOperationType(VTK_UNION_OF_MAGNITUDES);};
102   char *GetOperationTypeAsString();
103
104 protected:
105   vtkImplicitFunctionCollection FunctionList;
106
107   int OperationType;
108
109 };
110
111 // Description:
112 // Return the boolean operation type as a descriptive character string.
113 inline char *vtkImplicitBoolean::GetOperationTypeAsString(void)
114 {
115   if ( this->OperationType == VTK_UNION )
116     {
117     return "Union";
118     }
119   else if ( this->OperationType == VTK_INTERSECTION ) 
120     {
121     return "Intersection";
122     }
123   else if ( this->OperationType == VTK_DIFFERENCE ) 
124     {
125     return "Difference";
126     }
127   else 
128     {
129     return "UnionOfMagnitudes";
130     }
131 }
132
133 #endif
134
135