1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <osl/diagnose.h>
21 #include <basegfx/polygon/b3dpolypolygontools.hxx>
22 #include <basegfx/range/b3drange.hxx>
23 #include <basegfx/polygon/b3dpolypolygon.hxx>
24 #include <basegfx/polygon/b3dpolygon.hxx>
25 #include <basegfx/polygon/b3dpolygontools.hxx>
26 #include <basegfx/matrix/b3dhommatrix.hxx>
27 #include <basegfx/numeric/ftools.hxx>
28 #include <com/sun/star/drawing/DoubleSequence.hpp>
29 #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
30 
31 // predefines
32 #define nMinSegments sal_uInt32(1)
33 #define nMaxSegments sal_uInt32(512)
34 
35 namespace basegfx
36 {
37     namespace utils
38     {
39         // B3DPolyPolygon tools
getRange(const B3DPolyPolygon & rCandidate)40         B3DRange getRange(const B3DPolyPolygon& rCandidate)
41         {
42             B3DRange aRetval;
43             const sal_uInt32 nPolygonCount(rCandidate.count());
44 
45             for(sal_uInt32 a(0); a < nPolygonCount; a++)
46             {
47                 const B3DPolygon& aCandidate = rCandidate.getB3DPolygon(a);
48                 aRetval.expand(getRange(aCandidate));
49             }
50 
51             return aRetval;
52         }
53 
createUnitCubePolyPolygon()54         B3DPolyPolygon const & createUnitCubePolyPolygon()
55         {
56             static auto const singleton = [] {
57                     B3DPolyPolygon aRetval;
58                     B3DPolygon aTemp;
59                     aTemp.append(B3DPoint(0.0, 0.0, 1.0));
60                     aTemp.append(B3DPoint(0.0, 1.0, 1.0));
61                     aTemp.append(B3DPoint(1.0, 1.0, 1.0));
62                     aTemp.append(B3DPoint(1.0, 0.0, 1.0));
63                     aTemp.setClosed(true);
64                     aRetval.append(aTemp);
65 
66                     aTemp.clear();
67                     aTemp.append(B3DPoint(0.0, 0.0, 0.0));
68                     aTemp.append(B3DPoint(0.0, 1.0, 0.0));
69                     aTemp.append(B3DPoint(1.0, 1.0, 0.0));
70                     aTemp.append(B3DPoint(1.0, 0.0, 0.0));
71                     aTemp.setClosed(true);
72                     aRetval.append(aTemp);
73 
74                     aTemp.clear();
75                     aTemp.append(B3DPoint(0.0, 0.0, 0.0));
76                     aTemp.append(B3DPoint(0.0, 0.0, 1.0));
77                     aRetval.append(aTemp);
78 
79                     aTemp.clear();
80                     aTemp.append(B3DPoint(0.0, 1.0, 0.0));
81                     aTemp.append(B3DPoint(0.0, 1.0, 1.0));
82                     aRetval.append(aTemp);
83 
84                     aTemp.clear();
85                     aTemp.append(B3DPoint(1.0, 1.0, 0.0));
86                     aTemp.append(B3DPoint(1.0, 1.0, 1.0));
87                     aRetval.append(aTemp);
88 
89                     aTemp.clear();
90                     aTemp.append(B3DPoint(1.0, 0.0, 0.0));
91                     aTemp.append(B3DPoint(1.0, 0.0, 1.0));
92                     aRetval.append(aTemp);
93                     return aRetval;
94                 }();
95             return singleton;
96         }
97 
createUnitCubeFillPolyPolygon()98         B3DPolyPolygon const & createUnitCubeFillPolyPolygon()
99         {
100             static auto const singleton = [] {
101                     B3DPolyPolygon aRetval;
102                     B3DPolygon aTemp;
103 
104                     // all points
105                     const B3DPoint A(0.0, 0.0, 0.0);
106                     const B3DPoint B(0.0, 1.0, 0.0);
107                     const B3DPoint C(1.0, 1.0, 0.0);
108                     const B3DPoint D(1.0, 0.0, 0.0);
109                     const B3DPoint E(0.0, 0.0, 1.0);
110                     const B3DPoint F(0.0, 1.0, 1.0);
111                     const B3DPoint G(1.0, 1.0, 1.0);
112                     const B3DPoint H(1.0, 0.0, 1.0);
113 
114                     // create bottom
115                     aTemp.append(D);
116                     aTemp.append(A);
117                     aTemp.append(E);
118                     aTemp.append(H);
119                     aTemp.setClosed(true);
120                     aRetval.append(aTemp);
121 
122                     // create front
123                     aTemp.clear();
124                     aTemp.append(B);
125                     aTemp.append(A);
126                     aTemp.append(D);
127                     aTemp.append(C);
128                     aTemp.setClosed(true);
129                     aRetval.append(aTemp);
130 
131                     // create left
132                     aTemp.clear();
133                     aTemp.append(E);
134                     aTemp.append(A);
135                     aTemp.append(B);
136                     aTemp.append(F);
137                     aTemp.setClosed(true);
138                     aRetval.append(aTemp);
139 
140                     // create top
141                     aTemp.clear();
142                     aTemp.append(C);
143                     aTemp.append(G);
144                     aTemp.append(F);
145                     aTemp.append(B);
146                     aTemp.setClosed(true);
147                     aRetval.append(aTemp);
148 
149                     // create right
150                     aTemp.clear();
151                     aTemp.append(H);
152                     aTemp.append(G);
153                     aTemp.append(C);
154                     aTemp.append(D);
155                     aTemp.setClosed(true);
156                     aRetval.append(aTemp);
157 
158                     // create back
159                     aTemp.clear();
160                     aTemp.append(F);
161                     aTemp.append(G);
162                     aTemp.append(H);
163                     aTemp.append(E);
164                     aTemp.setClosed(true);
165                     aRetval.append(aTemp);
166                     return aRetval;
167                 }();
168             return singleton;
169         }
170 
createCubePolyPolygonFromB3DRange(const B3DRange & rRange)171         B3DPolyPolygon createCubePolyPolygonFromB3DRange( const B3DRange& rRange)
172         {
173             B3DPolyPolygon aRetval;
174 
175             if(!rRange.isEmpty())
176             {
177                 aRetval = createUnitCubePolyPolygon();
178                 B3DHomMatrix aTrans;
179                 aTrans.scale(rRange.getWidth(), rRange.getHeight(), rRange.getDepth());
180                 aTrans.translate(rRange.getMinX(), rRange.getMinY(), rRange.getMinZ());
181                 aRetval.transform(aTrans);
182                 aRetval.removeDoublePoints();
183             }
184 
185             return aRetval;
186         }
187 
createCubeFillPolyPolygonFromB3DRange(const B3DRange & rRange)188         B3DPolyPolygon createCubeFillPolyPolygonFromB3DRange( const B3DRange& rRange)
189         {
190             B3DPolyPolygon aRetval;
191 
192             if(!rRange.isEmpty())
193             {
194                 aRetval = createUnitCubeFillPolyPolygon();
195                 B3DHomMatrix aTrans;
196                 aTrans.scale(rRange.getWidth(), rRange.getHeight(), rRange.getDepth());
197                 aTrans.translate(rRange.getMinX(), rRange.getMinY(), rRange.getMinZ());
198                 aRetval.transform(aTrans);
199                 aRetval.removeDoublePoints();
200             }
201 
202             return aRetval;
203         }
204 
205         // helper for getting the 3D Point from given cartesian coordinates. fHor is defined from
206         // [F_PI2 .. -F_PI2], fVer from [0.0 .. F_2PI]
getPointFromCartesian(double fHor,double fVer)207         static B3DPoint getPointFromCartesian(double fHor, double fVer)
208         {
209             const double fCosVer(cos(fVer));
210             return B3DPoint(fCosVer * cos(fHor), sin(fVer), fCosVer * -sin(fHor));
211         }
212 
createUnitSpherePolyPolygon(sal_uInt32 nHorSeg,sal_uInt32 nVerSeg,double fVerStart,double fVerStop,double fHorStart,double fHorStop)213         B3DPolyPolygon createUnitSpherePolyPolygon(
214             sal_uInt32 nHorSeg, sal_uInt32 nVerSeg,
215             double fVerStart, double fVerStop,
216             double fHorStart, double fHorStop)
217         {
218             B3DPolyPolygon aRetval;
219             sal_uInt32 a, b;
220 
221             if(!nHorSeg)
222             {
223                 nHorSeg = fround(fabs(fHorStop - fHorStart) / (F_2PI / 24.0));
224             }
225 
226             // min/max limitations
227             nHorSeg = std::min(nMaxSegments, std::max(nMinSegments, nHorSeg));
228 
229             if(!nVerSeg)
230             {
231                 nVerSeg = fround(fabs(fVerStop - fVerStart) / (F_2PI / 24.0));
232             }
233 
234             // min/max limitations
235             nVerSeg = std::min(nMaxSegments, std::max(nMinSegments, nVerSeg));
236 
237             // create constants
238             const double fVerDiffPerStep((fVerStop - fVerStart) / static_cast<double>(nVerSeg));
239             const double fHorDiffPerStep((fHorStop - fHorStart) / static_cast<double>(nHorSeg));
240             bool bHorClosed(fTools::equal(fHorStop - fHorStart, F_2PI));
241             bool bVerFromTop(fTools::equal(fVerStart, F_PI2));
242             bool bVerToBottom(fTools::equal(fVerStop, -F_PI2));
243 
244             // create horizontal rings
245             const sal_uInt32 nLoopVerInit(bVerFromTop ? 1 : 0);
246             const sal_uInt32 nLoopVerLimit(bVerToBottom ? nVerSeg : nVerSeg + 1);
247             const sal_uInt32 nLoopHorLimit(bHorClosed ? nHorSeg : nHorSeg + 1);
248 
249             for(a = nLoopVerInit; a < nLoopVerLimit; a++)
250             {
251                 const double fVer(fVerStart + (static_cast<double>(a) * fVerDiffPerStep));
252                 B3DPolygon aNew;
253 
254                 for(b = 0; b < nLoopHorLimit; b++)
255                 {
256                     const double fHor(fHorStart + (static_cast<double>(b) * fHorDiffPerStep));
257                     aNew.append(getPointFromCartesian(fHor, fVer));
258                 }
259 
260                 aNew.setClosed(bHorClosed);
261                 aRetval.append(aNew);
262             }
263 
264             // create vertical half-rings
265             for(a = 0; a < nLoopHorLimit; a++)
266             {
267                 const double fHor(fHorStart + (static_cast<double>(a) * fHorDiffPerStep));
268                 B3DPolygon aNew;
269 
270                 if(bVerFromTop)
271                 {
272                     aNew.append(B3DPoint(0.0, 1.0, 0.0));
273                 }
274 
275                 for(b = nLoopVerInit; b < nLoopVerLimit; b++)
276                 {
277                     const double fVer(fVerStart + (static_cast<double>(b) * fVerDiffPerStep));
278                     aNew.append(getPointFromCartesian(fHor, fVer));
279                 }
280 
281                 if(bVerToBottom)
282                 {
283                     aNew.append(B3DPoint(0.0, -1.0, 0.0));
284                 }
285 
286                 aRetval.append(aNew);
287             }
288 
289             return aRetval;
290         }
291 
createSpherePolyPolygonFromB3DRange(const B3DRange & rRange,sal_uInt32 nHorSeg,sal_uInt32 nVerSeg,double fVerStart,double fVerStop,double fHorStart,double fHorStop)292         B3DPolyPolygon createSpherePolyPolygonFromB3DRange( const B3DRange& rRange,
293             sal_uInt32 nHorSeg, sal_uInt32 nVerSeg,
294             double fVerStart, double fVerStop,
295             double fHorStart, double fHorStop)
296         {
297             B3DPolyPolygon aRetval(createUnitSpherePolyPolygon(nHorSeg, nVerSeg, fVerStart, fVerStop, fHorStart, fHorStop));
298 
299             if(aRetval.count())
300             {
301                 // move and scale whole construct which is now in [-1.0 .. 1.0] in all directions
302                 B3DHomMatrix aTrans;
303                 aTrans.translate(1.0, 1.0, 1.0);
304                 aTrans.scale(rRange.getWidth() / 2.0, rRange.getHeight() / 2.0, rRange.getDepth() / 2.0);
305                 aTrans.translate(rRange.getMinX(), rRange.getMinY(), rRange.getMinZ());
306                 aRetval.transform(aTrans);
307             }
308 
309             return aRetval;
310         }
311 
createUnitSphereFillPolyPolygon(sal_uInt32 nHorSeg,sal_uInt32 nVerSeg,bool bNormals,double fVerStart,double fVerStop,double fHorStart,double fHorStop)312         B3DPolyPolygon createUnitSphereFillPolyPolygon(
313             sal_uInt32 nHorSeg, sal_uInt32 nVerSeg,
314             bool bNormals,
315             double fVerStart, double fVerStop,
316             double fHorStart, double fHorStop)
317         {
318             B3DPolyPolygon aRetval;
319 
320             if(!nHorSeg)
321             {
322                 nHorSeg = fround(fabs(fHorStop - fHorStart) / (F_2PI / 24.0));
323             }
324 
325             // min/max limitations
326             nHorSeg = std::min(nMaxSegments, std::max(nMinSegments, nHorSeg));
327 
328             if(!nVerSeg)
329             {
330                 nVerSeg = fround(fabs(fVerStop - fVerStart) / (F_2PI / 24.0));
331             }
332 
333             // min/max limitations
334             nVerSeg = std::min(nMaxSegments, std::max(nMinSegments, nVerSeg));
335 
336             // vertical loop
337             for(sal_uInt32 a(0); a < nVerSeg; a++)
338             {
339                 const double fVer1(fVerStart + (((fVerStop - fVerStart) * a) / nVerSeg));
340                 const double fVer2(fVerStart + (((fVerStop - fVerStart) * (a + 1)) / nVerSeg));
341 
342                 // horizontal loop
343                 for(sal_uInt32 b(0); b < nHorSeg; b++)
344                 {
345                     const double fHor1(fHorStart + (((fHorStop - fHorStart) * b) / nHorSeg));
346                     const double fHor2(fHorStart + (((fHorStop - fHorStart) * (b + 1)) / nHorSeg));
347                     B3DPolygon aNew;
348 
349                     aNew.append(getPointFromCartesian(fHor1, fVer1));
350                     aNew.append(getPointFromCartesian(fHor2, fVer1));
351                     aNew.append(getPointFromCartesian(fHor2, fVer2));
352                     aNew.append(getPointFromCartesian(fHor1, fVer2));
353 
354                     if(bNormals)
355                     {
356                         for(sal_uInt32 c(0); c < aNew.count(); c++)
357                         {
358                             aNew.setNormal(c, ::basegfx::B3DVector(aNew.getB3DPoint(c)));
359                         }
360                     }
361 
362                     aNew.setClosed(true);
363                     aRetval.append(aNew);
364                 }
365             }
366 
367             return aRetval;
368         }
369 
createSphereFillPolyPolygonFromB3DRange(const B3DRange & rRange,sal_uInt32 nHorSeg,sal_uInt32 nVerSeg,bool bNormals,double fVerStart,double fVerStop,double fHorStart,double fHorStop)370         B3DPolyPolygon createSphereFillPolyPolygonFromB3DRange( const B3DRange& rRange,
371             sal_uInt32 nHorSeg, sal_uInt32 nVerSeg,
372             bool bNormals,
373             double fVerStart, double fVerStop,
374             double fHorStart, double fHorStop)
375         {
376             B3DPolyPolygon aRetval(createUnitSphereFillPolyPolygon(nHorSeg, nVerSeg, bNormals, fVerStart, fVerStop, fHorStart, fHorStop));
377 
378             if(aRetval.count())
379             {
380                 // move and scale whole construct which is now in [-1.0 .. 1.0] in all directions
381                 B3DHomMatrix aTrans;
382                 aTrans.translate(1.0, 1.0, 1.0);
383                 aTrans.scale(rRange.getWidth() / 2.0, rRange.getHeight() / 2.0, rRange.getDepth() / 2.0);
384                 aTrans.translate(rRange.getMinX(), rRange.getMinY(), rRange.getMinZ());
385                 aRetval.transform(aTrans);
386             }
387 
388             return aRetval;
389         }
390 
applyDefaultNormalsSphere(const B3DPolyPolygon & rCandidate,const B3DPoint & rCenter)391         B3DPolyPolygon applyDefaultNormalsSphere( const B3DPolyPolygon& rCandidate, const B3DPoint& rCenter)
392         {
393             B3DPolyPolygon aRetval;
394 
395             for(sal_uInt32 a(0); a < rCandidate.count(); a++)
396             {
397                 aRetval.append(applyDefaultNormalsSphere(rCandidate.getB3DPolygon(a), rCenter));
398             }
399 
400             return aRetval;
401         }
402 
invertNormals(const B3DPolyPolygon & rCandidate)403         B3DPolyPolygon invertNormals( const B3DPolyPolygon& rCandidate)
404         {
405             B3DPolyPolygon aRetval;
406 
407             for(sal_uInt32 a(0); a < rCandidate.count(); a++)
408             {
409                 aRetval.append(invertNormals(rCandidate.getB3DPolygon(a)));
410             }
411 
412             return aRetval;
413         }
414 
applyDefaultTextureCoordinatesParallel(const B3DPolyPolygon & rCandidate,const B3DRange & rRange,bool bChangeX,bool bChangeY)415         B3DPolyPolygon applyDefaultTextureCoordinatesParallel( const B3DPolyPolygon& rCandidate, const B3DRange& rRange, bool bChangeX, bool bChangeY)
416         {
417             B3DPolyPolygon aRetval;
418 
419             for(sal_uInt32 a(0); a < rCandidate.count(); a++)
420             {
421                 aRetval.append(applyDefaultTextureCoordinatesParallel(rCandidate.getB3DPolygon(a), rRange, bChangeX, bChangeY));
422             }
423 
424             return aRetval;
425         }
426 
applyDefaultTextureCoordinatesSphere(const B3DPolyPolygon & rCandidate,const B3DPoint & rCenter,bool bChangeX,bool bChangeY)427         B3DPolyPolygon applyDefaultTextureCoordinatesSphere( const B3DPolyPolygon& rCandidate, const B3DPoint& rCenter, bool bChangeX, bool bChangeY)
428         {
429             B3DPolyPolygon aRetval;
430 
431             for(sal_uInt32 a(0); a < rCandidate.count(); a++)
432             {
433                 aRetval.append(applyDefaultTextureCoordinatesSphere(rCandidate.getB3DPolygon(a), rCenter, bChangeX, bChangeY));
434             }
435 
436             return aRetval;
437         }
438 
isInside(const B3DPolyPolygon & rCandidate,const B3DPoint & rPoint)439         bool isInside(const B3DPolyPolygon& rCandidate, const B3DPoint& rPoint)
440         {
441             const sal_uInt32 nPolygonCount(rCandidate.count());
442 
443             if(nPolygonCount == 1)
444             {
445                 return isInside(rCandidate.getB3DPolygon(0), rPoint, false/*bWithBorder*/);
446             }
447             else
448             {
449                 sal_Int32 nInsideCount(0);
450 
451                 for(sal_uInt32 a(0); a < nPolygonCount; a++)
452                 {
453                     const B3DPolygon& aPolygon(rCandidate.getB3DPolygon(a));
454                     const bool bInside(isInside(aPolygon, rPoint, false/*bWithBorder*/));
455 
456                     if(bInside)
457                     {
458                         nInsideCount++;
459                     }
460                 }
461 
462                 return (nInsideCount % 2);
463             }
464         }
465 
466 /// converters for css::drawing::PolyPolygonShape3D
UnoPolyPolygonShape3DToB3DPolyPolygon(const css::drawing::PolyPolygonShape3D & rPolyPolygonShape3DSource)467         B3DPolyPolygon UnoPolyPolygonShape3DToB3DPolyPolygon(
468             const css::drawing::PolyPolygonShape3D& rPolyPolygonShape3DSource)
469         {
470             B3DPolyPolygon aRetval;
471             const sal_Int32 nOuterSequenceCount(rPolyPolygonShape3DSource.SequenceX.getLength());
472 
473             if(nOuterSequenceCount)
474             {
475                 OSL_ENSURE(nOuterSequenceCount == rPolyPolygonShape3DSource.SequenceY.getLength()
476                     && nOuterSequenceCount == rPolyPolygonShape3DSource.SequenceZ.getLength(),
477                     "UnoPolyPolygonShape3DToB3DPolygon: Not all double sequences have the same length (!)");
478 
479                 const css::drawing::DoubleSequence* pInnerSequenceX = rPolyPolygonShape3DSource.SequenceX.getConstArray();
480                 const css::drawing::DoubleSequence* pInnerSequenceY = rPolyPolygonShape3DSource.SequenceY.getConstArray();
481                 const css::drawing::DoubleSequence* pInnerSequenceZ = rPolyPolygonShape3DSource.SequenceZ.getConstArray();
482 
483                 for(sal_Int32 a(0); a < nOuterSequenceCount; a++)
484                 {
485                     basegfx::B3DPolygon aNewPolygon;
486                     const sal_Int32 nInnerSequenceCount(pInnerSequenceX->getLength());
487                     OSL_ENSURE(nInnerSequenceCount == pInnerSequenceY->getLength()
488                         && nInnerSequenceCount == pInnerSequenceZ->getLength(),
489                         "UnoPolyPolygonShape3DToB3DPolygon: Not all double sequences have the same length (!)");
490 
491                     const double* pArrayX = pInnerSequenceX->getConstArray();
492                     const double* pArrayY = pInnerSequenceY->getConstArray();
493                     const double* pArrayZ = pInnerSequenceZ->getConstArray();
494 
495                     for(sal_Int32 b(0); b < nInnerSequenceCount; b++)
496                     {
497                         aNewPolygon.append(basegfx::B3DPoint(*pArrayX++,*pArrayY++,*pArrayZ++));
498                     }
499 
500                     pInnerSequenceX++;
501                     pInnerSequenceY++;
502                     pInnerSequenceZ++;
503 
504                     // #i101520# correction is needed for imported polygons of old format,
505                     // see callers
506                     basegfx::utils::checkClosed(aNewPolygon);
507 
508                     aRetval.append(aNewPolygon);
509                 }
510             }
511 
512             return aRetval;
513         }
514 
B3DPolyPolygonToUnoPolyPolygonShape3D(const B3DPolyPolygon & rPolyPolygonSource,css::drawing::PolyPolygonShape3D & rPolyPolygonShape3DRetval)515         void B3DPolyPolygonToUnoPolyPolygonShape3D(
516             const B3DPolyPolygon& rPolyPolygonSource,
517             css::drawing::PolyPolygonShape3D& rPolyPolygonShape3DRetval)
518         {
519             const sal_uInt32 nPolygonCount(rPolyPolygonSource.count());
520 
521             if(nPolygonCount)
522             {
523                 rPolyPolygonShape3DRetval.SequenceX.realloc(nPolygonCount);
524                 rPolyPolygonShape3DRetval.SequenceY.realloc(nPolygonCount);
525                 rPolyPolygonShape3DRetval.SequenceZ.realloc(nPolygonCount);
526 
527                 css::drawing::DoubleSequence* pOuterSequenceX = rPolyPolygonShape3DRetval.SequenceX.getArray();
528                 css::drawing::DoubleSequence* pOuterSequenceY = rPolyPolygonShape3DRetval.SequenceY.getArray();
529                 css::drawing::DoubleSequence* pOuterSequenceZ = rPolyPolygonShape3DRetval.SequenceZ.getArray();
530 
531                 for(sal_uInt32 a(0); a < nPolygonCount; a++)
532                 {
533                     const basegfx::B3DPolygon& aPoly(rPolyPolygonSource.getB3DPolygon(a));
534                     const sal_uInt32 nPointCount(aPoly.count());
535 
536                     if(nPointCount)
537                     {
538                         const bool bIsClosed(aPoly.isClosed());
539                         const sal_uInt32 nTargetCount(bIsClosed ? nPointCount + 1 : nPointCount);
540                         pOuterSequenceX->realloc(nTargetCount);
541                         pOuterSequenceY->realloc(nTargetCount);
542                         pOuterSequenceZ->realloc(nTargetCount);
543 
544                         double* pInnerSequenceX = pOuterSequenceX->getArray();
545                         double* pInnerSequenceY = pOuterSequenceY->getArray();
546                         double* pInnerSequenceZ = pOuterSequenceZ->getArray();
547 
548                         for(sal_uInt32 b(0); b < nPointCount; b++)
549                         {
550                             const basegfx::B3DPoint aPoint(aPoly.getB3DPoint(b));
551 
552                             *pInnerSequenceX++ = aPoint.getX();
553                             *pInnerSequenceY++ = aPoint.getY();
554                             *pInnerSequenceZ++ = aPoint.getZ();
555                         }
556 
557                         if(bIsClosed)
558                         {
559                             const basegfx::B3DPoint aPoint(aPoly.getB3DPoint(0));
560 
561                             *pInnerSequenceX++ = aPoint.getX();
562                             *pInnerSequenceY++ = aPoint.getY();
563                             *pInnerSequenceZ++ = aPoint.getZ();
564                         }
565                     }
566                     else
567                     {
568                         pOuterSequenceX->realloc(0);
569                         pOuterSequenceY->realloc(0);
570                         pOuterSequenceZ->realloc(0);
571                     }
572 
573                     pOuterSequenceX++;
574                     pOuterSequenceY++;
575                     pOuterSequenceZ++;
576                 }
577             }
578             else
579             {
580                 rPolyPolygonShape3DRetval.SequenceX.realloc(0);
581                 rPolyPolygonShape3DRetval.SequenceY.realloc(0);
582                 rPolyPolygonShape3DRetval.SequenceZ.realloc(0);
583             }
584         }
585 
586     } // end of namespace utils
587 } // end of namespace basegfx
588 
589 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
590