1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Stripe.cxx,v $
10 * $Revision: 1.6.44.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "CommonConverters.hxx"
35 #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
36 #include <com/sun/star/drawing/DoubleSequence.hpp>
37 #include <basegfx/polygon/b3dpolygon.hxx>
38 #include <basegfx/polygon/b3dpolygontools.hxx>
40 using namespace ::com::sun::star
;
42 //.............................................................................
45 //.............................................................................
47 Stripe::Stripe( const drawing::Position3D
& rPoint1
48 , const drawing::Direction3D
& rDirectionToPoint2
49 , const drawing::Direction3D
& rDirectionToPoint4
)
51 , m_aPoint2(rPoint1
+rDirectionToPoint2
)
52 , m_aPoint3(m_aPoint2
+rDirectionToPoint4
)
53 , m_aPoint4(rPoint1
+rDirectionToPoint4
)
58 Stripe::Stripe( const drawing::Position3D
& rPoint1
59 , const drawing::Position3D
& rPoint2
66 m_aPoint3
.PositionZ
+= fDepth
;
67 m_aPoint4
.PositionZ
+= fDepth
;
71 Stripe::Stripe( const drawing::Position3D& rPoint1
72 , const drawing::Position3D& rPoint2
73 , const drawing::Position3D& rPoint3
74 , const drawing::Position3D& rPoint4 )
84 uno::Any
Stripe::getPolyPolygonShape3D() const
86 drawing::PolyPolygonShape3D aPP
;
88 aPP
.SequenceX
.realloc(1);
89 aPP
.SequenceY
.realloc(1);
90 aPP
.SequenceZ
.realloc(1);
92 drawing::DoubleSequence
* pOuterSequenceX
= aPP
.SequenceX
.getArray();
93 drawing::DoubleSequence
* pOuterSequenceY
= aPP
.SequenceY
.getArray();
94 drawing::DoubleSequence
* pOuterSequenceZ
= aPP
.SequenceZ
.getArray();
96 pOuterSequenceX
->realloc(4);
97 pOuterSequenceY
->realloc(4);
98 pOuterSequenceZ
->realloc(4);
100 double* pInnerSequenceX
= pOuterSequenceX
->getArray();
101 double* pInnerSequenceY
= pOuterSequenceY
->getArray();
102 double* pInnerSequenceZ
= pOuterSequenceZ
->getArray();
104 *pInnerSequenceX
++ = m_aPoint1
.PositionX
;
105 *pInnerSequenceY
++ = m_aPoint1
.PositionY
;
106 *pInnerSequenceZ
++ = m_aPoint1
.PositionZ
;
108 *pInnerSequenceX
++ = m_aPoint2
.PositionX
;
109 *pInnerSequenceY
++ = m_aPoint2
.PositionY
;
110 *pInnerSequenceZ
++ = m_aPoint2
.PositionZ
;
112 *pInnerSequenceX
++ = m_aPoint3
.PositionX
;
113 *pInnerSequenceY
++ = m_aPoint3
.PositionY
;
114 *pInnerSequenceZ
++ = m_aPoint3
.PositionZ
;
116 *pInnerSequenceX
++ = m_aPoint4
.PositionX
;
117 *pInnerSequenceY
++ = m_aPoint4
.PositionY
;
118 *pInnerSequenceZ
++ = m_aPoint4
.PositionZ
;
120 return uno::Any( &aPP
, ::getCppuType((const drawing::PolyPolygonShape3D
*)0) );
123 drawing::Direction3D
Stripe::getNormal() const
125 ::basegfx::B3DPolygon aPolygon3D
;
126 aPolygon3D
.append(Position3DToB3DPoint( m_aPoint1
));
127 aPolygon3D
.append(Position3DToB3DPoint( m_aPoint2
));
128 aPolygon3D
.append(Position3DToB3DPoint( m_aPoint3
));
129 ::basegfx::B3DVector
aNormal(::basegfx::tools::getNormal(aPolygon3D
));
130 return B3DVectorToDirection3D(aNormal
);
133 uno::Any
Stripe::getNormalsPolygon() const
135 drawing::PolyPolygonShape3D aPP
;
137 aPP
.SequenceX
.realloc(1);
138 aPP
.SequenceY
.realloc(1);
139 aPP
.SequenceZ
.realloc(1);
141 drawing::DoubleSequence
* pOuterSequenceX
= aPP
.SequenceX
.getArray();
142 drawing::DoubleSequence
* pOuterSequenceY
= aPP
.SequenceY
.getArray();
143 drawing::DoubleSequence
* pOuterSequenceZ
= aPP
.SequenceZ
.getArray();
145 pOuterSequenceX
->realloc(4);
146 pOuterSequenceY
->realloc(4);
147 pOuterSequenceZ
->realloc(4);
149 double* pInnerSequenceX
= pOuterSequenceX
->getArray();
150 double* pInnerSequenceY
= pOuterSequenceY
->getArray();
151 double* pInnerSequenceZ
= pOuterSequenceZ
->getArray();
153 drawing::Direction3D
aNormal( getNormal() );
155 for(sal_Int32 nN
=4; --nN
; )
157 *pInnerSequenceX
++ = aNormal
.DirectionX
;
158 *pInnerSequenceY
++ = aNormal
.DirectionY
;
159 *pInnerSequenceZ
++ = aNormal
.DirectionZ
;
161 return uno::Any( &aPP
, ::getCppuType((const drawing::PolyPolygonShape3D
*)0) );
164 uno::Any
Stripe::getTexturePolygon( bool bRotatedTexture
) const
166 drawing::PolyPolygonShape3D aPP
;
168 aPP
.SequenceX
.realloc(1);
169 aPP
.SequenceY
.realloc(1);
170 aPP
.SequenceZ
.realloc(1);
172 drawing::DoubleSequence
* pOuterSequenceX
= aPP
.SequenceX
.getArray();
173 drawing::DoubleSequence
* pOuterSequenceY
= aPP
.SequenceY
.getArray();
174 drawing::DoubleSequence
* pOuterSequenceZ
= aPP
.SequenceZ
.getArray();
176 pOuterSequenceX
->realloc(4);
177 pOuterSequenceY
->realloc(4);
178 pOuterSequenceZ
->realloc(4);
180 double* pInnerSequenceX
= pOuterSequenceX
->getArray();
181 double* pInnerSequenceY
= pOuterSequenceY
->getArray();
182 double* pInnerSequenceZ
= pOuterSequenceZ
->getArray();
184 if( !bRotatedTexture
)
186 *pInnerSequenceX
++ = 0.0;
187 *pInnerSequenceY
++ = 0.0;
188 *pInnerSequenceZ
++ = 0.0;
190 *pInnerSequenceX
++ = 1.0;
191 *pInnerSequenceY
++ = 0.0;
192 *pInnerSequenceZ
++ = 0.0;
194 *pInnerSequenceX
++ = 1.0;
195 *pInnerSequenceY
++ = 1.0;
196 *pInnerSequenceZ
++ = 0.0;
198 *pInnerSequenceX
++ = 0.0;
199 *pInnerSequenceY
++ = 1.0;
200 *pInnerSequenceZ
++ = 0.0;
204 *pInnerSequenceX
++ = 1.0;
205 *pInnerSequenceY
++ = 0.0;
206 *pInnerSequenceZ
++ = 0.0;
208 *pInnerSequenceX
++ = 1.0;
209 *pInnerSequenceY
++ = 1.0;
210 *pInnerSequenceZ
++ = 0.0;
212 *pInnerSequenceX
++ = 0.0;
213 *pInnerSequenceY
++ = 1.0;
214 *pInnerSequenceZ
++ = 0.0;
216 *pInnerSequenceX
++ = 0.0;
217 *pInnerSequenceY
++ = 0.0;
218 *pInnerSequenceZ
++ = 0.0;
221 return uno::Any( &aPP
, ::getCppuType((const drawing::PolyPolygonShape3D
*)0) );
224 //.............................................................................
226 //.............................................................................