27#include <com/sun/star/drawing/DoubleSequence.hpp>
28#include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
31#define nMinSegments sal_uInt32(1)
32#define nMaxSegments sal_uInt32(512)
41 for(
const auto& rPolygon : rCandidate )
51 static auto const singleton = [] {
95 static auto const singleton = [] {
204 const double fCosVer(cos(fVer));
205 return B3DPoint(fCosVer * cos(fHor), sin(fVer), fCosVer * -sin(fHor));
209 sal_uInt32 nHorSeg, sal_uInt32 nVerSeg,
210 double fVerStart,
double fVerStop,
211 double fHorStart,
double fHorStop)
218 nHorSeg =
fround(fabs(fHorStop - fHorStart) / (M_PI / 12.0));
226 nVerSeg =
fround(fabs(fVerStop - fVerStart) / (M_PI / 12.0));
233 const double fVerDiffPerStep((fVerStop - fVerStart) /
static_cast<double>(nVerSeg));
234 const double fHorDiffPerStep((fHorStop - fHorStart) /
static_cast<double>(nHorSeg));
235 bool bHorClosed(
fTools::equal(fHorStop - fHorStart, 2 * M_PI));
240 const sal_uInt32 nLoopVerInit(bVerFromTop ? 1 : 0);
241 const sal_uInt32 nLoopVerLimit(bVerToBottom ? nVerSeg : nVerSeg + 1);
242 const sal_uInt32 nLoopHorLimit(bHorClosed ? nHorSeg : nHorSeg + 1);
244 for(
a = nLoopVerInit;
a < nLoopVerLimit;
a++)
246 const double fVer(fVerStart + (
static_cast<double>(
a) * fVerDiffPerStep));
249 for(b = 0; b < nLoopHorLimit; b++)
251 const double fHor(fHorStart + (
static_cast<double>(b) * fHorDiffPerStep));
260 for(
a = 0;
a < nLoopHorLimit;
a++)
262 const double fHor(fHorStart + (
static_cast<double>(
a) * fHorDiffPerStep));
270 for(b = nLoopVerInit; b < nLoopVerLimit; b++)
272 const double fVer(fVerStart + (
static_cast<double>(b) * fVerDiffPerStep));
288 sal_uInt32 nHorSeg, sal_uInt32 nVerSeg,
289 double fVerStart,
double fVerStop,
290 double fHorStart,
double fHorStop)
308 sal_uInt32 nHorSeg, sal_uInt32 nVerSeg,
310 double fVerStart,
double fVerStop,
311 double fHorStart,
double fHorStop)
317 nHorSeg =
fround(fabs(fHorStop - fHorStart) / (M_PI / 12.0));
325 nVerSeg =
fround(fabs(fVerStop - fVerStart) / (M_PI / 12.0));
332 for(sal_uInt32
a(0);
a < nVerSeg;
a++)
334 const double fVer1(fVerStart + (((fVerStop - fVerStart) *
a) / nVerSeg));
335 const double fVer2(fVerStart + (((fVerStop - fVerStart) * (
a + 1)) / nVerSeg));
338 for(sal_uInt32 b(0); b < nHorSeg; b++)
340 const double fHor1(fHorStart + (((fHorStop - fHorStart) * b) / nHorSeg));
341 const double fHor2(fHorStart + (((fHorStop - fHorStart) * (b + 1)) / nHorSeg));
351 for(sal_uInt32 c(0); c < aNew.
count(); c++)
366 sal_uInt32 nHorSeg, sal_uInt32 nVerSeg,
368 double fVerStart,
double fVerStop,
369 double fHorStart,
double fHorStop)
390 for(
const auto& rB3DPolygon : rCandidate)
402 for(
const auto& rB3DPolygon : rCandidate )
414 for(
const auto& rB3DPolygon : rCandidate)
426 for(
const auto& rB3DPolygon : rCandidate )
436 const sal_uInt32 nPolygonCount(rCandidate.
count());
438 if(nPolygonCount == 1)
444 sal_Int32 nInsideCount(0);
446 for(
const auto& rPolygon : rCandidate )
448 const bool bInside(
isInside(rPolygon, rPoint,
false));
456 return (nInsideCount % 2);
462 const css::drawing::PolyPolygonShape3D& rPolyPolygonShape3DSource)
465 const sal_Int32 nOuterSequenceCount(rPolyPolygonShape3DSource.SequenceX.getLength());
467 if(nOuterSequenceCount)
469 assert(nOuterSequenceCount == rPolyPolygonShape3DSource.SequenceY.getLength()
470 && nOuterSequenceCount
471 == rPolyPolygonShape3DSource.SequenceZ.getLength()&&
472 "UnoPolyPolygonShape3DToB3DPolygon: Not all double sequences have the same "
475 const css::drawing::DoubleSequence* pInnerSequenceX = rPolyPolygonShape3DSource.SequenceX.getConstArray();
476 const css::drawing::DoubleSequence* pInnerSequenceY = rPolyPolygonShape3DSource.SequenceY.getConstArray();
477 const css::drawing::DoubleSequence* pInnerSequenceZ = rPolyPolygonShape3DSource.SequenceZ.getConstArray();
479 for(sal_Int32
a(0);
a < nOuterSequenceCount;
a++)
482 const sal_Int32 nInnerSequenceCount(pInnerSequenceX->getLength());
483 assert(nInnerSequenceCount == pInnerSequenceY->getLength()
484 && nInnerSequenceCount == pInnerSequenceZ->getLength()
485 &&
"UnoPolyPolygonShape3DToB3DPolygon: Not all double sequences have "
486 "the same length (!)");
488 const double* pArrayX = pInnerSequenceX->getConstArray();
489 const double* pArrayY = pInnerSequenceY->getConstArray();
490 const double* pArrayZ = pInnerSequenceZ->getConstArray();
492 for(sal_Int32 b(0); b < nInnerSequenceCount; b++)
505 aRetval.
append(aNewPolygon);
514 css::drawing::PolyPolygonShape3D& rPolyPolygonShape3DRetval)
516 const sal_uInt32 nPolygonCount(rPolyPolygonSource.
count());
520 rPolyPolygonShape3DRetval.SequenceX.realloc(nPolygonCount);
521 rPolyPolygonShape3DRetval.SequenceY.realloc(nPolygonCount);
522 rPolyPolygonShape3DRetval.SequenceZ.realloc(nPolygonCount);
524 css::drawing::DoubleSequence* pOuterSequenceX = rPolyPolygonShape3DRetval.SequenceX.getArray();
525 css::drawing::DoubleSequence* pOuterSequenceY = rPolyPolygonShape3DRetval.SequenceY.getArray();
526 css::drawing::DoubleSequence* pOuterSequenceZ = rPolyPolygonShape3DRetval.SequenceZ.getArray();
528 for(sal_uInt32
a(0);
a < nPolygonCount;
a++)
531 const sal_uInt32 nPointCount(aPoly.
count());
535 const bool bIsClosed(aPoly.
isClosed());
536 const sal_uInt32 nTargetCount(bIsClosed ? nPointCount + 1 : nPointCount);
537 pOuterSequenceX->realloc(nTargetCount);
538 pOuterSequenceY->realloc(nTargetCount);
539 pOuterSequenceZ->realloc(nTargetCount);
541 double* pInnerSequenceX = pOuterSequenceX->getArray();
542 double* pInnerSequenceY = pOuterSequenceY->getArray();
543 double* pInnerSequenceZ = pOuterSequenceZ->getArray();
545 for(sal_uInt32 b(0); b < nPointCount; b++)
549 *pInnerSequenceX++ = aPoint.
getX();
550 *pInnerSequenceY++ = aPoint.
getY();
551 *pInnerSequenceZ++ = aPoint.
getZ();
558 *pInnerSequenceX++ = aPoint.
getX();
559 *pInnerSequenceY++ = aPoint.
getY();
560 *pInnerSequenceZ++ = aPoint.
getZ();
565 pOuterSequenceX->realloc(0);
566 pOuterSequenceY->realloc(0);
567 pOuterSequenceZ->realloc(0);
577 rPolyPolygonShape3DRetval.SequenceX.realloc(0);
578 rPolyPolygonShape3DRetval.SequenceY.realloc(0);
579 rPolyPolygonShape3DRetval.SequenceZ.realloc(0);
void translate(double fX, double fY, double fZ)
Translation.
void scale(double fX, double fY, double fZ)
Scaling.
Base Point class with three double values.
void transform(const basegfx::B3DHomMatrix &rMatrix)
void append(const B3DPolygon &rPolygon, sal_uInt32 nCount=1)
void removeDoublePoints()
B3DPolygon const & getB3DPolygon(sal_uInt32 nIndex) const
void append(const B3DPoint &rPoint, sal_uInt32 nCount=1)
B3DPoint const & getB3DPoint(sal_uInt32 nIndex) const
void setNormal(sal_uInt32 nIndex, const B3DVector &rValue)
void setClosed(bool bNew)
void expand(const B3DTuple &rTuple)
Base Point class with three double values.
TYPE getX() const
Get X-Coordinate of 3D Tuple.
TYPE getZ() const
Get Z-Coordinate of 3D Tuple.
TYPE getY() const
Get Y-Coordinate of 3D Tuple.
B3DPolyPolygon createCubePolyPolygonFromB3DRange(const B3DRange &rRange)
Create a 3D line polyPolygon from a B3DRange which defines a cube.
B3DPolygon applyDefaultTextureCoordinatesSphere(const B3DPolygon &rCandidate, const B3DPoint &rCenter, bool bChangeX, bool bChangeY)
Create/replace texture coordinates for given 3d geometry with spherical one rCenter: the centre of th...
B3DPolyPolygon createSphereFillPolyPolygonFromB3DRange(const B3DRange &rRange, sal_uInt32 nHorSeg, sal_uInt32 nVerSeg, bool bNormals, double fVerStart, double fVerStop, double fHorStart, double fHorStop)
same as createSpherePolyPolygonFromB3DRange, but creates filled polygons (closed and oriented) There ...
static B3DPoint getPointFromCartesian(double fHor, double fVer)
B3DPolyPolygon createCubeFillPolyPolygonFromB3DRange(const B3DRange &rRange)
Create a 3D fill polyPolygon from a B3DRange which defines a cube.
bool isInside(const B2DPolygon &rCandidate, const B2DPoint &rPoint, bool bWithBorder)
B3DPolygon applyDefaultNormalsSphere(const B3DPolygon &rCandidate, const B3DPoint &rCenter)
Create/replace normals for given 3d geometry with default normals from given center to outside.
B3DPolyPolygon createSpherePolyPolygonFromB3DRange(const B3DRange &rRange, sal_uInt32 nHorSeg, sal_uInt32 nVerSeg, double fVerStart, double fVerStop, double fHorStart, double fHorStop)
Create a 3D line polyPolygon from a B3DRange which defines a sphere with the given count of hor and v...
void B3DPolyPolygonToUnoPolyPolygonShape3D(const B3DPolyPolygon &rPolyPolygonSource, css::drawing::PolyPolygonShape3D &rPolyPolygonShape3DRetval)
B3DPolyPolygon const & createUnitCubeFillPolyPolygon()
Create a unit 3D fill polyPolygon which defines a cube.
B3DPolyPolygon createUnitSphereFillPolyPolygon(sal_uInt32 nHorSeg, sal_uInt32 nVerSeg, bool bNormals, double fVerStart, double fVerStop, double fHorStart, double fHorStop)
same as createUnitSpherePolyPolygon, but creates filled polygons (closed and oriented) There is one e...
B3DPolyPolygon UnoPolyPolygonShape3DToB3DPolyPolygon(const css::drawing::PolyPolygonShape3D &rPolyPolygonShape3DSource)
converters for css::drawing::PolyPolygonShape3D
B3DPolyPolygon const & createUnitCubePolyPolygon()
Create a unit 3D line polyPolygon which defines a cube.
B3DPolygon invertNormals(const B3DPolygon &rCandidate)
invert normals for given 3d geometry.
B3DPolygon applyDefaultTextureCoordinatesParallel(const B3DPolygon &rCandidate, const B3DRange &rRange, bool bChangeX, bool bChangeY)
Create/replace texture coordinates for given 3d geometry with parallel projected one rRange: the full...
B3DPolyPolygon createUnitSpherePolyPolygon(sal_uInt32 nHorSeg, sal_uInt32 nVerSeg, double fVerStart, double fVerStop, double fHorStart, double fHorStop)
Create a unit 3D line polyPolygon which defines a sphere with the given count of hor and ver segments...
void checkClosed(B2DPolygon &rCandidate)
Check if given polygon is closed.
B2DRange getRange(const B2DPolygon &rCandidate)
Get the range of a polygon.
B2IRange fround(const B2DRange &rRange)
Round double to nearest integer for 2D range.