xref: /trunk/main/drawinglayer/inc/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
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_SDRLATHEPRIMITIVE3D_HXX
25 #define INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_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         /** SdrLathePrimitive3D class
38 
39             This 3D primitive expands the SdrPrimitive3D to a 3D rotation definition.
40             The given 2D PolyPolygon geometry is imagined as lying on the XY-plane in 3D
41             and gets rotated around the Y-Axis.
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 SdrLathePrimitive3D : 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             sal_uInt32                                  mnHorizontalSegments;
58             sal_uInt32                                  mnVerticalSegments;
59             double                                      mfDiagonal;
60             double                                      mfBackScale;
61             double                                      mfRotation;
62 
63             /// decomposition data when ReducedLineGeometry is used, see get3DDecomposition
64             geometry::ViewInformation3D*                mpLastRLGViewInformation;
65 
66             /// bitfield
67             unsigned                                    mbSmoothNormals : 1; // Plane self
68             unsigned                                    mbSmoothHorizontalNormals : 1; // always
69             unsigned                                    mbSmoothLids : 1; // Front/back
70             unsigned                                    mbCharacterMode : 1;
71             unsigned                                    mbCloseFront : 1;
72             unsigned                                    mbCloseBack : 1;
73 
74             /// create slices
75             void impCreateSlices();
76 
77             /// get (evtl. create) slices
78             const Slice3DVector& getSlices() const;
79 
80         protected:
81             /// local helpers
82             void impCreateOutlines(
83                 const geometry::ViewInformation3D& rViewInformation,
84                 const basegfx::B3DPolygon& rLoopA,
85                 const basegfx::B3DPolygon& rLoopB,
86                 basegfx::B3DPolyPolygon& rTarget) const;
87 
88             bool impHasCutWith(
89                 const basegfx::B2DPolygon& rPoly,
90                 const basegfx::B2DPoint& rStart,
91                 const basegfx::B2DPoint& rEnd) const;
92 
93             /// local decomposition.
94             virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const;
95 
96         public:
97             /// constructor
98             SdrLathePrimitive3D(
99                 const basegfx::B3DHomMatrix& rTransform,
100                 const basegfx::B2DVector& rTextureSize,
101                 const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute,
102                 const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute,
103                 const basegfx::B2DPolyPolygon& rPolyPolygon,
104                 sal_uInt32 nHorizontalSegments,
105                 sal_uInt32 nVerticalSegments,
106                 double fDiagonal,
107                 double fBackScale,
108                 double fRotation,
109                 bool bSmoothNormals,
110                 bool bSmoothHorizontalNormals,
111                 bool bSmoothLids,
112                 bool bCharacterMode,
113                 bool bCloseFront,
114                 bool bCloseBack);
115             virtual ~SdrLathePrimitive3D();
116 
117             /// data read access
getPolyPolygon() const118             const basegfx::B2DPolyPolygon& getPolyPolygon() const { return maPolyPolygon; }
getHorizontalSegments() const119             sal_uInt32 getHorizontalSegments() const { return mnHorizontalSegments; }
getVerticalSegments() const120             sal_uInt32 getVerticalSegments() const { return mnVerticalSegments; }
getDiagonal() const121             double getDiagonal() const { return mfDiagonal; }
getBackScale() const122             double getBackScale() const { return mfBackScale; }
getRotation() const123             double getRotation() const { return mfRotation; }
getSmoothNormals() const124             bool getSmoothNormals() const { return mbSmoothNormals; }
getSmoothHorizontalNormals() const125             bool getSmoothHorizontalNormals() const { return mbSmoothHorizontalNormals; }
getSmoothLids() const126             bool getSmoothLids() const { return mbSmoothLids; }
getCharacterMode() const127             bool getCharacterMode() const { return mbCharacterMode; }
getCloseFront() const128             bool getCloseFront() const { return mbCloseFront; }
getCloseBack() const129             bool getCloseBack() const { return mbCloseBack; }
130 
131             /// compare operator
132             virtual bool operator==(const BasePrimitive3D& rPrimitive) const;
133 
134             /// get range
135             virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const;
136 
137             /// Overloaded to allow for reduced line mode to decide if to buffer decomposition or not
138             virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const;
139 
140             /// provide unique ID
141             DeclPrimitrive3DIDBlock()
142         };
143     } // end of namespace primitive3d
144 } // end of namespace drawinglayer
145 
146 //////////////////////////////////////////////////////////////////////////////
147 
148 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE3D_SDRLATHEPRIMITIVE3D_HXX
149 
150 //////////////////////////////////////////////////////////////////////////////
151 // eof
152