2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
|
*
|
2008-04-10 23:44:50 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 23:44:50 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 23:44:50 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 23:44:50 +00:00
|
|
|
* $RCSfile: polygn3d.cxx,v $
|
2008-10-17 08:40:10 +00:00
|
|
|
* $Revision: 1.17.18.1 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 23:44:50 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 23:44:50 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 23:44:50 +00:00
|
|
|
* OpenOffice.org 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 version 3 for more details
|
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 23:44:50 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
2006-09-17 03:58:10 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
|
#include "precompiled_svx.hxx"
|
2007-06-27 17:04:42 +00:00
|
|
|
#include <svx/polygn3d.hxx>
|
|
|
|
|
#include <svx/svdpage.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "globl3d.hxx"
|
2004-11-03 09:41:14 +00:00
|
|
|
#include <basegfx/point/b3dpoint.hxx>
|
2008-08-19 21:59:15 +00:00
|
|
|
#include <svx/sdr/contact/viewcontactofe3dpolygon.hxx>
|
2006-11-14 12:21:01 +00:00
|
|
|
#include <basegfx/polygon/b3dpolygon.hxx>
|
|
|
|
|
#include <basegfx/polygon/b3dpolygontools.hxx>
|
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
TYPEINIT1(E3dPolygonObj, E3dCompoundObject);
|
|
|
|
|
|
2008-08-19 21:59:15 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// #110094# DrawContact section
|
|
|
|
|
|
|
|
|
|
sdr::contact::ViewContact* E3dPolygonObj::CreateObjectSpecificViewContact()
|
|
|
|
|
{
|
|
|
|
|
return new sdr::contact::ViewContactOfE3dPolygon(*this);
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
|
|*
|
|
|
|
|
|* Konstruktor
|
|
|
|
|
|*
|
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
|
|
E3dPolygonObj::E3dPolygonObj(
|
|
|
|
|
E3dDefaultAttributes& rDefault,
|
2006-11-14 12:21:01 +00:00
|
|
|
const basegfx::B3DPolyPolygon& rPolyPoly3D,
|
2000-09-18 16:07:07 +00:00
|
|
|
BOOL bLinOnly)
|
|
|
|
|
: E3dCompoundObject(rDefault),
|
|
|
|
|
bLineOnly(bLinOnly)
|
|
|
|
|
{
|
|
|
|
|
// Geometrie setzen
|
|
|
|
|
SetPolyPolygon3D(rPolyPoly3D);
|
|
|
|
|
|
|
|
|
|
// Default-Normals erzeugen
|
|
|
|
|
CreateDefaultNormals();
|
|
|
|
|
|
|
|
|
|
// Default-Texturkoordinaten erzeugen
|
|
|
|
|
CreateDefaultTexture();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|
|*
|
|
|
|
|
|* Konstruktor
|
|
|
|
|
|*
|
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
|
|
E3dPolygonObj::E3dPolygonObj(
|
|
|
|
|
E3dDefaultAttributes& rDefault,
|
2006-11-14 12:21:01 +00:00
|
|
|
const basegfx::B3DPolyPolygon& rPolyPoly3D,
|
|
|
|
|
const basegfx::B3DPolyPolygon& rPolyNormals3D,
|
2000-09-18 16:07:07 +00:00
|
|
|
BOOL bLinOnly)
|
|
|
|
|
: E3dCompoundObject(rDefault),
|
|
|
|
|
bLineOnly(bLinOnly)
|
|
|
|
|
{
|
|
|
|
|
// Geometrie und Normalen setzen
|
|
|
|
|
SetPolyPolygon3D(rPolyPoly3D);
|
|
|
|
|
SetPolyNormals3D(rPolyNormals3D);
|
|
|
|
|
|
|
|
|
|
// Default-Texturkoordinaten erzeugen
|
|
|
|
|
CreateDefaultTexture();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|
|*
|
|
|
|
|
|* Konstruktor
|
|
|
|
|
|*
|
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
|
|
E3dPolygonObj::E3dPolygonObj(
|
|
|
|
|
E3dDefaultAttributes& rDefault,
|
2006-11-14 12:21:01 +00:00
|
|
|
const basegfx::B3DPolyPolygon& rPolyPoly3D,
|
|
|
|
|
const basegfx::B3DPolyPolygon& rPolyNormals3D,
|
|
|
|
|
const basegfx::B2DPolyPolygon& rPolyTexture2D,
|
2000-09-18 16:07:07 +00:00
|
|
|
BOOL bLinOnly)
|
|
|
|
|
: E3dCompoundObject(rDefault),
|
|
|
|
|
bLineOnly(bLinOnly)
|
|
|
|
|
{
|
|
|
|
|
SetPolyPolygon3D(rPolyPoly3D);
|
|
|
|
|
SetPolyNormals3D(rPolyNormals3D);
|
2006-11-14 12:21:01 +00:00
|
|
|
SetPolyTexture2D(rPolyTexture2D);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|
|*
|
|
|
|
|
|* Leer-Konstruktor
|
|
|
|
|
|*
|
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
|
|
E3dPolygonObj::E3dPolygonObj()
|
2008-08-19 21:59:15 +00:00
|
|
|
: E3dCompoundObject(),
|
|
|
|
|
bLineOnly(false) // added missing initialisation
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
|
// Keine Geometrie erzeugen
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|
|*
|
|
|
|
|
|* Default-Normalen erzeugen
|
|
|
|
|
|*
|
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
|
|
void E3dPolygonObj::CreateDefaultNormals()
|
|
|
|
|
{
|
2006-11-14 12:21:01 +00:00
|
|
|
basegfx::B3DPolyPolygon aPolyNormals;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
// Komplettes PolyPolygon mit den Ebenennormalen anlegen
|
2006-11-14 12:21:01 +00:00
|
|
|
for(sal_uInt32 a(0L); a < aPolyPoly3D.count(); a++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
|
// Quellpolygon finden
|
2006-11-14 12:21:01 +00:00
|
|
|
const basegfx::B3DPolygon aPolygon(aPolyPoly3D.getB3DPolygon(a));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
// Neues Polygon fuer Normalen anlegen
|
2006-11-14 12:21:01 +00:00
|
|
|
basegfx::B3DPolygon aNormals;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
// Normale holen (und umdrehen)
|
2006-11-14 12:21:01 +00:00
|
|
|
basegfx::B3DVector aNormal(-basegfx::tools::getNormal(aPolygon));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
// Neues Polygon fuellen
|
2006-11-14 12:21:01 +00:00
|
|
|
for(sal_uInt32 b(0L); b < aPolygon.count(); b++)
|
|
|
|
|
{
|
|
|
|
|
aNormals.append(aNormal);
|
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
// Neues Polygon in PolyPolygon einfuegen
|
2006-11-14 12:21:01 +00:00
|
|
|
aPolyNormals.append(aNormals);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Default-Normalen setzen
|
|
|
|
|
SetPolyNormals3D(aPolyNormals);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|
|*
|
|
|
|
|
|* Default-Texturkoordinaten erzeugen
|
|
|
|
|
|*
|
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
|
|
void E3dPolygonObj::CreateDefaultTexture()
|
|
|
|
|
{
|
2006-11-14 12:21:01 +00:00
|
|
|
basegfx::B2DPolyPolygon aPolyTexture;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
// Komplettes PolyPolygon mit den Texturkoordinaten anlegen
|
|
|
|
|
// Die Texturkoordinaten erstrecken sich ueber X,Y und Z
|
|
|
|
|
// ueber die gesamten Extremwerte im Bereich 0.0 .. 1.0
|
2006-11-14 12:21:01 +00:00
|
|
|
for(sal_uInt32 a(0L); a < aPolyPoly3D.count(); a++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
|
// Quellpolygon finden
|
2006-11-14 12:21:01 +00:00
|
|
|
const basegfx::B3DPolygon& aPolygon(aPolyPoly3D.getB3DPolygon(a));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
// Gesamtgroesse des Objektes feststellen
|
2008-10-17 08:40:10 +00:00
|
|
|
basegfx::B3DRange aVolume(basegfx::tools::getRange(aPolygon));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
// Normale holen
|
2006-11-14 12:21:01 +00:00
|
|
|
basegfx::B3DVector aNormal(basegfx::tools::getNormal(aPolygon));
|
|
|
|
|
aNormal.setX(fabs(aNormal.getX()));
|
|
|
|
|
aNormal.setY(fabs(aNormal.getY()));
|
|
|
|
|
aNormal.setZ(fabs(aNormal.getZ()));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
// Entscheiden, welche Koordinaten als Source fuer das
|
|
|
|
|
// Mapping benutzt werden sollen
|
|
|
|
|
UINT16 nSourceMode = 0;
|
|
|
|
|
|
|
|
|
|
// Groessten Freiheitsgrad ermitteln
|
2006-11-14 12:21:01 +00:00
|
|
|
if(!(aNormal.getX() > aNormal.getY() && aNormal.getX() > aNormal.getZ()))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2006-11-14 12:21:01 +00:00
|
|
|
if(aNormal.getY() > aNormal.getZ())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
|
// Y ist am groessten, benutze X,Z als mapping
|
|
|
|
|
nSourceMode = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Z ist am groessten, benutze X,Y als mapping
|
|
|
|
|
nSourceMode = 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-14 12:21:01 +00:00
|
|
|
// Neues Polygon fuer Texturkoordinaten anlegen
|
|
|
|
|
basegfx::B2DPolygon aTexture;
|
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// Neues Polygon fuellen
|
2006-11-14 12:21:01 +00:00
|
|
|
for(sal_uInt32 b(0L); b < aPolygon.count(); b++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2006-11-14 12:21:01 +00:00
|
|
|
basegfx::B2DPoint aTex;
|
|
|
|
|
const basegfx::B3DPoint aCandidate(aPolygon.getB3DPoint(b));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
switch(nSourceMode)
|
|
|
|
|
{
|
|
|
|
|
case 0: // Quelle ist Y,Z
|
2006-11-14 12:21:01 +00:00
|
|
|
if(aVolume.getHeight())
|
|
|
|
|
aTex.setX((aCandidate.getY() - aVolume.getMinY()) / aVolume.getHeight());
|
|
|
|
|
if(aVolume.getDepth())
|
|
|
|
|
aTex.setY((aCandidate.getZ() - aVolume.getMinZ()) / aVolume.getDepth());
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1: // Quelle ist X,Z
|
2006-11-14 12:21:01 +00:00
|
|
|
if(aVolume.getWidth())
|
|
|
|
|
aTex.setX((aCandidate.getX() - aVolume.getMinX()) / aVolume.getWidth());
|
|
|
|
|
if(aVolume.getDepth())
|
|
|
|
|
aTex.setY((aCandidate.getZ() - aVolume.getMinZ()) / aVolume.getDepth());
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2: // Quelle ist X,Y
|
2006-11-14 12:21:01 +00:00
|
|
|
if(aVolume.getWidth())
|
|
|
|
|
aTex.setX((aCandidate.getX() - aVolume.getMinX()) / aVolume.getWidth());
|
|
|
|
|
if(aVolume.getHeight())
|
|
|
|
|
aTex.setY((aCandidate.getY() - aVolume.getMinY()) / aVolume.getHeight());
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2006-11-14 12:21:01 +00:00
|
|
|
|
|
|
|
|
aTexture.append(aTex);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Neues Polygon in PolyPolygon einfuegen
|
2006-11-14 12:21:01 +00:00
|
|
|
aPolyTexture.append(aTexture);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Default-Texturkoordinaten setzen
|
2006-11-14 12:21:01 +00:00
|
|
|
SetPolyTexture2D(aPolyTexture);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|
|*
|
|
|
|
|
|* Destruktor
|
|
|
|
|
|*
|
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
|
|
E3dPolygonObj::~E3dPolygonObj()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|
|*
|
|
|
|
|
|* Identifier zurueckgeben
|
|
|
|
|
|*
|
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
|
|
UINT16 E3dPolygonObj::GetObjIdentifier() const
|
|
|
|
|
{
|
|
|
|
|
return E3D_POLYGONOBJ_ID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|
|*
|
|
|
|
|
|* Polygon setzen
|
|
|
|
|
|*
|
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
2006-11-14 12:21:01 +00:00
|
|
|
void E3dPolygonObj::SetPolyPolygon3D(const basegfx::B3DPolyPolygon& rNewPolyPoly3D)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
|
if ( aPolyPoly3D != rNewPolyPoly3D )
|
|
|
|
|
{
|
|
|
|
|
// Neues PolyPolygon; kopieren
|
|
|
|
|
aPolyPoly3D = rNewPolyPoly3D;
|
|
|
|
|
|
|
|
|
|
// Geometrie neu erzeugen
|
2008-10-17 08:40:10 +00:00
|
|
|
ActionChanged();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-14 12:21:01 +00:00
|
|
|
void E3dPolygonObj::SetPolyNormals3D(const basegfx::B3DPolyPolygon& rNewPolyNormals3D)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
|
if ( aPolyNormals3D != rNewPolyNormals3D )
|
|
|
|
|
{
|
|
|
|
|
// Neue Normalen; kopieren
|
|
|
|
|
aPolyNormals3D = rNewPolyNormals3D;
|
|
|
|
|
|
|
|
|
|
// Geometrie neu erzeugen
|
2008-10-17 08:40:10 +00:00
|
|
|
ActionChanged();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-14 12:21:01 +00:00
|
|
|
void E3dPolygonObj::SetPolyTexture2D(const basegfx::B2DPolyPolygon& rNewPolyTexture2D)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2006-11-14 12:21:01 +00:00
|
|
|
if ( aPolyTexture2D != rNewPolyTexture2D )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
|
// Neue Texturkoordinaten; kopieren
|
2006-11-14 12:21:01 +00:00
|
|
|
aPolyTexture2D = rNewPolyTexture2D;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
// Geometrie neu erzeugen
|
2008-10-17 08:40:10 +00:00
|
|
|
ActionChanged();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|
|*
|
|
|
|
|
|* Wandle das Objekt in ein Gruppenobjekt bestehend aus 6 Polygonen
|
|
|
|
|
|*
|
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
2006-06-19 14:46:42 +00:00
|
|
|
SdrObject *E3dPolygonObj::DoConvertToPolyObj(BOOL /*bBezier*/) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|
|*
|
|
|
|
|
|* Zuweisungsoperator
|
|
|
|
|
|*
|
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
|
|
void E3dPolygonObj::operator=(const SdrObject& rObj)
|
|
|
|
|
{
|
|
|
|
|
// erstmal alle Childs kopieren
|
|
|
|
|
E3dCompoundObject::operator=(rObj);
|
|
|
|
|
|
|
|
|
|
// weitere Parameter kopieren
|
|
|
|
|
const E3dPolygonObj& r3DObj = (const E3dPolygonObj&)rObj;
|
|
|
|
|
|
|
|
|
|
aPolyPoly3D = r3DObj.aPolyPoly3D;
|
|
|
|
|
aPolyNormals3D = r3DObj.aPolyNormals3D;
|
2006-11-14 12:21:01 +00:00
|
|
|
aPolyTexture2D = r3DObj.aPolyTexture2D;
|
2000-09-18 16:07:07 +00:00
|
|
|
bLineOnly = r3DObj.bLineOnly;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|
|*
|
|
|
|
|
|* LineOnly setzen
|
|
|
|
|
|*
|
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
|
|
void E3dPolygonObj::SetLineOnly(BOOL bNew)
|
|
|
|
|
{
|
|
|
|
|
if(bNew != bLineOnly)
|
|
|
|
|
{
|
|
|
|
|
bLineOnly = bNew;
|
2008-10-17 08:40:10 +00:00
|
|
|
ActionChanged();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-03 09:41:14 +00:00
|
|
|
// eof
|