1 /******************************************************************************* 2 * prism.h 3 * 4 * This module contains all defines, typedefs, and prototypes for PRISM.CPP. 5 * 6 * --------------------------------------------------------------------------- 7 * Persistence of Vision Ray Tracer ('POV-Ray') version 3.7. 8 * Copyright 1991-2013 Persistence of Vision Raytracer Pty. Ltd. 9 * 10 * POV-Ray is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU Affero General Public License as 12 * published by the Free Software Foundation, either version 3 of the 13 * License, or (at your option) any later version. 14 * 15 * POV-Ray is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Affero General Public License for more details. 19 * 20 * You should have received a copy of the GNU Affero General Public License 21 * along with this program. If not, see <http://www.gnu.org/licenses/>. 22 * --------------------------------------------------------------------------- 23 * POV-Ray is based on the popular DKB raytracer version 2.12. 24 * DKBTrace was originally written by David K. Buck. 25 * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. 26 * --------------------------------------------------------------------------- 27 * $File: //depot/public/povray/3.x/source/backend/shape/prism.h $ 28 * $Revision: #1 $ 29 * $Change: 6069 $ 30 * $DateTime: 2013/11/06 11:59:40 $ 31 * $Author: chrisc $ 32 *******************************************************************************/ 33 34 #ifndef PRISM_H 35 #define PRISM_H 36 37 namespace pov 38 { 39 40 /***************************************************************************** 41 * Global preprocessor definitions 42 ******************************************************************************/ 43 44 #define PRISM_OBJECT (STURM_OK_OBJECT) 45 46 #define LINEAR_SPLINE 1 47 #define QUADRATIC_SPLINE 2 48 #define CUBIC_SPLINE 3 49 #define BEZIER_SPLINE 4 50 51 #define LINEAR_SWEEP 1 52 #define CONIC_SWEEP 2 53 54 /* Generate additional prism statistics. */ 55 56 #define PRISM_EXTRA_STATS 1 57 58 59 60 /***************************************************************************** 61 * Global typedefs 62 ******************************************************************************/ 63 64 typedef struct Prism_Spline_Struct PRISM_SPLINE; 65 typedef struct Prism_Spline_Entry_Struct PRISM_SPLINE_ENTRY; 66 67 struct Prism_Spline_Entry_Struct 68 { 69 DBL x1, y1, x2, y2; /* Min./Max. coordinates of segment */ 70 DBL v1, u2, v2; /* Min./Max. coordinates of segment in <u,v>, u1 not needed */ 71 UV_VECT A, B, C, D; /* Coefficients of segment */ 72 }; 73 74 struct Prism_Spline_Struct 75 { 76 int References; 77 PRISM_SPLINE_ENTRY *Entry; 78 }; 79 80 class Prism : public ObjectBase 81 { 82 public: 83 int Number; 84 int Spline_Type; /* Spline type (linear, quadratic ...) */ 85 int Sweep_Type; /* Sweep type (linear, conic) */ 86 DBL Height1, Height2; 87 DBL x1, y1, x2, y2; /* Overall bounding rectangle of spline curve */ 88 PRISM_SPLINE *Spline; /* Pointer to array of splines */ 89 DBL u1, v1, u2, v2; /* Overall <u,v> bounding rectangle of spline */ 90 91 Prism(); 92 virtual ~Prism(); 93 94 virtual ObjectPtr Copy(); 95 96 virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); 97 virtual bool Inside(const VECTOR, TraceThreadData *) const; 98 virtual void Normal(VECTOR, Intersection *, TraceThreadData *) const; 99 virtual void Translate(const VECTOR, const TRANSFORM *); 100 virtual void Rotate(const VECTOR, const TRANSFORM *); 101 virtual void Scale(const VECTOR, const TRANSFORM *); 102 virtual void Transform(const TRANSFORM *); 103 virtual void Invert(); 104 virtual void Compute_BBox(); 105 106 void Compute_Prism(UV_VECT *P, TraceThreadData *Thread); 107 protected: 108 int in_curve(DBL u, DBL v, TraceThreadData *Thread) const; 109 static bool test_rectangle(const VECTOR P, const VECTOR D, DBL x1, DBL y1, DBL x2, DBL y2); 110 }; 111 112 } 113 114 #endif 115