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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_drawinglayer.hxx"
26 
27 #include <drawinglayer/primitive3d/sdrprimitive3d.hxx>
28 #include <basegfx/polygon/b3dpolypolygontools.hxx>
29 #include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx>
30 #include <drawinglayer/attribute/sdrlineattribute.hxx>
31 
32 //////////////////////////////////////////////////////////////////////////////
33 
34 using namespace com::sun::star;
35 
36 //////////////////////////////////////////////////////////////////////////////
37 
38 namespace drawinglayer
39 {
40 	namespace primitive3d
41 	{
getStandard3DRange() const42         basegfx::B3DRange SdrPrimitive3D::getStandard3DRange() const
43 		{
44 			basegfx::B3DRange aUnitRange(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
45 			aUnitRange.transform(getTransform());
46 
47 			if(!getSdrLFSAttribute().getLine().isDefault())
48 			{
49 				const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine();
50 
51 				if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth()))
52 				{
53 					// expand by hald LineWidth as tube radius
54 					aUnitRange.grow(rLine.getWidth() / 2.0);
55 				}
56 			}
57 
58 			return aUnitRange;
59 		}
60 
get3DRangeFromSlices(const Slice3DVector & rSlices) const61 		basegfx::B3DRange SdrPrimitive3D::get3DRangeFromSlices(const Slice3DVector& rSlices) const
62 		{
63 			basegfx::B3DRange aRetval;
64 
65 			if(rSlices.size())
66 			{
67 				for(sal_uInt32 a(0L); a < rSlices.size(); a++)
68 				{
69 					aRetval.expand(basegfx::tools::getRange(rSlices[a].getB3DPolyPolygon()));
70 				}
71 
72 				aRetval.transform(getTransform());
73 
74 				if(!getSdrLFSAttribute().getLine().isDefault())
75 				{
76 					const attribute::SdrLineAttribute& rLine = getSdrLFSAttribute().getLine();
77 
78 					if(!rLine.isDefault() && !basegfx::fTools::equalZero(rLine.getWidth()))
79 					{
80 						// expand by half LineWidth as tube radius
81 						aRetval.grow(rLine.getWidth() / 2.0);
82 					}
83 				}
84 			}
85 
86 			return aRetval;
87 		}
88 
SdrPrimitive3D(const basegfx::B3DHomMatrix & rTransform,const basegfx::B2DVector & rTextureSize,const attribute::SdrLineFillShadowAttribute3D & rSdrLFSAttribute,const attribute::Sdr3DObjectAttribute & rSdr3DObjectAttribute)89 		SdrPrimitive3D::SdrPrimitive3D(
90 			const basegfx::B3DHomMatrix& rTransform,
91 			const basegfx::B2DVector& rTextureSize,
92 			const attribute::SdrLineFillShadowAttribute3D& rSdrLFSAttribute,
93 			const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute)
94 		:	BufferedDecompositionPrimitive3D(),
95 			maTransform(rTransform),
96 			maTextureSize(rTextureSize),
97 			maSdrLFSAttribute(rSdrLFSAttribute),
98 			maSdr3DObjectAttribute(rSdr3DObjectAttribute)
99 		{
100 		}
101 
operator ==(const BasePrimitive3D & rPrimitive) const102 		bool SdrPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
103 		{
104 			if(BufferedDecompositionPrimitive3D::operator==(rPrimitive))
105 			{
106 				const SdrPrimitive3D& rCompare = static_cast< const SdrPrimitive3D& >(rPrimitive);
107 
108 				return (getTransform() == rCompare.getTransform()
109 					&& getTextureSize() == rCompare.getTextureSize()
110 					&& getSdrLFSAttribute() == rCompare.getSdrLFSAttribute()
111 					&& getSdr3DObjectAttribute() == rCompare.getSdr3DObjectAttribute());
112 			}
113 
114 			return false;
115 		}
116 
117 	} // end of namespace primitive3d
118 } // end of namespace drawinglayer
119 
120 //////////////////////////////////////////////////////////////////////////////
121 // eof
122