LCOV - code coverage report
Current view: top level - svx/source/engine3d - helperminimaldepth3d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 66 0.0 %
Date: 2012-08-25 Functions: 0 6 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 142 0.0 %

           Branch data     Line data    Source code
       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                 :            : 
      21                 :            : #include <helperminimaldepth3d.hxx>
      22                 :            : #include <drawinglayer/processor3d/baseprocessor3d.hxx>
      23                 :            : #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
      24                 :            : #include <drawinglayer/primitive3d/transformprimitive3d.hxx>
      25                 :            : #include <drawinglayer/primitive3d/polygonprimitive3d.hxx>
      26                 :            : #include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx>
      27                 :            : #include <svx/sdr/contact/viewcontactofe3d.hxx>
      28                 :            : #include <svx/sdr/contact/viewcontactofe3dscene.hxx>
      29                 :            : #include <svx/obj3d.hxx>
      30                 :            : #include <svx/scene3d.hxx>
      31                 :            : 
      32                 :            : //////////////////////////////////////////////////////////////////////////////
      33                 :            : 
      34                 :            : namespace drawinglayer
      35                 :            : {
      36                 :            :     namespace processor3d
      37                 :            :     {
      38         [ #  # ]:          0 :         class MinimalDephInViewExtractor : public BaseProcessor3D
      39                 :            :         {
      40                 :            :         private:
      41                 :            :             // the value which will be fetched as result
      42                 :            :             double                                  mfMinimalDepth;
      43                 :            : 
      44                 :            :             // as tooling, the process() implementation takes over API handling and calls this
      45                 :            :             // virtual render method when the primitive implementation is BasePrimitive3D-based.
      46                 :            :             virtual void processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate);
      47                 :            : 
      48                 :            :         public:
      49                 :          0 :             MinimalDephInViewExtractor(const geometry::ViewInformation3D& rViewInformation)
      50                 :            :             :   BaseProcessor3D(rViewInformation),
      51                 :          0 :                 mfMinimalDepth(DBL_MAX)
      52                 :          0 :             {}
      53                 :            : 
      54                 :            :             // data access
      55                 :          0 :             double getMinimalDepth() const { return mfMinimalDepth; }
      56                 :            :         };
      57                 :            : 
      58                 :          0 :         void MinimalDephInViewExtractor::processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate)
      59                 :            :         {
      60                 :            :             // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch
      61   [ #  #  #  # ]:          0 :             switch(rCandidate.getPrimitive3DID())
      62                 :            :             {
      63                 :            :                 case PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D :
      64                 :            :                 {
      65                 :            :                     // transform group. Remember current transformations
      66                 :          0 :                     const primitive3d::TransformPrimitive3D& rPrimitive = static_cast< const primitive3d::TransformPrimitive3D& >(rCandidate);
      67         [ #  # ]:          0 :                     const geometry::ViewInformation3D aLastViewInformation3D(getViewInformation3D());
      68                 :            : 
      69                 :            :                     // create new transformation; add new object transform from right side
      70                 :            :                     const geometry::ViewInformation3D aNewViewInformation3D(
      71         [ #  # ]:          0 :                         aLastViewInformation3D.getObjectTransformation() * rPrimitive.getTransformation(),
      72         [ #  # ]:          0 :                         aLastViewInformation3D.getOrientation(),
      73         [ #  # ]:          0 :                         aLastViewInformation3D.getProjection(),
      74         [ #  # ]:          0 :                         aLastViewInformation3D.getDeviceToView(),
      75                 :            :                         aLastViewInformation3D.getViewTime(),
      76 [ #  # ][ #  # ]:          0 :                         aLastViewInformation3D.getExtendedInformationSequence());
         [ #  # ][ #  # ]
                 [ #  # ]
      77         [ #  # ]:          0 :                     updateViewInformation(aNewViewInformation3D);
      78                 :            : 
      79                 :            :                     // let break down
      80 [ #  # ][ #  # ]:          0 :                     process(rPrimitive.getChildren());
                 [ #  # ]
      81                 :            : 
      82                 :            :                     // restore transformations
      83         [ #  # ]:          0 :                     updateViewInformation(aLastViewInformation3D);
      84 [ #  # ][ #  # ]:          0 :                     break;
      85                 :            :                 }
      86                 :            :                 case PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D :
      87                 :            :                 {
      88                 :            :                     // PolygonHairlinePrimitive3D
      89                 :          0 :                     const primitive3d::PolygonHairlinePrimitive3D& rPrimitive = static_cast< const primitive3d::PolygonHairlinePrimitive3D& >(rCandidate);
      90                 :          0 :                        const basegfx::B3DPolygon& rPolygon = rPrimitive.getB3DPolygon();
      91                 :          0 :                     const sal_uInt32 nCount(rPolygon.count());
      92                 :            : 
      93         [ #  # ]:          0 :                     for(sal_uInt32 a(0); a < nCount; a++)
      94                 :            :                     {
      95 [ #  # ][ #  # ]:          0 :                         const basegfx::B3DPoint aPointInView(getViewInformation3D().getObjectToView() * rPolygon.getB3DPoint(a));
                 [ #  # ]
      96                 :            : 
      97         [ #  # ]:          0 :                         if(aPointInView.getZ() < mfMinimalDepth)
      98                 :            :                         {
      99                 :          0 :                             mfMinimalDepth = aPointInView.getZ();
     100                 :            :                         }
     101                 :          0 :                     }
     102                 :            : 
     103                 :          0 :                     break;
     104                 :            :                 }
     105                 :            :                 case PRIMITIVE3D_ID_POLYPOLYGONMATERIALPRIMITIVE3D :
     106                 :            :                 {
     107                 :            :                     // PolyPolygonMaterialPrimitive3D
     108                 :          0 :                     const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const primitive3d::PolyPolygonMaterialPrimitive3D& >(rCandidate);
     109                 :          0 :                        const basegfx::B3DPolyPolygon& rPolyPolygon = rPrimitive.getB3DPolyPolygon();
     110                 :          0 :                     const sal_uInt32 nPolyCount(rPolyPolygon.count());
     111                 :            : 
     112         [ #  # ]:          0 :                     for(sal_uInt32 a(0); a < nPolyCount; a++)
     113                 :            :                     {
     114         [ #  # ]:          0 :                            const basegfx::B3DPolygon aPolygon(rPolyPolygon.getB3DPolygon(a));
     115         [ #  # ]:          0 :                         const sal_uInt32 nCount(aPolygon.count());
     116                 :            : 
     117         [ #  # ]:          0 :                         for(sal_uInt32 b(0); b < nCount; b++)
     118                 :            :                         {
     119 [ #  # ][ #  # ]:          0 :                             const basegfx::B3DPoint aPointInView(getViewInformation3D().getObjectToView() * aPolygon.getB3DPoint(b));
                 [ #  # ]
     120                 :            : 
     121         [ #  # ]:          0 :                             if(aPointInView.getZ() < mfMinimalDepth)
     122                 :            :                             {
     123                 :          0 :                                 mfMinimalDepth = aPointInView.getZ();
     124                 :            :                             }
     125                 :          0 :                         }
     126         [ #  # ]:          0 :                     }
     127                 :            : 
     128                 :          0 :                     break;
     129                 :            :                 }
     130                 :            :                 default :
     131                 :            :                 {
     132                 :            :                     // process recursively
     133         [ #  # ]:          0 :                     process(rCandidate.get3DDecomposition(getViewInformation3D()));
     134                 :          0 :                     break;
     135                 :            :                 }
     136                 :            :             }
     137                 :          0 :         }
     138                 :            :     } // end of namespace processor3d
     139                 :            : } // end of namespace drawinglayer
     140                 :            : 
     141                 :            : //////////////////////////////////////////////////////////////////////////////
     142                 :            : // changed to create values using VCs, Primitive3DSequence and ViewInformation3D to allow
     143                 :            : // removal of old 3D bucket geometry. There is one slight difference in the result, it's
     144                 :            : // in [0.0 .. 1.0] for Z-Depth since the scaling of the scene as 2D object is no longer
     145                 :            : // part of the 3D transformations. This could be added since the ViewContactOfE3dScene is
     146                 :            : // given, but is not needed since the permutation of the depth values needs only be correct
     147                 :            : // relative to each other
     148                 :            : 
     149                 :          0 : double getMinimalDepthInViewCoordinates(const E3dCompoundObject& rObject)
     150                 :            : {
     151                 :            :     // this is a E3dCompoundObject, so it cannot be a scene (which is a E3dObject).
     152                 :            :     // Get primitive sequence using VC
     153         [ #  # ]:          0 :     const sdr::contact::ViewContactOfE3d& rVCObject = static_cast< sdr::contact::ViewContactOfE3d& >(rObject.GetViewContact());
     154         [ #  # ]:          0 :     const drawinglayer::primitive3d::Primitive3DSequence aPrimitives = rVCObject.getViewIndependentPrimitive3DSequence();
     155                 :          0 :     double fRetval(DBL_MAX);
     156                 :            : 
     157         [ #  # ]:          0 :     if(aPrimitives.hasElements())
     158                 :            :     {
     159         [ #  # ]:          0 :         const E3dScene* pScene = rObject.GetScene();
     160                 :            : 
     161         [ #  # ]:          0 :         if(pScene)
     162                 :            :         {
     163                 :            :             // get ViewInformation3D from scene using VC
     164         [ #  # ]:          0 :             const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact());
     165 [ #  # ][ #  # ]:          0 :             const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
     166                 :            : 
     167                 :            :             // the scene's object transformation is already part of aViewInfo3D.getObjectTransformation()
     168                 :            :             // for historical reasons (see ViewContactOfE3dScene::createViewInformation3D for more info)
     169                 :            :             // and the object's transform is part of aPrimitives (and taken into account when decomposing
     170                 :            :             // to PolygonHairlinePrimitive3D and PolyPolygonMaterialPrimitive3D). The missing part may be
     171                 :            :             // some Scene SdrObjects lying in-between which may need to be added. This is e.g. used in chart,
     172                 :            :             // and generally allowed in 3d scenes an their 3d object hierarchy
     173         [ #  # ]:          0 :             basegfx::B3DHomMatrix aInBetweenSceneMatrix;
     174 [ #  # ][ #  # ]:          0 :             E3dScene* pParentScene = dynamic_cast< E3dScene* >(rObject.GetParentObj());
     175                 :            : 
     176 [ #  # ][ #  # ]:          0 :             while(pParentScene && pParentScene != pScene)
                 [ #  # ]
     177                 :            :             {
     178 [ #  # ][ #  # ]:          0 :                 aInBetweenSceneMatrix = pParentScene->GetTransform() * aInBetweenSceneMatrix;
         [ #  # ][ #  # ]
     179 [ #  # ][ #  # ]:          0 :                 pParentScene = dynamic_cast< E3dScene* >(pParentScene->GetParentObj());
     180                 :            :             }
     181                 :            : 
     182                 :            :             // build new ViewInformation containing all transforms
     183                 :            :             const drawinglayer::geometry::ViewInformation3D aNewViewInformation3D(
     184         [ #  # ]:          0 :                 aViewInfo3D.getObjectTransformation() * aInBetweenSceneMatrix,
     185         [ #  # ]:          0 :                 aViewInfo3D.getOrientation(),
     186         [ #  # ]:          0 :                 aViewInfo3D.getProjection(),
     187         [ #  # ]:          0 :                 aViewInfo3D.getDeviceToView(),
     188                 :            :                 aViewInfo3D.getViewTime(),
     189 [ #  # ][ #  # ]:          0 :                 aViewInfo3D.getExtendedInformationSequence());
         [ #  # ][ #  # ]
                 [ #  # ]
     190                 :            : 
     191                 :            :             // create extractor helper, proccess geometry and get return value
     192         [ #  # ]:          0 :             drawinglayer::processor3d::MinimalDephInViewExtractor aExtractor(aNewViewInformation3D);
     193         [ #  # ]:          0 :             aExtractor.process(aPrimitives);
     194 [ #  # ][ #  # ]:          0 :             fRetval = aExtractor.getMinimalDepth();
         [ #  # ][ #  # ]
     195                 :            :         }
     196                 :            :     }
     197                 :            : 
     198         [ #  # ]:          0 :     return fRetval;
     199                 :            : }
     200                 :            : 
     201                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10