diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2007-04-11 19:33:08 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2007-04-11 19:33:08 +0000 |
commit | 495ef45bd297dad85ed4677d3cf7168ebcd60d76 (patch) | |
tree | dfe901809c836c030bc0f415b7ef947e518507ad /goodies | |
parent | c1f340a3078e3cf1ebdb9381deee7ac44fe6bcfa (diff) |
INTEGRATION: CWS hedaburemove01 (1.1.2); FILE ADDED
2007/02/09 16:13:37 vg 1.1.2.1: #72503# get rid of hedabu procedure: Moving headers to goodies/inc/goodies and correspondent necessary changes
Diffstat (limited to 'goodies')
-rw-r--r-- | goodies/inc/goodies/base3d.hxx | 485 | ||||
-rw-r--r-- | goodies/inc/goodies/bucket.hxx | 204 | ||||
-rw-r--r-- | goodies/inc/goodies/bxdintpo.hxx | 190 |
3 files changed, 879 insertions, 0 deletions
diff --git a/goodies/inc/goodies/base3d.hxx b/goodies/inc/goodies/base3d.hxx new file mode 100644 index 000000000000..5e6ad71fa9ca --- /dev/null +++ b/goodies/inc/goodies/base3d.hxx @@ -0,0 +1,485 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: base3d.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: vg $ $Date: 2007-04-11 20:32:50 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _B3D_BASE3D_HXX +#define _B3D_BASE3D_HXX + +#ifndef _B3D_B3DLIGHT_HXX +#include <goodies/b3dlight.hxx> +#endif + +//#ifndef _B3D_HMATRIX_HXX +//#include "hmatrix.hxx" +//#endif + +#ifndef _B3D_B3DENTITY_HXX +#include <goodies/b3dentty.hxx> +#endif + +#ifndef _B3D_B3DCOMPO_HXX +#include <goodies/b3dcompo.hxx> +#endif + +#ifndef _INC_FLOAT +#include <float.h> +#endif + +// MUSS-Aenderung +#ifndef _SV_OUTDEV3D_HXX +#include <vcl/outdev3d.hxx> +#endif + +#ifndef _SV_TIMER_HXX +#include <vcl/timer.hxx> +#endif + +#ifndef _VOS_MUTEX_HXX_ +#include <vos/mutex.hxx> +#endif + +#ifndef _SV_GEN_HXX +#include <tools/gen.hxx> +#endif + +// Vorausdeklarationen +class B3dTexture; +class OutputDevice; +class Bitmap; +class BitmapEx; +class TextureAttributes; +class B3dTransformationSet; + +/************************************************************************* +|* +|* Texturenverwaltung +|* +\************************************************************************/ + +SV_DECL_PTRARR_DEL(B3dTextureStore, B3dTexture*, 0, 4) + +/************************************************************************* +|* +|* Globale Daten fuer Base3D +|* +\************************************************************************/ + +class B3dGlobalData +{ +private: + // Texturverwaltung + Container maTextureStore; + AutoTimer maTimer; + vos::OMutex maMutex; + + // link for timer + DECL_LINK(TimerHdl, AutoTimer*); + +public: + B3dGlobalData(); + virtual ~B3dGlobalData(); + + B3dTexture* ObtainTexture(TextureAttributes& rAtt); + void InsertTexture(B3dTexture* pNew); + void DeleteTexture(B3dTexture* pOld); + void DeleteAllTextures(); +}; + +/************************************************************************* +|* +|* Bisher vorhandene Renderer +|* +\************************************************************************/ + +#define BASE3D_TYPE_DEFAULT 0x0000 +#define BASE3D_TYPE_OPENGL 0x0001 +#define BASE3D_TYPE_PRINTER 0x0002 + +/************************************************************************* +|* +|* Moegliche Objekttypen fuer Primitive +|* +\************************************************************************/ + +enum Base3DObjectMode +{ + + // die folgenden Primitive muessen von jedem abgeleiteten Renderer + // ausgefuehrt werden koennen + + Base3DPoints = 0, + Base3DLines, + Base3DLineLoop, + Base3DLineStrip, + Base3DTriangles, + Base3DTriangleStrip, + Base3DTriangleFan, + Base3DQuads, + Base3DQuadStrip, + Base3DPolygon, + + // ab hier beginnen hoehere Primitive, die mit speziellen Methoden + // innerhalb von Base3D auf die obenstehenden Primitive + // abgebildet werden. Diese Methoden tun dies alles im object + // coordinate system. + + // PolyPolygon ohne Selbstueberschneidungen und ohne + // Ueberschneidungen der evtl. vorhandenen Teilpolygone + Base3DComplexPolygon, + + // Beliebiges PolyPolygon mit Selbstueberschneidungen und + // Ueberschneidungen der weiteren Teilpolygone + Base3DComplexPolygonCut +}; + +/************************************************************************* +|* +|* Moegliche Darstellungsarten fuer Primitive +|* +\************************************************************************/ + +enum Base3DRenderMode +{ + Base3DRenderNone = 0, + Base3DRenderPoint, + Base3DRenderLine, + Base3DRenderFill +}; + +/************************************************************************* +|* +|* Moegliche CullingModes fuer Polygone +|* +\************************************************************************/ + +enum Base3DCullMode +{ + Base3DCullNone = 0, + Base3DCullFront, + Base3DCullBack +}; + +/************************************************************************* +|* +|* Moegliche ShadeModels fuer Polygone +|* +\************************************************************************/ + +enum Base3DShadeModel +{ + Base3DSmooth = 0, + Base3DFlat, + Base3DPhong +}; + +/************************************************************************* +|* +|* Unterstuetzung PolygonOffset +|* +\************************************************************************/ + +enum Base3DPolygonOffset +{ + Base3DPolygonOffsetFill = 1, + Base3DPolygonOffsetLine, + Base3DPolygonOffsetPoint +}; + +/************************************************************************* +|* +|* Genauigkeit der Berechnungen; im Zweifelsfall wird dieser +|* Wert benutzt, um mit 0.0 zu vergleichen oder Abstaende von +|* Randvereichen von Wertebereichen zu testen +|* +\************************************************************************/ + +#define SMALL_DVALUE (0.0000001) + +/************************************************************************* +|* +|* Die Basisklasse fuer alle 3D Ausgaben +|* +\************************************************************************/ + +class Base3D : public OutDev3D +{ +private: + // das OutputDevice, das Ziel dieser Base3D Engine ist. Wird bereits + // im Konstruktor uebergeben und kann nicht veraendert werden. + OutputDevice* pDevice; + + // ObjectCreationMode + Base3DObjectMode eObjectMode; + + // current color and alpha blending + Color aCurrentColor; + + // Komplexe Polygone + B3dComplexPolygon aComplexPolygon; + + // RenderMode + Base3DRenderMode eRenderModeFront; + Base3DRenderMode eRenderModeBack; + + // ShadeMode fuer Polygone + Base3DShadeModel eShadeModel; + + // CullingMode + Base3DCullMode eCullMode; + + // PointSize, LineWidth + double fPointSize; + double fLineWidth; + + // Scissor Region + Rectangle aScissorRectangle; + + // Texture store + B3dTexture* pActiveTexture; + + // Aktuelles TransformationSet + B3dTransformationSet* pTransformationSet; + + // Aktuelle Beleuchtung + B3dLightGroup* pLightGroup; + + // Materialien + B3dMaterial aMaterialFront; + B3dMaterial aMaterialBack; + + // Darstellungsqualitaet (0..255) + UINT8 nDisplayQuality; + + // EdgeFlag + unsigned bEdgeFlag : 1; + + // Gueltigkeit des Kontextes, wird in + // den Konstruktoren gesetzt + unsigned bContextIsValid : 1; + + // Variablen fuer PolygonOffset + unsigned bPolyOffsetFill : 1; + unsigned bPolyOffsetLine : 1; + unsigned bPolyOffsetPoint : 1; + + // Scissor-Region gesetzt? + unsigned bScissorRegionActive : 1; + + // Dithern? + unsigned bDitherActive : 1; + + // Hint auf transparente Anteile in der Szene + unsigned bTransparentParts : 1; + + // FlatMode force switch + unsigned bForceFlat : 1; + +protected: + // Konstruktor, Destruktor + Base3D(OutputDevice* pOutDev); + virtual ~Base3D(); + + // setze das ContextIsValid - Flag + void SetContextIsValid(BOOL bNew=TRUE) + { bContextIsValid=bNew; } + + static Base3D* CreateScreenRenderer(OutputDevice* pDev); + +public: + // Typbestimmung + virtual UINT16 GetBase3DType()=0; + + // Zugriff auf das zu verwendende OutputDevice + OutputDevice* GetOutputDevice() const { return pDevice; } + + // Hint auf transparente Anteile in der Szene setzen/lesen + void SetTransparentPartsContainedHint(BOOL bNew) { bTransparentParts = bNew; } + BOOL GetTransparentPartsContainedHint() const { return bTransparentParts; } + + // Zugriff auf globale Daten von allen Base3D's +private: + B3dGlobalData& GetGlobalData(); +public: + + // Erzeugen bzw. Zerstoeren eines Base3D Kontextes + static Base3D* Create(OutputDevice* pOutDev, BOOL bForcePrinter=FALSE); +#if SUPD > 375 + virtual void Destroy(OutputDevice *pOutDev); +#else + void Destroy(OutputDevice *pOutDev); +#endif + + // Gueltigkeit des Kontextes nach der Inkarnation + // ueberpruefen + BOOL IsContextValid() + { return bContextIsValid; } +#ifdef DBG_UTIL + void SetContextValid(BOOL bNew=TRUE) { bContextIsValid = bNew; } +#endif + + // TransformationSet setzen/lesen + virtual void SetTransformationSet(B3dTransformationSet* pSet); + B3dTransformationSet* GetTransformationSet() { return pTransformationSet; } + + // Beleuchtung setzen/lesen + virtual void SetLightGroup(B3dLightGroup* pSet, BOOL bSetGlobal=TRUE); + B3dLightGroup* GetLightGroup() { return pLightGroup; } + + // Szenenverwaltung + virtual void StartScene() = 0; + virtual void EndScene() = 0; + + // Scissoring + virtual void SetScissorRegionPixel(const Rectangle& rRect, BOOL bActivate=TRUE); + void SetScissorRegion(const Rectangle& rRect, BOOL bActivate=TRUE); + virtual void ActivateScissorRegion(BOOL bNew); + BOOL IsScissorRegionActive() { return bScissorRegionActive; } + const Rectangle& GetScissorRegionPixel() { return aScissorRectangle; } + + // Dithering aktiv? + BOOL GetDither() const { return bDitherActive; } + virtual void SetDither(BOOL bNew); + + // Dithering aktiv? + BOOL GetForceFlat() const { return bForceFlat; } + void SetForceFlat(BOOL bNew) { bForceFlat = bNew; } + + // Attribute Color (und Alpha) + virtual void SetColor(Color aNew); + virtual Color GetColor(); + + // Materials + virtual void SetMaterial(Color aNew, + Base3DMaterialValue=Base3DMaterialAmbient, + Base3DMaterialMode=Base3DMaterialFrontAndBack); + Color GetMaterial(Base3DMaterialValue=Base3DMaterialAmbient, + Base3DMaterialMode=Base3DMaterialFrontAndBack) const; + virtual void SetShininess(UINT16 nExponent, + Base3DMaterialMode=Base3DMaterialFrontAndBack); + UINT16 GetShininess(Base3DMaterialMode=Base3DMaterialFrontAndBack) const; + void ResetMaterial(Base3DMaterialMode=Base3DMaterialFrontAndBack); + + // Texturen + B3dTexture* ObtainTexture(TextureAttributes& rAtt); + B3dTexture* ObtainTexture(TextureAttributes& rAtt, BitmapEx& rBitmapEx); + void DeleteTexture(TextureAttributes& rAtt); + void DeleteAllTextures(); +private: + virtual B3dTexture* CreateTexture(TextureAttributes& rAtt, BitmapEx& rBitmapEx); +protected: + virtual void DestroyTexture(B3dTexture*); +public: + virtual void SetActiveTexture(B3dTexture* pTex=NULL); + B3dTexture* GetActiveTexture() { return pActiveTexture; } + BOOL IsTextureActive() const { return (pActiveTexture != NULL) ? TRUE : FALSE; } + + // Darstellungsqualitaet + virtual void SetDisplayQuality(UINT8 nNew); + UINT8 GetDisplayQuality() const; + + // PolygonOffset + virtual void SetPolygonOffset( + Base3DPolygonOffset eNew=Base3DPolygonOffsetLine, BOOL bNew=FALSE); + BOOL GetPolygonOffset(Base3DPolygonOffset eNew=Base3DPolygonOffsetLine) const; + + // RenderMode + virtual void SetRenderMode(Base3DRenderMode eNew, + Base3DMaterialMode=Base3DMaterialFrontAndBack); + Base3DRenderMode GetRenderMode( + Base3DMaterialMode=Base3DMaterialFrontAndBack) const; + + // ShadeModel + virtual void SetShadeModel(Base3DShadeModel eNew); + Base3DShadeModel GetShadeModel() const; + + // CullingMode + virtual void SetCullMode(Base3DCullMode eNew); + Base3DCullMode GetCullMode() const; + + // EdgeFlagMode + BOOL GetEdgeFlag() const; + virtual void SetEdgeFlag(BOOL bNew=TRUE); + + // PointSize, LineWidth + double GetPointSize() const; + virtual void SetPointSize(double fNew=1.0); + double GetLineWidth() const; + virtual void SetLineWidth(double fNew=1.0); + + // geometrische Objekte hinzufuegen + // Modus setzen + Base3DObjectMode GetObjectMode() const; + + // geometrische Daten + void AddVertex(basegfx::B3DPoint& rVertex); + void AddVertex(basegfx::B3DPoint& rVertex, basegfx::B3DVector& rNormal); + void AddVertex(basegfx::B3DPoint& rVertex, basegfx::B3DVector& rNormal, basegfx::B2DPoint& rTexPos); + void AddVertex(B3dEntity& rEnt); + void PostAddVertex(B3dEntity& rEnt); + + // Geometrische Daten uebergeben + virtual B3dEntity& GetFreeEntity(); + + // Primitiv beginnen/abschliessen + void StartPrimitive(Base3DObjectMode eMode); + void EndPrimitive(); + + // Ein Objekt in Form einer B3dGeometry direkt ausgeben + virtual void DrawPolygonGeometry(const B3dGeometry& rGeometry, sal_Bool bOutline=FALSE); + +#ifdef DBG_UTIL + // Testfunktion um gezielte 3D-Ausgaben zu testen + void Test(const Rectangle& rBound, const Rectangle& rVisible); +#endif + +protected: + // geometrische Daten uebergeben + virtual void ImplPostAddVertex(B3dEntity& rEnt) = 0; + + // Direkter Zugriff auf B3dMaterial + // fuer abgeleitete Klassen + B3dMaterial& GetMaterialObject(Base3DMaterialMode=Base3DMaterialFront); + + // Primitiv beginnen/abschliessen + virtual void ImplStartPrimitive() = 0; + virtual void ImplEndPrimitive() = 0; + + // Geometrische Daten uebergeben + virtual B3dEntity& ImplGetFreeEntity() = 0; + + // Funktionen, um mit hoeheren Primitiven umzugehen + void HandleComplexPolygon(); +}; + +#endif // _B3D_BASE3D_HXX diff --git a/goodies/inc/goodies/bucket.hxx b/goodies/inc/goodies/bucket.hxx new file mode 100644 index 000000000000..173a95633a7e --- /dev/null +++ b/goodies/inc/goodies/bucket.hxx @@ -0,0 +1,204 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: bucket.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: vg $ $Date: 2007-04-11 20:32:58 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _B3D_BUCKET_HXX +#define _B3D_BUCKET_HXX + +#ifndef _SVARRAY_HXX +#include <svtools/svarray.hxx> +#endif + +/************************************************************************* +|* +|* Bucket deklarator +|* +\************************************************************************/ + +#define BASE3D_DECL_BUCKET(TheClassName,TheExtension) \ + SV_DECL_VARARR(TheClassName##TheExtension##MemArr, char*, 32, 32) \ + class TheClassName##TheExtension { \ + private: \ + TheClassName##TheExtension##MemArr aMemArray; \ + UINT32 nMask; \ + UINT32 nCount; \ + INT16 nFreeMemArray; \ + INT16 nActMemArray; \ + UINT16 nFreeEntry; \ + UINT16 nShift; \ + UINT16 nBlockShift; \ + UINT16 nEntriesPerArray; \ + UINT16 nSlotSize; \ + UINT16 nNext; \ + UINT16 nMemArray; \ + public: \ + TheClassName##TheExtension(UINT16 TheSize); \ + /* Notwendiger Leer-Konstruktor, benutzt default-Groesse 8 */ \ + TheClassName##TheExtension(); \ + /* Zu verwendende Groesse der Speicherarrays setzen */ \ + /* Bitte NUR verwenden, falls sich der Leerkonstruktor */ \ + /* nicht vermeiden laesst! Nicht nachtraeglich anwenden! */ \ + void InitializeSize(UINT16 TheSize); \ + /* Destruktor */ \ + ~TheClassName##TheExtension(); \ + /* Anhaengen und kopieren */ \ + BOOL Append(TheClassName& rVec) \ + { if(CareForSpace()) return ImplAppend(rVec); return FALSE; } \ + /* nur neuen Eintrag anhaengen, ohne ausfuellen */ \ + BOOL Append() \ + { if(CareForSpace()) return ImplAppend(); return FALSE; } \ + /* Letzten Eintrag entfernen */ \ + BOOL Remove() { if(nCount) return ImplRemove(); return FALSE; } \ + /* leeren und Speicher freigeben */ \ + void Empty(); \ + /* leeren aber Speicher behalten */ \ + void Erase(); \ + TheClassName& operator[] (UINT32 nPos); \ + const TheClassName& operator[] (UINT32 nPos) const; \ + UINT32 Count() const { return nCount; } \ + UINT32 GetNumAllocated() const { return aMemArray.Count() * nEntriesPerArray; } \ + void operator=(const TheClassName##TheExtension&); \ + UINT16 GetBlockShift() const { return nBlockShift; } \ + UINT16 GetSlotSize() const { return nSlotSize; } \ + private: \ + BOOL CareForSpace() \ + { if(nFreeEntry == nEntriesPerArray) \ + return ImplCareForSpace(); return TRUE; } \ + BOOL ImplCareForSpace(); \ + /* Anhaengen und kopieren */ \ + BOOL ImplAppend(TheClassName& rVec); \ + /* nur neuen Eintrag anhaengen, ohne ausfuellen */ \ + BOOL ImplAppend(); \ + BOOL ImplRemove(); \ + }; + +/************************************************************************* +|* +|* Bucket implementor +|* +\************************************************************************/ + +#define BASE3D_IMPL_BUCKET(TheClassName,TheExtension) \ + SV_IMPL_VARARR(TheClassName##TheExtension##MemArr, char*) \ + TheClassName##TheExtension::TheClassName##TheExtension(UINT16 TheSize) { \ + InitializeSize(TheSize); \ + } \ + TheClassName##TheExtension::TheClassName##TheExtension() { \ + InitializeSize(8); \ + } \ + void TheClassName##TheExtension::InitializeSize(UINT16 TheSize) { \ + UINT16 nSiz; \ + for(nShift=0,nSiz=1;nSiz<sizeof(TheClassName);nSiz<<=1,nShift++); \ + nBlockShift = TheSize - nShift; \ + nMask = (1L << nBlockShift)-1L; \ + nSlotSize = 1<<nShift; \ + nEntriesPerArray = (UINT16)((1L << TheSize) >> nShift); \ + Empty(); \ + } \ + void TheClassName##TheExtension::operator=(const TheClassName##TheExtension& rObj) { \ + Erase(); \ + TheClassName##TheExtension& rSrc = (TheClassName##TheExtension&)rObj; \ + for(UINT32 a=0;a<rSrc.Count();a++) \ + Append(rSrc[a]); \ + } \ + void TheClassName##TheExtension::Empty() { \ + for(UINT16 i=0;i<aMemArray.Count();i++) \ + /*#90353#*/ delete [] aMemArray[i]; \ + if(aMemArray.Count()) \ + aMemArray.Remove(0, aMemArray.Count()); \ + nFreeMemArray = 0; \ + nActMemArray = -1; \ + Erase(); \ + } \ + void TheClassName##TheExtension::Erase() { \ + nFreeEntry = nEntriesPerArray; \ + nCount = 0; \ + nActMemArray = -1; \ + } \ + TheClassName##TheExtension::~TheClassName##TheExtension() { \ + Empty(); \ + } \ + BOOL TheClassName##TheExtension::ImplAppend(TheClassName& rVec) { \ + *((TheClassName*)(aMemArray[nActMemArray] + (nFreeEntry++ << nShift))) = rVec; \ + nCount++; \ + return TRUE; \ + } \ + BOOL TheClassName##TheExtension::ImplAppend() { \ + nFreeEntry++; \ + nCount++; \ + return TRUE; \ + } \ + BOOL TheClassName##TheExtension::ImplRemove() { \ + if(nFreeEntry == 1) { \ + nFreeEntry = nEntriesPerArray + 1; \ + if(nActMemArray == -1) \ + return FALSE; \ + nActMemArray--; \ + } \ + nFreeEntry--; \ + nCount--; \ + return TRUE; \ + } \ + BOOL TheClassName##TheExtension::ImplCareForSpace() { \ + /* neues array bestimmem */ \ + if(nActMemArray + 1 < nFreeMemArray) { \ + /* ist scon allokiert, gehe auf naechstes */ \ + nActMemArray++; \ + } else { \ + /* neues muss allokiert werden */ \ + char* pNew = new char[nEntriesPerArray << nShift]; \ + if(!pNew) \ + return FALSE; \ + aMemArray.Insert((const char*&) pNew, aMemArray.Count()); \ + nActMemArray = nFreeMemArray++; \ + } \ + nFreeEntry = 0; \ + return TRUE; \ + } \ + TheClassName& TheClassName##TheExtension::operator[] (UINT32 nPos) { \ + if(nPos >= nCount) { \ + DBG_ERROR("Access to Bucket out of range!"); \ + return *((TheClassName*)aMemArray[0]); \ + } \ + return *((TheClassName*)(aMemArray[(UINT16)(nPos >> nBlockShift)] + ((nPos & nMask) << nShift))); \ + } \ + const TheClassName& TheClassName##TheExtension::operator[] (UINT32 nPos) const { \ + if(nPos >= nCount) { \ + DBG_ERROR("Access to Bucket out of range!"); \ + return *((TheClassName*)aMemArray[0]); \ + } \ + return *((TheClassName*)(aMemArray[(UINT16)(nPos >> nBlockShift)] + ((nPos & nMask) << nShift))); \ + } + +#endif // _B3D_BUCKET_HXX diff --git a/goodies/inc/goodies/bxdintpo.hxx b/goodies/inc/goodies/bxdintpo.hxx new file mode 100644 index 000000000000..c1866424dae7 --- /dev/null +++ b/goodies/inc/goodies/bxdintpo.hxx @@ -0,0 +1,190 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: bxdintpo.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: vg $ $Date: 2007-04-11 20:33:08 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _BXD_INTERPOLATOR_HXX +#define _BXD_INTERPOLATOR_HXX + +#ifndef _SOLAR_H +#include <tools/solar.h> +#endif + +#ifndef _TOOLS_COLOR_HXX +#include <tools/color.hxx> +#endif + +#ifndef _BGFX_VECTOR_B3DVECTOR_HXX +#include <basegfx/vector/b3dvector.hxx> +#endif + +/************************************************************************* +|* +|* Standard-Interpolierer +|* +\************************************************************************/ + +class BxdInterpolator +{ +private: + double fPos; + double fInc; + +public: + BxdInterpolator(long nS, long nE, long nSteps) + : fPos(nSteps ? ((double)nS) + 0.5 : ((double)nE) + 0.5), + fInc((double)(nE - nS)/(double)(nSteps == 0 ? 1 : nSteps)) {} + + BxdInterpolator(UINT8 nS, UINT8 nE, long nSteps) + : fPos(nSteps ? ((double)nS) + 0.5 : ((double)nE) + 0.5), + fInc((double)(nE - nS)/(double)(nSteps == 0 ? 1 : nSteps)) {} + + BxdInterpolator(double fS, double fE, long nSteps) + : fPos(nSteps ? fS : fE), + fInc((fE - fS)/(double)(nSteps == 0 ? 1 : nSteps)) {} + + BxdInterpolator() {} + + void Increment() { fPos += fInc; } + + void Load(long nS, long nE, long nSteps) + { + fPos = (nSteps) ? ((double)nS) + 0.5 : ((double)nE) + 0.5; + fInc = (double)(nE - nS)/(double)(nSteps == 0 ? 1 : nSteps); + } + + void Load(UINT8 nS, UINT8 nE, long nSteps) + { + fPos = (nSteps) ? ((double)nS) + 0.5 : ((double)nE) + 0.5; + fInc = (double)(nE - nS)/(double)(nSteps == 0 ? 1 : nSteps); + } + + void Load(double fS, double fE, long nSteps) + { + fPos = (nSteps) ? fS : fE; + fInc = (fE - fS)/(double)(nSteps == 0 ? 1 : nSteps); + } + + long GetLongValue() { return (long)fPos; } + UINT32 GetUINT32Value() { return (UINT32)fPos; } + UINT8 GetUINT8Value() { return (UINT8)fPos; } + double GetDoubleValue() { return fPos; } + double GetStepSize() { return fInc; } +}; + +/************************************************************************* +|* +|* Interpolierer fuer Color +|* +\************************************************************************/ + +class BxdColorInterpolator +{ +private: + BxdInterpolator aRed; + BxdInterpolator aGreen; + BxdInterpolator aBlue; + UINT8 nTransparency; + +public: + BxdColorInterpolator(Color aS, Color aE, long nSteps) + : aRed(aS.GetRed(), aE.GetRed(), nSteps), + aGreen(aS.GetGreen(), aE.GetGreen(), nSteps), + aBlue(aS.GetBlue(), aE.GetBlue(), nSteps), + nTransparency(aS.GetTransparency()) {} + + BxdColorInterpolator() {} + + void Increment() + { + aRed.Increment(); + aGreen.Increment(); + aBlue.Increment(); + } + + void Load(Color aS, Color aE, long nSteps) + { + aRed.Load(aS.GetRed(), aE.GetRed(), nSteps); + aGreen.Load(aS.GetGreen(), aE.GetGreen(), nSteps); + aBlue.Load(aS.GetBlue(), aE.GetBlue(), nSteps); + nTransparency = aS.GetTransparency(); + } + + Color GetColorValue() + { + return Color(nTransparency, + aRed.GetUINT8Value(), + aGreen.GetUINT8Value(), + aBlue.GetUINT8Value()); + } +}; + +/************************************************************************* +|* +|* Interpolierer fuer Vector3D +|* +\************************************************************************/ + +class B3dVectorInterpolator +{ +private: + BxdInterpolator aX; + BxdInterpolator aY; + BxdInterpolator aZ; + +public: + B3dVectorInterpolator(basegfx::B3DVector& rS, basegfx::B3DVector& rE, long nSteps) + : aX(rS.getX(), rE.getX(), nSteps), + aY(rS.getY(), rE.getY(), nSteps), + aZ(rS.getZ(), rE.getZ(), nSteps) {} + + B3dVectorInterpolator() {} + + void Increment() { aX.Increment(); aY.Increment(); aZ.Increment(); } + + void Load(basegfx::B3DVector& rS, basegfx::B3DVector& rE, long nSteps) + { + aX.Load(rS.getX(), rE.getX(), nSteps); + aY.Load(rS.getY(), rE.getY(), nSteps); + aZ.Load(rS.getZ(), rE.getZ(), nSteps); + } + + void GetVector3DValue(basegfx::B3DVector& rVec) + { + rVec.setX(aX.GetDoubleValue()); + rVec.setY(aY.GetDoubleValue()); + rVec.setZ(aZ.GetDoubleValue()); + } +}; + +#endif // _BXD_INTERPOLATOR_HXX |