summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorArmin Weiss <aw@openoffice.org>2006-05-19 08:34:56 +0000
committerArmin Weiss <aw@openoffice.org>2006-05-19 08:34:56 +0000
commitae23ab2090b1f6899e291c98fd6c1dfd47278bdc (patch)
treee11134ffeb85632817cbfbd6d63c5667a2f7d25d /drawinglayer
parentbffc7386ec5082308da11079f15e2fd6ce842fd8 (diff)
#i39532# smooting of 3d
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/inc/drawinglayer/primitive3d/sdrextrudelathetools3d.hxx6
-rw-r--r--drawinglayer/inc/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx15
-rw-r--r--drawinglayer/inc/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx14
-rw-r--r--drawinglayer/inc/drawinglayer/primitive3d/sdrprimitive3d.hxx12
-rw-r--r--drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx22
-rw-r--r--drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx11
-rw-r--r--drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx46
-rw-r--r--drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx62
-rw-r--r--drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx84
-rw-r--r--drawinglayer/source/primitive3d/sdrprimitive3d.cxx36
-rw-r--r--drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx13
11 files changed, 207 insertions, 114 deletions
diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudelathetools3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudelathetools3d.hxx
index 8d5ddd02dd45..8a92166606fe 100644
--- a/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudelathetools3d.hxx
+++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudelathetools3d.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: sdrextrudelathetools3d.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2006-05-12 11:45:14 $
+ * last change: $Author: aw $ $Date: 2006-05-19 09:34:49 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -93,7 +93,7 @@ namespace drawinglayer
typedef ::std::vector< slice > sliceVector;
// helpers for creation
- bool createLatheSlices(sliceVector& rSliceVector, const ::basegfx::B2DPolyPolygon& rSource,
+ void createLatheSlices(sliceVector& rSliceVector, const ::basegfx::B2DPolyPolygon& rSource,
double fBackScale, double fDiagonal, double fRotation, sal_uInt32 nSteps,
bool bCharacterMode, bool bCloseFront, bool bCloseBack);
void createExtrudeSlices(sliceVector& rSliceVector, const ::basegfx::B2DPolyPolygon& rSource,
diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx
index 7c86df80ec5b..182de49c173b 100644
--- a/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx
+++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: sdrextrudeprimitive3d.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2006-05-12 11:45:14 $
+ * last change: $Author: aw $ $Date: 2006-05-19 09:34:50 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -55,6 +55,14 @@ namespace drawinglayer
{
class sdrExtrudePrimitive3D : public sdrPrimitive3D
{
+ private:
+ // create slices
+ void impCreateSlices();
+
+ // geometry helper for slices
+ ::basegfx::B2DPolyPolygon maCorrectedPolyPolygon;
+ sliceVector maSlices;
+
protected:
::basegfx::B2DPolyPolygon maPolyPolygon;
double mfDepth;
@@ -72,6 +80,9 @@ namespace drawinglayer
// create decomposition
virtual void decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation);
+ // get (evtl. create) slices
+ const sliceVector& getSlices() const;
+
public:
sdrExtrudePrimitive3D(
const ::basegfx::B3DHomMatrix& rTransform,
diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx
index 0847550c95bb..143f360e7e56 100644
--- a/drawinglayer/inc/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx
+++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: sdrlatheprimitive3d.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2006-05-12 11:45:14 $
+ * last change: $Author: aw $ $Date: 2006-05-19 09:34:50 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -55,6 +55,13 @@ namespace drawinglayer
{
class sdrLathePrimitive3D : public sdrPrimitive3D
{
+ private:
+ // create slices
+ void impCreateSlices();
+
+ // geometry helper for slices
+ sliceVector maSlices;
+
protected:
::basegfx::B2DPolyPolygon maPolyPolygon;
sal_uInt32 mnHorizontalSegments;
@@ -74,6 +81,9 @@ namespace drawinglayer
// create decomposition
virtual void decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation);
+ // get (evtl. create) slices
+ const sliceVector& getSlices() const;
+
public:
sdrLathePrimitive3D(
const ::basegfx::B3DHomMatrix& rTransform,
diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrprimitive3d.hxx
index 6ca56b460bcf..bdd5f44c0e83 100644
--- a/drawinglayer/inc/drawinglayer/primitive3d/sdrprimitive3d.hxx
+++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrprimitive3d.hxx
@@ -4,9 +4,9 @@
*
* $RCSfile: sdrprimitive3d.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2006-05-12 11:45:14 $
+ * last change: $Author: aw $ $Date: 2006-05-19 09:34:51 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -52,6 +52,10 @@
#include <drawinglayer/primitive3d/sdrattribute3d.hxx>
#endif
+#ifndef _DRAWINGLAYER_PRIMITIVE3D_SDREXTRUDELATHETOOLS3D_HXX
+#include <drawinglayer/primitive3d/sdrextrudelathetools3d.hxx>
+#endif
+
//////////////////////////////////////////////////////////////////////////////
// predefines
@@ -73,6 +77,10 @@ namespace drawinglayer
// will use maTransform as range and expand by evtl. line width / 2
::basegfx::B3DRange getStandard3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const;
+ // implementation for primitive3D which
+ // will use given slices and expand by evtl. line width / 2
+ ::basegfx::B3DRange get3DRangeFromSlices(const sliceVector& rSlices, const ::drawinglayer::geometry::viewInformation& rViewInformation) const;
+
public:
sdrPrimitive3D(
const ::basegfx::B3DHomMatrix& rTransform,
diff --git a/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx b/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx
index 144c59267778..b70e272e6118 100644
--- a/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx
+++ b/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: polygontubeprimitive3d.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2006-05-12 11:49:07 $
+ * last change: $Author: aw $ $Date: 2006-05-19 09:34:52 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -386,19 +386,13 @@ namespace drawinglayer
// build transformation from unit vector to vector
::basegfx::B3DHomMatrix aRetval;
- // extract rot angles from vector, first in XY
- const double fRotInXY(atan2(rVector.getY(), rVector.getX()));
+ // get applied rotations from angles in XY and in XZ (cartesian)
+ const double fRotInXY(atan2(rVector.getY(), rVector.getXZLength()));
+ const double fRotInXZ(atan2(-rVector.getZ(), rVector.getX()));
- // now get rot in XZ. Use negative Z due to right-handed system. Use XYLength as
- // X-Coordinate to get correct angle
- const double fRotInXZ(atan2(-rVector.getZ(), rVector.getXYLength()));
-
- // fill rotation. This will first rotate around Y, then around
- // Z, that's why the angles needed to be extracted in that order
- if(!::basegfx::fTools::equalZero(fRotInXY) || !::basegfx::fTools::equalZero(fRotInXZ))
- {
- aRetval.rotate(0.0, fRotInXZ, fRotInXY);
- }
+ // apply rotations. Rot around Z needs to be done first, so apply in two steps
+ aRetval.rotate(0.0, 0.0, fRotInXY);
+ aRetval.rotate(0.0, fRotInXZ, 0.0);
return aRetval;
}
diff --git a/drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx
index b5270cad199f..c7bcc3688206 100644
--- a/drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx
+++ b/drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: sdrcubeprimitive3d.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2006-05-12 11:49:07 $
+ * last change: $Author: aw $ $Date: 2006-05-19 09:34:53 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -224,7 +224,12 @@ namespace drawinglayer
::basegfx::B3DRange sdrCubePrimitive3D::get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const
{
- // use defaut from sdrPrimitive3D which uses transformation expanded by line width/2
+ // use defaut from sdrPrimitive3D which uses transformation expanded by line width/2.
+ // The parent implementation which uses the ranges of the breakdown would be more
+ // corrcet, but for historical reasons it is necessary to do the old method: To get
+ // the range of the non-transformed geometry and transform it then. This leads to different
+ // ranges where the new method is more correct, but the need to keep the old behaviour
+ // has priority here.
return getStandard3DRange(rViewInformation);
}
} // end of namespace primitive
diff --git a/drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx b/drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx
index 2a3f4c67d91c..4cfb233c2b18 100644
--- a/drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx
+++ b/drawinglayer/source/primitive3d/sdrextrudelathetools3d.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: sdrextrudelathetools3d.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2006-05-12 11:49:08 $
+ * last change: $Author: aw $ $Date: 2006-05-19 09:34:54 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -252,29 +252,31 @@ namespace
if(nPointCount)
{
- ::basegfx::B3DPoint aPrev(aSubA.getB3DPoint(nPointCount - 1L));
+ ::basegfx::B3DPoint aPrevA(aSubA.getB3DPoint(nPointCount - 1L));
::basegfx::B3DPoint aCurrA(aSubA.getB3DPoint(0L));
const bool bClosed(aSubA.isClosed());
for(sal_uInt32 b(0L); b < nPointCount; b++)
{
const sal_uInt32 nIndNext((b + 1L) % nPointCount);
- const ::basegfx::B3DPoint aNext(aSubA.getB3DPoint(nIndNext));
+ const ::basegfx::B3DPoint aNextA(aSubA.getB3DPoint(nIndNext));
const ::basegfx::B3DPoint aCurrB(aSubB.getB3DPoint(b));
// vector to back
::basegfx::B3DVector aDepth(aCurrB - aCurrA);
aDepth.normalize();
- // vector to left
- ::basegfx::B3DVector aLeft(aPrev - aCurrA);
-
- if(!bClosed && 0L == b)
+ if(aDepth.equalZero())
{
- // correct for non-closed lines
- aLeft = aCurrA - aNext;
+ // no difference, try to get depth from next point
+ const ::basegfx::B3DPoint aNextB(aSubB.getB3DPoint(nIndNext));
+ aDepth = aNextB - aNextA;
+ aDepth.normalize();
}
+ // vector to left (correct for non-closed lines)
+ const bool bFirstAndNotClosed(!bClosed && 0L == b);
+ ::basegfx::B3DVector aLeft(bFirstAndNotClosed ? aCurrA - aNextA : aPrevA - aCurrA);
aLeft.normalize();
// create left normal
@@ -282,15 +284,9 @@ namespace
if(bSmoothHorizontalNormals)
{
- // vector to right
- ::basegfx::B3DVector aRight(aNext - aCurrA);
-
- if(!bClosed && b + 1L == nPointCount)
- {
- // correct for non-closed lines
- aRight = aCurrA - aPrev;
- }
-
+ // vector to right (correct for non-closed lines)
+ const bool bLastAndNotClosed(!bClosed && b + 1L == nPointCount);
+ ::basegfx::B3DVector aRight(bLastAndNotClosed ? aCurrA - aPrevA : aNextA - aCurrA);
aRight.normalize();
// create right normal
@@ -312,8 +308,8 @@ namespace
}
// prepare next step
- aPrev = aCurrA;
- aCurrA = aNext;
+ aPrevA = aCurrA;
+ aCurrA = aNextA;
}
rPolA.setB3DPolygon(a, aSubA);
@@ -355,12 +351,10 @@ namespace drawinglayer
{
namespace primitive
{
- bool createLatheSlices(sliceVector& rSliceVector, const ::basegfx::B2DPolyPolygon& rSource,
+ void createLatheSlices(sliceVector& rSliceVector, const ::basegfx::B2DPolyPolygon& rSource,
double fBackScale, double fDiagonal, double fRotation, sal_uInt32 nSteps,
bool bCharacterMode, bool bCloseFront, bool bCloseBack)
{
- bool bClosedRotation(false);
-
if(::basegfx::fTools::equalZero(fRotation) || 0L == nSteps)
{
// no rotation or no steps, just one plane
@@ -369,7 +363,7 @@ namespace drawinglayer
else
{
const bool bBackScale(!::basegfx::fTools::equal(fBackScale, 1.0));
- bClosedRotation = (!bBackScale && ::basegfx::fTools::equal(fRotation, F_2PI));
+ const bool bClosedRotation(!bBackScale && ::basegfx::fTools::equal(fRotation, F_2PI));
::basegfx::B2DPolyPolygon aFront(rSource);
::basegfx::B2DPolyPolygon aBack(rSource);
::basegfx::B3DHomMatrix aTransformBack;
@@ -441,8 +435,6 @@ namespace drawinglayer
rSliceVector.push_back(slice(aOuterBack, aTransformBack, SLICETYPE_BACKCAP));
}
}
-
- return bClosedRotation;
}
void createExtrudeSlices(sliceVector& rSliceVector, const ::basegfx::B2DPolyPolygon& rSource,
diff --git a/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx
index b49fd0df12e5..d2ee6898c75b 100644
--- a/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx
+++ b/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: sdrextrudeprimitive3d.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2006-05-12 11:49:08 $
+ * last change: $Author: aw $ $Date: 2006-05-19 09:34:55 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -73,22 +73,11 @@ namespace drawinglayer
{
void sdrExtrudePrimitive3D::decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation)
{
- if(maPolyPolygon.count())
- {
- ::basegfx::B2DPolyPolygon aCandidate(maPolyPolygon);
- sliceVector aSliceVector;
-
- if(getSdrLFSAttribute().getFill() || getSdrLFSAttribute().getLine())
- {
- // prepare the polygon
- aCandidate.removeDoublePoints();
- aCandidate = ::basegfx::tools::correctOrientations(aCandidate);
- aCandidate = ::basegfx::tools::correctOutmostPolygon(aCandidate);
-
- // prepare slices as geometry
- createExtrudeSlices(aSliceVector, aCandidate, mfBackScale, mfDiagonal, mfDepth, mbCharacterMode, mbCloseFront, mbCloseBack);
- }
+ // get slices
+ const sliceVector& rSliceVector = getSlices();
+ if(rSliceVector.size())
+ {
// add fill
if(getSdrLFSAttribute().getFill())
{
@@ -104,7 +93,7 @@ namespace drawinglayer
if(bCreateTextureCoordiantesX || bCreateTextureCoordiantesY)
{
- const ::basegfx::B2DPolygon aFirstPolygon(aCandidate.getB2DPolygon(0L));
+ const ::basegfx::B2DPolygon aFirstPolygon(maCorrectedPolyPolygon.getB2DPolygon(0L));
const double fFrontLength(::basegfx::tools::getLength(aFirstPolygon));
const double fFrontArea(::basegfx::tools::getArea(aFirstPolygon));
const double fSqrtFrontArea(sqrt(fFrontArea));
@@ -124,7 +113,7 @@ namespace drawinglayer
// create geometry
::std::vector< ::basegfx::B3DPolyPolygon > aFill;
- extractPlanesFromSlice(aFill, aSliceVector,
+ extractPlanesFromSlice(aFill, rSliceVector,
bCreateNormals, mbSmoothHorizontalNormals, mbSmoothNormals, mbSmoothLids, false,
0.5, 0.6, bCreateTextureCoordiantesX || bCreateTextureCoordiantesY, aTexTransform);
@@ -216,7 +205,7 @@ namespace drawinglayer
if(getSdrLFSAttribute().getLine())
{
::basegfx::B3DPolyPolygon aLine;
- extractLinesFromSlice(aLine, aSliceVector, false);
+ extractLinesFromSlice(aLine, rSliceVector, false);
add3DPolyPolygonLinePrimitive(aLine, maTransform, rTarget, *maSdrLFSAttribute.getLine());
}
@@ -228,6 +217,30 @@ namespace drawinglayer
}
}
+ void sdrExtrudePrimitive3D::impCreateSlices()
+ {
+ maCorrectedPolyPolygon = maPolyPolygon;
+
+ // prepare the polygon
+ maCorrectedPolyPolygon.removeDoublePoints();
+ maCorrectedPolyPolygon = ::basegfx::tools::correctOrientations(maCorrectedPolyPolygon);
+ maCorrectedPolyPolygon = ::basegfx::tools::correctOutmostPolygon(maCorrectedPolyPolygon);
+
+ // prepare slices as geometry
+ createExtrudeSlices(maSlices, maCorrectedPolyPolygon, mfBackScale, mfDiagonal, mfDepth, mbCharacterMode, mbCloseFront, mbCloseBack);
+ }
+
+ const sliceVector& sdrExtrudePrimitive3D::getSlices() const
+ {
+ if(maPolyPolygon.count() && !maSlices.size() && (getSdrLFSAttribute().getFill() || getSdrLFSAttribute().getLine()))
+ {
+ ::osl::Mutex m_mutex;
+ const_cast< sdrExtrudePrimitive3D& >(*this).impCreateSlices();
+ }
+
+ return maSlices;
+ }
+
sdrExtrudePrimitive3D::sdrExtrudePrimitive3D(
const ::basegfx::B3DHomMatrix& rTransform,
const ::basegfx::B2DVector& rTextureSize,
@@ -324,8 +337,13 @@ namespace drawinglayer
::basegfx::B3DRange sdrExtrudePrimitive3D::get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const
{
- // call parent, use decomposition
- return sdrPrimitive3D::get3DRange(rViewInformation);
+ // use defaut from sdrPrimitive3D which uses transformation expanded by line width/2
+ // The parent implementation which uses the ranges of the breakdown would be more
+ // corrcet, but for historical reasons it is necessary to do the old method: To get
+ // the range of the non-transformed geometry and transform it then. This leads to different
+ // ranges where the new method is more correct, but the need to keep the old behaviour
+ // has priority here.
+ return get3DRangeFromSlices(getSlices(), rViewInformation);
}
} // end of namespace primitive
} // end of namespace drawinglayer
diff --git a/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx
index d48e7676b24d..81f1b7539d40 100644
--- a/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx
+++ b/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: sdrlatheprimitive3d.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2006-05-12 11:49:08 $
+ * last change: $Author: aw $ $Date: 2006-05-19 09:34:55 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -69,34 +69,13 @@ namespace drawinglayer
{
void sdrLathePrimitive3D::decompose(primitiveList& rTarget, const ::drawinglayer::geometry::viewInformation& rViewInformation)
{
- if(maPolyPolygon.count())
- {
- ::basegfx::B2DPolyPolygon aCandidate(maPolyPolygon);
- sliceVector aSliceVector;
- bool bClosedRotation(false);
-
- if(getSdrLFSAttribute().getFill() || getSdrLFSAttribute().getLine())
- {
- // prepare the polygon
- aCandidate = ::basegfx::tools::adaptiveSubdivideByDistance(aCandidate);
- aCandidate.removeDoublePoints();
- aCandidate = ::basegfx::tools::correctOrientations(aCandidate);
- aCandidate = ::basegfx::tools::correctOutmostPolygon(aCandidate);
-
- // check edge count of first sub-polygon. If different, reSegment polyPolygon. This ensures
- // that for polyPolygons, the subPolys 1..n only get reSegmented when polygon 0L is different
- // at all (and not always)
- const ::basegfx::B2DPolygon aSubCandidate(aCandidate.getB2DPolygon(0L));
- const sal_uInt32 nSubEdgeCount(aSubCandidate.isClosed() ? aSubCandidate.count() : (aSubCandidate.count() ? aSubCandidate.count() - 1L : 0L));
-
- if(nSubEdgeCount != mnVerticalSegments)
- {
- aCandidate = ::basegfx::tools::reSegmentPolyPolygon(aCandidate, mnVerticalSegments);
- }
+ // get slices
+ const sliceVector& rSliceVector = getSlices();
- // prepare slices as geometry
- bClosedRotation = createLatheSlices(aSliceVector, aCandidate, mfBackScale, mfDiagonal, mfRotation, mnHorizontalSegments, mbCharacterMode, mbCloseFront, mbCloseBack);
- }
+ if(rSliceVector.size())
+ {
+ const bool bBackScale(!::basegfx::fTools::equal(mfBackScale, 1.0));
+ const bool bClosedRotation(!bBackScale && mnHorizontalSegments && ::basegfx::fTools::equal(mfRotation, F_2PI));
// add fill
if(getSdrLFSAttribute().getFill())
@@ -124,7 +103,7 @@ namespace drawinglayer
// create geometry
::std::vector< ::basegfx::B3DPolyPolygon > aFill;
- extractPlanesFromSlice(aFill, aSliceVector,
+ extractPlanesFromSlice(aFill, rSliceVector,
bCreateNormals, mbSmoothHorizontalNormals, mbSmoothNormals, mbSmoothLids, bClosedRotation,
0.85, 0.6, bCreateTextureCoordiantesX || bCreateTextureCoordiantesY, aTexTransform);
@@ -216,7 +195,7 @@ namespace drawinglayer
if(getSdrLFSAttribute().getLine())
{
::basegfx::B3DPolyPolygon aLine;
- extractLinesFromSlice(aLine, aSliceVector, bClosedRotation);
+ extractLinesFromSlice(aLine, rSliceVector, bClosedRotation);
add3DPolyPolygonLinePrimitive(aLine, maTransform, rTarget, *maSdrLFSAttribute.getLine());
}
@@ -228,6 +207,40 @@ namespace drawinglayer
}
}
+ void sdrLathePrimitive3D::impCreateSlices()
+ {
+ // prepare the polygon
+ ::basegfx::B2DPolyPolygon aCandidate(::basegfx::tools::adaptiveSubdivideByDistance(maPolyPolygon));
+ aCandidate.removeDoublePoints();
+ aCandidate = ::basegfx::tools::correctOrientations(aCandidate);
+ aCandidate = ::basegfx::tools::correctOutmostPolygon(aCandidate);
+
+ // check edge count of first sub-polygon. If different, reSegment polyPolygon. This ensures
+ // that for polyPolygons, the subPolys 1..n only get reSegmented when polygon 0L is different
+ // at all (and not always)
+ const ::basegfx::B2DPolygon aSubCandidate(aCandidate.getB2DPolygon(0L));
+ const sal_uInt32 nSubEdgeCount(aSubCandidate.isClosed() ? aSubCandidate.count() : (aSubCandidate.count() ? aSubCandidate.count() - 1L : 0L));
+
+ if(nSubEdgeCount != mnVerticalSegments)
+ {
+ aCandidate = ::basegfx::tools::reSegmentPolyPolygon(aCandidate, mnVerticalSegments);
+ }
+
+ // prepare slices as geometry
+ createLatheSlices(maSlices, aCandidate, mfBackScale, mfDiagonal, mfRotation, mnHorizontalSegments, mbCharacterMode, mbCloseFront, mbCloseBack);
+ }
+
+ const sliceVector& sdrLathePrimitive3D::getSlices() const
+ {
+ if(maPolyPolygon.count() && !maSlices.size() && (getSdrLFSAttribute().getFill() || getSdrLFSAttribute().getLine()))
+ {
+ ::osl::Mutex m_mutex;
+ const_cast< sdrLathePrimitive3D& >(*this).impCreateSlices();
+ }
+
+ return maSlices;
+ }
+
sdrLathePrimitive3D::sdrLathePrimitive3D(
const ::basegfx::B3DHomMatrix& rTransform,
const ::basegfx::B2DVector& rTextureSize,
@@ -328,8 +341,13 @@ namespace drawinglayer
::basegfx::B3DRange sdrLathePrimitive3D::get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const
{
- // call parent, use decomposition
- return sdrPrimitive3D::get3DRange(rViewInformation);
+ // use defaut from sdrPrimitive3D which uses transformation expanded by line width/2
+ // The parent implementation which uses the ranges of the breakdown would be more
+ // corrcet, but for historical reasons it is necessary to do the old method: To get
+ // the range of the non-transformed geometry and transform it then. This leads to different
+ // ranges where the new method is more correct, but the need to keep the old behaviour
+ // has priority here.
+ return get3DRangeFromSlices(getSlices(), rViewInformation);
}
} // end of namespace primitive
} // end of namespace drawinglayer
diff --git a/drawinglayer/source/primitive3d/sdrprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrprimitive3d.cxx
index f4326340b3a6..9d3ece4288c1 100644
--- a/drawinglayer/source/primitive3d/sdrprimitive3d.cxx
+++ b/drawinglayer/source/primitive3d/sdrprimitive3d.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: sdrprimitive3d.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2006-05-12 11:49:08 $
+ * last change: $Author: aw $ $Date: 2006-05-19 09:34:56 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -41,6 +41,10 @@
#include <drawinglayer/primitive/sdrattribute.hxx>
#endif
+#ifndef _BGFX_POLYPOLYGON_B3DPOLYGONTOOLS_HXX
+#include <basegfx/polygon/b3dpolypolygontools.hxx>
+#endif
+
//////////////////////////////////////////////////////////////////////////////
namespace drawinglayer
@@ -66,6 +70,34 @@ namespace drawinglayer
return aUnitRange;
}
+ ::basegfx::B3DRange sdrPrimitive3D::get3DRangeFromSlices(const sliceVector& rSlices, const ::drawinglayer::geometry::viewInformation& rViewInformation) const
+ {
+ ::basegfx::B3DRange aRetval;
+
+ if(rSlices.size())
+ {
+ for(sal_uInt32 a(0L); a < rSlices.size(); a++)
+ {
+ aRetval.expand(::basegfx::tools::getRange(rSlices[a].getB3DPolyPolygon()));
+ }
+
+ aRetval.transform(getTransform());
+
+ if(maSdrLFSAttribute.getLine())
+ {
+ const sdrLineAttribute& rLine = *maSdrLFSAttribute.getLine();
+
+ if(rLine.isVisible() && !::basegfx::fTools::equalZero(rLine.getWidth()))
+ {
+ // expand by hald LineWidth as tube radius
+ aRetval.grow(rLine.getWidth() / 2.0);
+ }
+ }
+ }
+
+ return aRetval;
+ }
+
sdrPrimitive3D::sdrPrimitive3D(
const ::basegfx::B3DHomMatrix& rTransform,
const ::basegfx::B2DVector& rTextureSize,
diff --git a/drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx
index 66c0a7abf559..e6c6a1f68040 100644
--- a/drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx
+++ b/drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: sdrsphereprimitive3d.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: aw $ $Date: 2006-05-12 11:49:08 $
+ * last change: $Author: aw $ $Date: 2006-05-19 09:34:56 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -216,8 +216,13 @@ namespace drawinglayer
::basegfx::B3DRange sdrSpherePrimitive3D::get3DRange(const ::drawinglayer::geometry::viewInformation& rViewInformation) const
{
- // call parent, use decomposition
- return sdrPrimitive3D::get3DRange(rViewInformation);
+ // use defaut from sdrPrimitive3D which uses transformation expanded by line width/2
+ // The parent implementation which uses the ranges of the breakdown would be more
+ // corrcet, but for historical reasons it is necessary to do the old method: To get
+ // the range of the non-transformed geometry and transform it then. This leads to different
+ // ranges where the new method is more correct, but the need to keep the old behaviour
+ // has priority here.
+ return getStandard3DRange(rViewInformation);
}
} // end of namespace primitive
} // end of namespace drawinglayer