1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDEPRIMITIVE3D_HXX
25 #define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDEPRIMITIVE3D_HXX
26 
27 #include <drawinglayer/drawinglayerdllapi.h>
28 #include <drawinglayer/primitive3d/sdrprimitive3d.hxx>
29 #include <basegfx/polygon/b2dpolypolygon.hxx>
30 
31 //////////////////////////////////////////////////////////////////////////////
32 
33 namespace drawinglayer
34 {
35 	namespace primitive3d
36 	{
37         /** SdrExtrudePrimitive3D class
38 
39             This 3D primitive expands the SdrPrimitive3D to a 3D extrude definition.
40             The given 2D PolyPolygon geometry is imagined as lying on the XY-plane in 3D
41             and gets extruded in Z-Direction by Depth.
42 
43             Various possibilities e.g. for creating diagonals (edge roudings in 3D)
44             and similar are given.
45 
46             The decomposition will create all necessary 3D planes for visualisation.
47          */
48 		class DRAWINGLAYER_DLLPUBLIC SdrExtrudePrimitive3D : public SdrPrimitive3D
49 		{
50 		private:
51 			/// geometry helper for slices
52 			basegfx::B2DPolyPolygon						maCorrectedPolyPolygon;
53 			Slice3DVector								maSlices;
54 
55 			/// primitive geometry data
56 			basegfx::B2DPolyPolygon						maPolyPolygon;
57 			double										mfDepth;
58 			double										mfDiagonal;
59 			double										mfBackScale;
60 
61             /// decomposition data when ReducedLineGeometry is used, see get3DDecomposition
62             geometry::ViewInformation3D*                mpLastRLGViewInformation;
63 
64             /// bitfield
65 			unsigned									mbSmoothNormals : 1; // Plane self
66 			unsigned									mbSmoothHorizontalNormals : 1; // always
67 			unsigned									mbSmoothLids : 1; // Front/back
68 			unsigned									mbCharacterMode : 1;
69 			unsigned									mbCloseFront : 1;
70 			unsigned									mbCloseBack : 1;
71 
72 			/// create slices
73 			void impCreateSlices();
74 
75 			/// get (evtl. create) slices
76 			const Slice3DVector& getSlices() const;
77 
78 		protected:
79 			/// local decomposition.
80 			virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const;
81 
82 		public:
83             /// constructor
84 			SdrExtrudePrimitive3D(
85 				const basegfx::B3DHomMatrix& rTransform,
86 				const basegfx::B2DVector& rTextureSize,
87 				const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute,
88 				const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute,
89 				const basegfx::B2DPolyPolygon& rPolyPolygon,
90 				double fDepth,
91 				double fDiagonal,
92 				double fBackScale,
93 				bool bSmoothNormals,
94 				bool bSmoothHorizontalNormals,
95 				bool bSmoothLids,
96 				bool bCharacterMode,
97 				bool bCloseFront,
98 				bool bCloseBack);
99 			virtual ~SdrExtrudePrimitive3D();
100 
101 			/// data read access
getPolyPolygon() const102 			const basegfx::B2DPolyPolygon& getPolyPolygon() const { return maPolyPolygon; }
getDepth() const103 			double getDepth() const { return mfDepth; }
getDiagonal() const104 			double getDiagonal() const { return mfDiagonal; }
getBackScale() const105 			double getBackScale() const { return mfBackScale; }
getSmoothNormals() const106 			bool getSmoothNormals() const { return mbSmoothNormals; }
getSmoothHorizontalNormals() const107 			bool getSmoothHorizontalNormals() const { return mbSmoothHorizontalNormals; }
getSmoothLids() const108 			bool getSmoothLids() const { return mbSmoothLids; }
getCharacterMode() const109 			bool getCharacterMode() const { return mbCharacterMode; }
getCloseFront() const110 			bool getCloseFront() const { return mbCloseFront; }
getCloseBack() const111 			bool getCloseBack() const { return mbCloseBack; }
112 
113 			/// compare operator
114 			virtual bool operator==(const BasePrimitive3D& rPrimitive) const;
115 
116 			/// get range
117 			virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const;
118 
119             /// Overloaded to allow for reduced line mode to decide if to buffer decomposition or not
120 			virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const;
121 
122             /// provide unique ID
123 			DeclPrimitrive3DIDBlock()
124 		};
125 	} // end of namespace primitive3d
126 } // end of namespace drawinglayer
127 
128 //////////////////////////////////////////////////////////////////////////////
129 
130 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDEPRIMITIVE3D_HXX
131 
132 //////////////////////////////////////////////////////////////////////////////
133 // eof
134