LCOV - code coverage report
Current view: top level - drawinglayer/source/processor3d - cutfindprocessor3d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 71 0.0 %
Date: 2012-08-25 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 139 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                 :            : #include <drawinglayer/processor3d/cutfindprocessor3d.hxx>
      21                 :            : #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
      22                 :            : #include <drawinglayer/primitive3d/transformprimitive3d.hxx>
      23                 :            : #include <drawinglayer/primitive3d/hatchtextureprimitive3d.hxx>
      24                 :            : #include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx>
      25                 :            : #include <basegfx/polygon/b3dpolygon.hxx>
      26                 :            : #include <basegfx/polygon/b3dpolygontools.hxx>
      27                 :            : #include <basegfx/polygon/b3dpolypolygontools.hxx>
      28                 :            : #include <drawinglayer/primitive3d/hiddengeometryprimitive3d.hxx>
      29                 :            : 
      30                 :            : //////////////////////////////////////////////////////////////////////////////
      31                 :            : 
      32                 :            : namespace drawinglayer
      33                 :            : {
      34                 :            :     namespace processor3d
      35                 :            :     {
      36                 :          0 :         CutFindProcessor::CutFindProcessor(const geometry::ViewInformation3D& rViewInformation,
      37                 :            :             const basegfx::B3DPoint& rFront,
      38                 :            :             const basegfx::B3DPoint& rBack,
      39                 :            :             bool bAnyHit)
      40                 :            :         :   BaseProcessor3D(rViewInformation),
      41                 :            :             maFront(rFront),
      42                 :            :             maBack(rBack),
      43                 :            :             maResult(),
      44                 :            :             maCombinedTransform(),
      45                 :            :             mbAnyHit(bAnyHit),
      46 [ #  # ][ #  # ]:          0 :             mbUseInvisiblePrimitiveContent(true)
      47                 :            :         {
      48                 :          0 :         }
      49                 :            : 
      50                 :          0 :         void CutFindProcessor::processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate)
      51                 :            :         {
      52 [ #  # ][ #  # ]:          0 :             if(getAnyHit() && maResult.size())
                 [ #  # ]
      53                 :            :             {
      54                 :            :                 // stop processing as soon as a hit was recognized
      55                 :          0 :                 return;
      56                 :            :             }
      57                 :            : 
      58                 :            :             // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch
      59   [ #  #  #  #  :          0 :             switch(rCandidate.getPrimitive3DID())
                #  #  # ]
      60                 :            :             {
      61                 :            :                 case PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D :
      62                 :            :                 {
      63                 :            :                     // transform group.
      64                 :          0 :                     const primitive3d::TransformPrimitive3D& rPrimitive = static_cast< const primitive3d::TransformPrimitive3D& >(rCandidate);
      65                 :            : 
      66                 :            :                     // remember old and transform front, back to object coordinates
      67                 :          0 :                     const basegfx::B3DPoint aLastFront(maFront);
      68                 :          0 :                     const basegfx::B3DPoint aLastBack(maBack);
      69         [ #  # ]:          0 :                     basegfx::B3DHomMatrix aInverseTrans(rPrimitive.getTransformation());
      70         [ #  # ]:          0 :                     aInverseTrans.invert();
      71         [ #  # ]:          0 :                     maFront *= aInverseTrans;
      72         [ #  # ]:          0 :                     maBack *= aInverseTrans;
      73                 :            : 
      74                 :            :                     // remember current and create new transformation; add new object transform from right side
      75         [ #  # ]:          0 :                     const geometry::ViewInformation3D aLastViewInformation3D(getViewInformation3D());
      76                 :            :                     const geometry::ViewInformation3D aNewViewInformation3D(
      77         [ #  # ]:          0 :                         aLastViewInformation3D.getObjectTransformation() * rPrimitive.getTransformation(),
      78         [ #  # ]:          0 :                         aLastViewInformation3D.getOrientation(),
      79         [ #  # ]:          0 :                         aLastViewInformation3D.getProjection(),
      80         [ #  # ]:          0 :                         aLastViewInformation3D.getDeviceToView(),
      81                 :            :                         aLastViewInformation3D.getViewTime(),
      82 [ #  # ][ #  # ]:          0 :                         aLastViewInformation3D.getExtendedInformationSequence());
         [ #  # ][ #  # ]
                 [ #  # ]
      83         [ #  # ]:          0 :                     updateViewInformation(aNewViewInformation3D);
      84                 :            : 
      85                 :            :                     // #i102956# remember needed back-transform for found cuts (combine from right side)
      86         [ #  # ]:          0 :                     const basegfx::B3DHomMatrix aLastCombinedTransform(maCombinedTransform);
      87 [ #  # ][ #  # ]:          0 :                     maCombinedTransform = maCombinedTransform * rPrimitive.getTransformation();
                 [ #  # ]
      88                 :            : 
      89                 :            :                     // let break down
      90 [ #  # ][ #  # ]:          0 :                     process(rPrimitive.getChildren());
                 [ #  # ]
      91                 :            : 
      92                 :            :                     // restore transformations and front, back
      93         [ #  # ]:          0 :                     maCombinedTransform = aLastCombinedTransform;
      94         [ #  # ]:          0 :                     updateViewInformation(aLastViewInformation3D);
      95         [ #  # ]:          0 :                     maFront = aLastFront;
      96         [ #  # ]:          0 :                     maBack = aLastBack;
      97 [ #  # ][ #  # ]:          0 :                     break;
         [ #  # ][ #  # ]
      98                 :            :                 }
      99                 :            :                 case PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D :
     100                 :            :                 {
     101                 :            :                     // PolygonHairlinePrimitive3D, not used for hit test with planes, ignore. This
     102                 :            :                     // means that also thick line expansion will not be hit-tested as
     103                 :            :                     // PolyPolygonMaterialPrimitive3D
     104                 :          0 :                     break;
     105                 :            :                 }
     106                 :            :                 case PRIMITIVE3D_ID_HATCHTEXTUREPRIMITIVE3D :
     107                 :            :                 {
     108                 :            :                     // #i97321#
     109                 :            :                     // For HatchTexturePrimitive3D, do not use the decomposition since it will produce
     110                 :            :                     // clipped hatch lines in 3D. It can be used when the hatch also has a filling, but for
     111                 :            :                     // simplicity, just use the children which are the PolyPolygonMaterialPrimitive3D
     112                 :            :                     // which define the hatched areas anyways; for HitTest this is more than adequate
     113                 :          0 :                     const primitive3d::HatchTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::HatchTexturePrimitive3D& >(rCandidate);
     114         [ #  # ]:          0 :                     process(rPrimitive.getChildren());
     115                 :          0 :                     break;
     116                 :            :                 }
     117                 :            :                 case PRIMITIVE3D_ID_HIDDENGEOMETRYPRIMITIVE3D :
     118                 :            :                 {
     119                 :            :                     // HiddenGeometryPrimitive3D; the default decomposition would return an empty seqence,
     120                 :            :                     // so force this primitive to process it's children directly if the switch is set
     121                 :            :                     // (which is the default). Else, ignore invisible content
     122                 :          0 :                     const primitive3d::HiddenGeometryPrimitive3D& rHiddenGeometry(static_cast< const primitive3d::HiddenGeometryPrimitive3D& >(rCandidate));
     123                 :          0 :                        const primitive3d::Primitive3DSequence& rChildren = rHiddenGeometry.getChildren();
     124                 :            : 
     125         [ #  # ]:          0 :                     if(rChildren.hasElements())
     126                 :            :                     {
     127         [ #  # ]:          0 :                         if(getUseInvisiblePrimitiveContent())
     128                 :            :                         {
     129         [ #  # ]:          0 :                             process(rChildren);
     130                 :            :                         }
     131                 :            :                     }
     132                 :            : 
     133                 :          0 :                     break;
     134                 :            :                 }
     135                 :            :                 case PRIMITIVE3D_ID_UNIFIEDTRANSPARENCETEXTUREPRIMITIVE3D :
     136                 :            :                 {
     137                 :          0 :                     const primitive3d::UnifiedTransparenceTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::UnifiedTransparenceTexturePrimitive3D& >(rCandidate);
     138         [ #  # ]:          0 :                        const primitive3d::Primitive3DSequence rChildren = rPrimitive.getChildren();
     139                 :            : 
     140         [ #  # ]:          0 :                     if(rChildren.getLength())
     141                 :            :                     {
     142         [ #  # ]:          0 :                         if(1.0 <= rPrimitive.getTransparence())
     143                 :            :                         {
     144                 :            :                             // not visible, but use for HitTest
     145         [ #  # ]:          0 :                             if(getUseInvisiblePrimitiveContent())
     146                 :            :                             {
     147         [ #  # ]:          0 :                                    process(rChildren);
     148                 :            :                             }
     149                 :            :                         }
     150 [ #  # ][ #  # ]:          0 :                         else if(rPrimitive.getTransparence() >= 0.0 && rPrimitive.getTransparence() < 1.0)
                 [ #  # ]
     151                 :            :                         {
     152                 :            :                             // visible; use content
     153         [ #  # ]:          0 :                             process(rChildren);
     154                 :            :                         }
     155                 :            :                     }
     156                 :            : 
     157         [ #  # ]:          0 :                     break;
     158                 :            :                 }
     159                 :            :                 case PRIMITIVE3D_ID_POLYPOLYGONMATERIALPRIMITIVE3D :
     160                 :            :                 {
     161                 :            :                     // PolyPolygonMaterialPrimitive3D
     162                 :          0 :                     const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const primitive3d::PolyPolygonMaterialPrimitive3D& >(rCandidate);
     163                 :            : 
     164         [ #  # ]:          0 :                     if(!maFront.equal(maBack))
     165                 :            :                     {
     166                 :          0 :                            const basegfx::B3DPolyPolygon& rPolyPolygon = rPrimitive.getB3DPolyPolygon();
     167                 :          0 :                         const sal_uInt32 nPolyCount(rPolyPolygon.count());
     168                 :            : 
     169         [ #  # ]:          0 :                         if(nPolyCount)
     170                 :            :                         {
     171         [ #  # ]:          0 :                                const basegfx::B3DPolygon aPolygon(rPolyPolygon.getB3DPolygon(0));
     172         [ #  # ]:          0 :                             const sal_uInt32 nPointCount(aPolygon.count());
     173                 :            : 
     174         [ #  # ]:          0 :                             if(nPointCount > 2)
     175                 :            :                             {
     176         [ #  # ]:          0 :                                 const basegfx::B3DVector aPlaneNormal(aPolygon.getNormal());
     177                 :            : 
     178 [ #  # ][ #  # ]:          0 :                                 if(!aPlaneNormal.equalZero())
     179                 :            :                                 {
     180         [ #  # ]:          0 :                                     const basegfx::B3DPoint aPointOnPlane(aPolygon.getB3DPoint(0));
     181                 :          0 :                                     double fCut(0.0);
     182                 :            : 
     183 [ #  # ][ #  # ]:          0 :                                     if(basegfx::tools::getCutBetweenLineAndPlane(aPlaneNormal, aPointOnPlane, maFront, maBack, fCut))
     184                 :            :                                     {
     185                 :          0 :                                         const basegfx::B3DPoint aCutPoint(basegfx::interpolate(maFront, maBack, fCut));
     186                 :            : 
     187 [ #  # ][ #  # ]:          0 :                                         if(basegfx::tools::isInside(rPolyPolygon, aCutPoint, false))
     188                 :            :                                         {
     189                 :            :                                             // #i102956# add result. Do not forget to do this in the coordinate
     190                 :            :                                             // system the processor get started with, so use the collected
     191                 :            :                                             // combined transformation from processed TransformPrimitive3D's
     192 [ #  # ][ #  # ]:          0 :                                             maResult.push_back(maCombinedTransform * aCutPoint);
     193                 :          0 :                                         }
     194                 :          0 :                                     }
     195                 :          0 :                                 }
     196         [ #  # ]:          0 :                             }
     197                 :            :                         }
     198                 :            :                     }
     199                 :            : 
     200                 :          0 :                     break;
     201                 :            :                 }
     202                 :            :                 default :
     203                 :            :                 {
     204                 :            :                     // process recursively
     205         [ #  # ]:          0 :                     process(rCandidate.get3DDecomposition(getViewInformation3D()));
     206                 :          0 :                     break;
     207                 :            :                 }
     208                 :            :             }
     209                 :            :         }
     210                 :            :     } // end of namespace processor3d
     211                 :            : } // end of namespace drawinglayer
     212                 :            : 
     213                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10