]> OCCT Git - occt-copy.git/commitdiff
Unnecessary code duplication in MeshVS_LODBuilder was removed;
authorvpa <vpa@opencascade.com>
Wed, 6 Apr 2016 16:56:06 +0000 (19:56 +0300)
committervpa <vpa@opencascade.com>
Fri, 8 Apr 2016 17:20:05 +0000 (20:20 +0300)
Added missing comments in MeshVS and PrsMgr classes

src/Graphic3d/Graphic3d_CStructure.hxx
src/Graphic3d/Graphic3d_Structure.cxx
src/MeshVS/MeshVS_LODBuilder.cxx
src/MeshVS/MeshVS_LODBuilder.hxx
src/MeshVS/MeshVS_LODDataSource.hxx
src/MeshVS/MeshVS_MeshPrsBuilder.cxx
src/MeshVS/MeshVS_MeshPrsBuilder.hxx
src/PrsMgr/PrsMgr_PresentableObject.hxx
src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx

index 630b60c9ca1dcf34dd06c6a114a675aa0871f47c..f15acb4f828c214bc539a0ca8e807fab0b2f0d58 100644 (file)
@@ -80,6 +80,9 @@ public:
   //! Get z layer ID
   Graphic3d_ZLayerId ZLayer() const { return myZLayer; }
 
+  //! Returns LOD manager for this structure. If the structure
+  //! is not represented through LODs, the return value will
+  //! be NULL pointer
   const Handle(Graphic3d_LODManager)& GetLodManager() const
   {
     return myLODManager;
index 1198ec1c664a2f26a8080232bb3983e5ee3ad2c4..a00e02e25a742507fce829404afd57c3bbc287ed 100644 (file)
@@ -496,7 +496,6 @@ Standard_Boolean Graphic3d_Structure::IsEmpty() const
   // - if all these groups are empty
   // - or if all groups are empty and all their descendants are empty
   // - or if all its descendants are empty
-  // - or, in case if it is represented by LODs, all LODs have no graphic groups
   if (!myCStructure->GetLodManager().IsNull())
   {
     return myCStructure->GetLodManager()->IsEmpty();
@@ -518,7 +517,6 @@ Standard_Boolean Graphic3d_Structure::IsEmpty() const
       return Standard_False;
     }
   }
-
   return Standard_True;
 }
 
index ecdcd8ea70ce4d020e56f995408c7536a4e98bf4..c821d211e0ef6ae41da359da12f08acc4f8c19b9 100644 (file)
@@ -26,7 +26,7 @@
 #include <TColStd_HPackedMapOfInteger.hxx>
 #include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
 
-IMPLEMENT_STANDARD_RTTIEXT (MeshVS_LODBuilder, MeshVS_PrsBuilder)
+IMPLEMENT_STANDARD_RTTIEXT (MeshVS_LODBuilder, MeshVS_MeshPrsBuilder)
 
 //=======================================================================
 // function : Creation
@@ -37,363 +37,20 @@ MeshVS_LODBuilder::MeshVS_LODBuilder (const Handle(MeshVS_Mesh)& theParentMesh,
                                       const Handle(MeshVS_LODDataSource)& theDataSource,
                                       const Standard_Integer theId,
                                       const MeshVS_BuilderPriority& thePriority)
-  : MeshVS_PrsBuilder (theParentMesh, theFlags, theDataSource, theId, thePriority)
+  : MeshVS_MeshPrsBuilder (theParentMesh, theFlags, theDataSource, theId, thePriority)
 {}
 
-//=======================================================================
-// function : Build
-// purpose  :
-//=======================================================================
-void MeshVS_LODBuilder::Build (const Handle(Prs3d_Presentation)& theBasePrs,
-                               const TColStd_PackedMapOfInteger& theIDs,
-                               TColStd_PackedMapOfInteger& /*theIDsToExclude*/,
-                               const Standard_Boolean theIsElement,
-                               const Standard_Integer theDisplayMode) const
-{
-  if (myParentMesh == NULL)
-    return;
-
-  if (theIsElement)
-  {
-    Standard_Integer aMaxNodesNb;
-
-    Handle(MeshVS_MeshPrsBuilder) aBuilder = Handle(MeshVS_MeshPrsBuilder)::DownCast (myParentMesh->GetBuilder (1));
-    if (aBuilder.IsNull())
-      return;
-    Handle(MeshVS_Drawer) aDrawer = aBuilder->GetDrawer();
-    if (aDrawer.IsNull() ||
-        !aDrawer->GetInteger (MeshVS_DA_MaxFaceNodes, aMaxNodesNb) ||
-        aMaxNodesNb <= 0)
-      return;
-
-    //----------- extract useful display mode flags ----------
-    Standard_Integer aDispStatus = (theDisplayMode & aBuilder->GetFlags());
-    if ((aDispStatus & MeshVS_DMF_DeformedMask) != 0)
-    {
-      aDispStatus /= MeshVS_DMF_DeformedPrsWireFrame;
-      // This transformation turns deformed mesh flags to real display modes
-    }
-    aDispStatus &= MeshVS_DMF_OCCMask;
-    //--------------------------------------------------------
-
-    Standard_Real aShrinkCoef;
-    aDrawer->GetDouble (MeshVS_DA_ShrinkCoeff, aShrinkCoef);
-
-    const Standard_Boolean isWireframe = theDisplayMode == MeshVS_DMF_WireFrame;
-    Standard_Boolean isShading = theDisplayMode == MeshVS_DMF_Shading;
-    Standard_Boolean isShrink = theDisplayMode == MeshVS_DMF_Shrink;
-    const Standard_Boolean hasHilightFlag = (aDispStatus & MeshVS_DMF_HilightPrs) != 0;
-    const Standard_Boolean hasSelFlag =(aDispStatus & MeshVS_DMF_SelectionPrs) != 0;
-    Standard_Boolean isMeshSmoothShading = Standard_False;
-    Standard_Boolean isMeshReflect, isMeshAllowOverlap, isReflect;
-
-    aDrawer->GetBoolean (MeshVS_DA_Reflection, isMeshReflect);
-    aDrawer->GetBoolean (MeshVS_DA_IsAllowOverlapped, isMeshAllowOverlap);
-    isReflect = isMeshReflect && !hasHilightFlag;
-    aDrawer->GetBoolean (MeshVS_DA_SmoothShading, isMeshSmoothShading);
-
-    // display mode for highlighted prs of groups
-    isShrink = isShrink && !hasHilightFlag;
-    isShading = isShading || hasHilightFlag;
-
-        Graphic3d_MaterialAspect aMatAspect;
-    aDrawer->GetMaterial (MeshVS_DA_FrontMaterial, aMatAspect);
-    if (!isReflect)
-    {
-      aMatAspect.SetReflectionModeOff(Graphic3d_TOR_AMBIENT);
-      aMatAspect.SetReflectionModeOff(Graphic3d_TOR_DIFFUSE);
-      aMatAspect.SetReflectionModeOff(Graphic3d_TOR_SPECULAR);
-      aMatAspect.SetReflectionModeOff(Graphic3d_TOR_EMISSION);
-    }
-    Handle(Graphic3d_AspectFillArea3d ) aFill = MeshVS_Tool::CreateAspectFillArea3d (aDrawer, aMatAspect);
-    Handle(Graphic3d_AspectLine3d ) aBeam = MeshVS_Tool::CreateAspectLine3d (aDrawer);
-
-    const Standard_Boolean isOverlapControl =
-      !isMeshAllowOverlap && (isWireframe || isShading) && !hasSelFlag;
-
-    // subtract the hidden elements and ids to exclude (to minimize allocated memory)
-    TColStd_PackedMapOfInteger anIDs;
-    anIDs.Assign (theIDs);
-    Handle(TColStd_HPackedMapOfInteger) aHiddenElems = myParentMesh->GetHiddenElems();
-    if (!aHiddenElems.IsNull())
-      anIDs.Subtract (aHiddenElems->Map());
-
-    Handle(MeshVS_HArray1OfSequenceOfInteger) aTopo;
-
-    Standard_Boolean toShowEdges = Standard_True;
-    aDrawer->GetBoolean (MeshVS_DA_ShowEdges, toShowEdges);
-
-    toShowEdges = isWireframe || toShowEdges;
-
-    Standard_Integer* aNodesBuf = (Standard_Integer*)alloca (aMaxNodesNb * sizeof (Standard_Integer));
-    Standard_Real*    aCoordsBuf = (Standard_Real*)alloca (3 * aMaxNodesNb * sizeof (Standard_Real));
-
-    TColStd_Array1OfInteger aNodes (*aNodesBuf, 1, aMaxNodesNb);
-    TColStd_Array1OfReal    aCoords (*aCoordsBuf, 1, 3 * aMaxNodesNb);
-
-    Standard_Integer aNbFacePrimitives = 0;
-    Standard_Integer aNbVolmPrimitives = 0;
-    Standard_Integer aNbEdgePrimitives = 0;
-    Standard_Integer aNbLinkPrimitives = 0;
-
-    MeshVS_EntityType aType;
-
-    TColStd_MapIteratorOfPackedMapOfInteger anIdxIter (anIDs);
-    for (anIdxIter.Reset(); anIdxIter.More(); anIdxIter.Next())
-    {
-      Standard_Integer aNbNodes = 0;
-
-      if (!DataSource()->GetGeom (anIdxIter.Key(), Standard_True, aCoords, aNbNodes, aType))
-        continue;
-
-      if (aType == MeshVS_ET_Volume)
-      {
-        if (DataSource()->Get3DGeom (anIdxIter.Key(), aNbNodes, aTopo))
-        {
-          for (Standard_Integer aFaceIdx = aTopo->Lower(); aFaceIdx <= aTopo->Upper(); ++aFaceIdx)
-          {
-            const TColStd_SequenceOfInteger& aFaceNodes = aTopo->Value(aFaceIdx);
-
-            if (toShowEdges) // add edge segments
-            {
-              aNbEdgePrimitives += aFaceNodes.Length();
-            }
-
-            if (isShading || isShrink) // add volumetric cell triangles
-            {
-              if (!hasSelFlag)
-                aNbVolmPrimitives += aFaceNodes.Length() - 2;
-            }
-          }
-        }
-      }
-      else if (aType == MeshVS_ET_Link)
-      {
-        if (toShowEdges)
-        {
-          aNbLinkPrimitives += 1; // add link segment
-        }
-      }
-      else if (aType == MeshVS_ET_Face)
-      {
-        if (toShowEdges)
-        {
-          aNbEdgePrimitives += aNbNodes; // add edge segments
-        }
-
-        if (!isOverlapControl || isShading)
-        {
-          if ((isShading || isShrink) && !hasSelFlag)
-          {
-            aNbFacePrimitives += aNbNodes - 2; // add face triangles
-          }
-        }
-      }
-    }
-
-    // Here we do not use indices arrays because they are not effective for some mesh
-    // drawing modes: shrinking mode (displaces the vertices inside the polygon), 3D
-    // cell rendering (normal interpolation is not always applicable - flat shading),
-    // elemental coloring (color interpolation is impossible)
-    Handle(Graphic3d_ArrayOfTriangles) aVolmTriangles =
-      new Graphic3d_ArrayOfTriangles (aNbVolmPrimitives * 3, 0, isReflect);
-    Handle(Graphic3d_ArrayOfTriangles) aFaceTriangles =
-      new Graphic3d_ArrayOfTriangles (aNbFacePrimitives * 3, 0, isReflect);
-
-    Handle(Graphic3d_ArrayOfSegments) aLinkSegments;
-    Handle(Graphic3d_ArrayOfSegments) aEdgeSegments;
-
-    if (toShowEdges)
-    {
-      aLinkSegments = new Graphic3d_ArrayOfSegments (aNbLinkPrimitives * 2);
-      aEdgeSegments = new Graphic3d_ArrayOfSegments (aNbEdgePrimitives * 2);
-    }
-
-    TColStd_PackedMapOfInteger aCustomElements;
-
-    MeshVS_MapOfTwoNodes aLinkNodes;
-
-    Quantity_Color       anOldEdgeColor;
-    Quantity_Color       anEdgeColor;
-    Quantity_Color       anIntColor;
-    Aspect_InteriorStyle anIntType;
-    Aspect_TypeOfLine    aLine;
-    Standard_Real        aWidth;
-
-    aFill->Values (anIntType, anIntColor, anEdgeColor, aLine, aWidth);
-
-    // Forbid drawings of edges which overlap with some links
-    if (toShowEdges && isOverlapControl)
-    {
-      for (anIdxIter.Reset(); anIdxIter.More(); anIdxIter.Next())
-      {
-        if (DataSource()->GetGeomType (anIdxIter.Key(), Standard_True, aType) && aType == MeshVS_ET_Link)
-        {
-          Standard_Integer aNbNodes;
-
-          if (DataSource()->GetNodesByElement (anIdxIter.Key(), aNodes, aNbNodes) && aNbNodes == 2)
-          {
-            aLinkNodes.Add (MeshVS_TwoNodes (aNodes(1), aNodes(2)));
-          }
-        }
-      }
-    }
-
-    NCollection_Map<MeshVS_NodePair, MeshVS_SymmetricPairHasher> aSegmentMap;
-
-    for (anIdxIter.Reset(); anIdxIter.More(); anIdxIter.Next())
-    {
-      const Standard_Integer aKey = anIdxIter.Key();
-
-      Standard_Integer NbNodes;
-      if (!DataSource()->GetGeom (aKey, Standard_True, aCoords, NbNodes, aType))
-        continue;
-
-      if (!DataSource()->GetNodesByElement (aKey, aNodes, NbNodes))
-        continue;
-
-      switch (aType)
-      {
-      case MeshVS_ET_Volume:
-      {
-        if (DataSource()->Get3DGeom (aKey, NbNodes, aTopo))
-        {
-          // Add wire-frame presentation (draw edges for shading mode as well)
-          if (toShowEdges)
-          {
-            aBuilder->AddVolumePrs (aTopo, aCoords, NbNodes,
-                                    aEdgeSegments, isReflect,
-                                    isShrink, hasSelFlag,
-                                    aShrinkCoef);
-          }
-
-          // Add shading presentation
-          if ((isShading || isShrink) && !hasSelFlag)
-          {
-            aBuilder->AddVolumePrs (aTopo, aCoords, NbNodes,
-                                    aVolmTriangles, isReflect,
-                                    isShrink, hasSelFlag,
-                                    aShrinkCoef);
-          }
-        }
-      }
-      break;
-
-      case MeshVS_ET_Link:
-      {
-        if (toShowEdges)
-        {
-          aBuilder->AddLinkPrs (aCoords, aLinkSegments, isShrink || hasSelFlag, aShrinkCoef);
-        }
-      }
-      break;
-
-      case MeshVS_ET_Face:
-      {
-        if (toShowEdges && isOverlapControl)
-        {
-          Standard_Integer Last = 0;
-
-          MeshVS_TwoNodes aTwoNodes (aNodes(1));
-
-          for (Standard_Integer i = 1; i <= NbNodes; ++i)
-          {
-            if (i > 1)
-              aTwoNodes.First = aTwoNodes.Second;
-
-            aTwoNodes.Second = (i < NbNodes) ? aNodes (i + 1) : aNodes (1);
-
-            if (aLinkNodes.Contains (aTwoNodes))
-            {
-              for (Standard_Integer aNodeIdx = Last + 1; aNodeIdx < i; ++aNodeIdx)
-              {
-                const Standard_Integer aNextIdx = aNodeIdx + 1;
-
-                aEdgeSegments->AddVertex (
-                  aCoords (3 * aNodeIdx - 2), aCoords (3 * aNodeIdx - 1), aCoords (3 * aNodeIdx));
-                aEdgeSegments->AddVertex(
-                  aCoords (3 * aNextIdx - 2), aCoords (3 * aNextIdx - 1), aCoords (3 * aNextIdx));
-              }
-
-              Last = i;
-            }
-          }
-
-          if (NbNodes - Last > 0)
-          {
-            for (Standard_Integer aNodeIdx = Last; aNodeIdx < NbNodes; ++aNodeIdx)
-            {
-              const Standard_Integer aNextIdx = (aNodeIdx + 1) % NbNodes;
-
-              const MeshVS_NodePair aSegment (aNodes (aNodeIdx + 1), aNodes (aNextIdx + 1));
-
-              if (!aSegmentMap.Contains (aSegment))
-              {
-                aEdgeSegments->AddVertex (aCoords (3 * aNodeIdx + 1),
-                                          aCoords (3 * aNodeIdx + 2),
-                                          aCoords (3 * aNodeIdx + 3));
-
-                aEdgeSegments->AddVertex (aCoords (3 * aNextIdx + 1),
-                                          aCoords (3 * aNextIdx + 2),
-                                          aCoords (3 * aNextIdx + 3));
-
-                aSegmentMap.Add (aSegment);
-              }
-            }
-          }
-        }
-
-        if (!isOverlapControl || isShading)
-        {
-          if (!isOverlapControl && toShowEdges)
-          {
-            aBuilder->AddFaceWirePrs (aCoords, NbNodes, aEdgeSegments, isShrink || hasSelFlag, aShrinkCoef);
-          }
-
-          if ((isShading || isShrink) && !hasSelFlag)
-          {
-            aBuilder->AddFaceSolidPrs (DataSource(), aKey, aCoords, NbNodes, aMaxNodesNb, aFaceTriangles, isReflect,
-              isShrink || hasSelFlag, aShrinkCoef, isMeshSmoothShading);
-          }
-        }
-      }
-      break;
-
-      default:
-        aCustomElements.Add (aKey);
-      }
-    }
-
-    if (isShrink)
-    {
-      anOldEdgeColor = anEdgeColor;
-      aFill->SetEdgeColor (Quantity_NOC_BLACK);
-    }
-
-    Standard_Boolean isSupressBackFaces = Standard_False;
-    if (!aDrawer.IsNull())
-    {
-      aDrawer->GetBoolean (MeshVS_DA_SupressBackFaces, isSupressBackFaces);
-    }
-    drawArrays (theBasePrs, aFaceTriangles, aEdgeSegments, aLinkSegments, aVolmTriangles,
-      !toShowEdges, hasSelFlag, isSupressBackFaces, aFill, aBeam);
-  }
-}
-
-#include <Prs3d_Root.hxx>
-
 //================================================================
-// Function : drawArrays
+// Function : DrawArrays
 // Purpose  :
 //================================================================
-void MeshVS_LODBuilder::drawArrays (const Handle(Prs3d_Presentation)& theBasePrs,
+void MeshVS_LODBuilder::DrawArrays (const Handle(Prs3d_Presentation)& theBasePrs,
                                     const Handle(Graphic3d_ArrayOfPrimitives)& thePolygons,
                                     const Handle(Graphic3d_ArrayOfPrimitives)& theLines,
                                     const Handle(Graphic3d_ArrayOfPrimitives)& theLinkLines,
                                     const Handle(Graphic3d_ArrayOfPrimitives)& theVolumesInShad,
                                     const Standard_Boolean theIsPolygonsEdgesOff,
                                     const Standard_Boolean theIsSelected,
-                                    const Standard_Boolean theIsSupressBackFaces,
                                     const Handle(Graphic3d_AspectFillArea3d)& theFillAsp,
                                     const Handle(Graphic3d_AspectLine3d)& theLineAsp) const
 {
@@ -406,6 +63,13 @@ void MeshVS_LODBuilder::drawArrays (const Handle(Prs3d_Presentation)& theBasePrs
                    isPolylines      = (!theLines.IsNull() && theLines->ItemNumber() > 0),
                    isLinkPolylines  = (!theLinkLines.IsNull() && theLinkLines->ItemNumber() > 0);
 
+  Standard_Boolean isSupressBackFaces = Standard_False;
+  Handle(MeshVS_Drawer) aDrawer = GetDrawer();
+  if (!aDrawer.IsNull())
+  {
+    aDrawer->GetBoolean (MeshVS_DA_SupressBackFaces, isSupressBackFaces);
+  }
+
   Aspect_InteriorStyle aStyle;
   Quantity_Color anIntColor, aBackColor, anEdgeColor;
   Aspect_TypeOfLine aType;
@@ -425,9 +89,9 @@ void MeshVS_LODBuilder::drawArrays (const Handle(Prs3d_Presentation)& theBasePrs
     else
       theFillAsp->SetDistinguishOff();
 
-    aGroup->SetClosed (theIsSupressBackFaces);
+    aGroup->SetClosed (isSupressBackFaces);
     Handle(Graphic3d_AspectFillArea3d) aFillAsp = new Graphic3d_AspectFillArea3d (*(theFillAsp.operator->()));
-    if (theIsSupressBackFaces)
+    if (isSupressBackFaces)
     {
       aFillAsp->SuppressBackFace();
     }
@@ -483,9 +147,9 @@ void MeshVS_LODBuilder::drawArrays (const Handle(Prs3d_Presentation)& theBasePrs
     else
       theFillAsp->SetDistinguishOff();
 
-    aGroup->SetClosed (theIsSupressBackFaces);
+    aGroup->SetClosed (isSupressBackFaces);
     Handle(Graphic3d_AspectFillArea3d) aFillAsp = new Graphic3d_AspectFillArea3d (*(theFillAsp.operator->()));
-    if (theIsSupressBackFaces)
+    if (isSupressBackFaces)
     {
       aFillAsp->SuppressBackFace();
     }
index 4639b1bf9f2bec7822011654bc8fb005c9994e93..10b04028864f134d0ad96a016516ce0e9de8c314 100644 (file)
 #define _MeshVS_LODBuilder_Header
 
 #include <MeshVS_Mesh.hxx>
-#include <MeshVS_PrsBuilder.hxx>
+#include <MeshVS_MeshPrsBuilder.hxx>
 #include <MeshVS_LODDataSource.hxx>
 
-class MeshVS_LODBuilder : public MeshVS_PrsBuilder
+//! The class is used to build graphic groups for one LOD of the presentation.
+//! The only difference between usual MeshVS_MeshPrsBuilder is in approach to
+//! filling the presentation: LOD groups are created instead of own groups of
+//! the presentation.
+class MeshVS_LODBuilder : public MeshVS_MeshPrsBuilder
 {
 public:
   
@@ -33,34 +37,23 @@ public:
 
   Standard_EXPORT virtual ~MeshVS_LODBuilder() {};
 
-  //! Builds presentation of certain type of data.
-  //! Prs is presentation object which this method constructs.
-  //! IDs is set of numeric identificators forming object appearance.
-  //! IDsToExclude is set of IDs to exclude from processing. If some entity
-  //! has been excluded, it is not processed by other builders.
-  //! IsElement indicates, IDs is identificators of nodes or elements.
-  //! DisplayMode is numeric constant describing display mode (see MeshVS_DisplayModeFlags.hxx)
-  Standard_EXPORT virtual void Build (const Handle(Prs3d_Presentation)& theBasePrs,
-                                      const TColStd_PackedMapOfInteger& theIDs,
-                                      TColStd_PackedMapOfInteger& theIDsToExclude,
-                                      const Standard_Boolean theIsElement,
-                                      const Standard_Integer theDisplayMode) const Standard_OVERRIDE;
-
   DEFINE_STANDARD_RTTIEXT (MeshVS_LODBuilder, MeshVS_PrsBuilder)
 
 protected:
-  void drawArrays (const Handle(Prs3d_Presentation)& theBasePrs,
-                   const Handle(Graphic3d_ArrayOfPrimitives)& thePolygons,
-                   const Handle(Graphic3d_ArrayOfPrimitives)& theLines,
-                   const Handle(Graphic3d_ArrayOfPrimitives)& theLinkLines,
-                   const Handle(Graphic3d_ArrayOfPrimitives)& theVolumesInShad,
-                   const Standard_Boolean theIsPolygonsEdgesOff,
-                   const Standard_Boolean theIsSelected,
-                   const Standard_Boolean theIsSupressBackFaces,
-                   const Handle(Graphic3d_AspectFillArea3d)& theFillAsp,
-                   const Handle(Graphic3d_AspectLine3d)& theLineAsp) const;
+
+  //! Creates LOD graphic groups, adds them to base presentation and fills according to the build
+  //! parameters
+  Standard_EXPORT virtual void DrawArrays (const Handle(Prs3d_Presentation)& theBasePrs,
+                                           const Handle(Graphic3d_ArrayOfPrimitives)& thePolygons,
+                                           const Handle(Graphic3d_ArrayOfPrimitives)& theLines,
+                                           const Handle(Graphic3d_ArrayOfPrimitives)& theLinkLines,
+                                           const Handle(Graphic3d_ArrayOfPrimitives)& theVolumesInShad,
+                                           const Standard_Boolean theIsPolygonsEdgesOff,
+                                           const Standard_Boolean theIsSelected,
+                                           const Handle(Graphic3d_AspectFillArea3d)& theFillAsp,
+                                           const Handle(Graphic3d_AspectLine3d)& theLineAsp) const Standard_OVERRIDE;
 };
 
-DEFINE_STANDARD_HANDLE (MeshVS_LODBuilder, MeshVS_PrsBuilder)
+DEFINE_STANDARD_HANDLE (MeshVS_LODBuilder, MeshVS_MeshPrsBuilder)
 
 #endif // _MeshVS_LODBuilder_Header
index a3deb7967f53db444a3682673fba253f58552cbe..3a2eb9cecf71b828ac15ec964bd637628328d88e 100644 (file)
 #include <Poly_Triangle.hxx>
 #include <StlMesh_Mesh.hxx>
 
-//! TODO: VPA: think how to avoid copying mesh data. Now it is done for returning useless maps
-//!            in GetAllElements() and GetAllNodes() because they must return const links. Moreover,
-//!            copying data allows to avoid cases when indexation in Poly_Triangluation inner
-//!            arrays starts from arbitrary numbers (if it is really possible).
+//! The class is used to parse LOD data stored in StlMesh_Mesh object
 class MeshVS_LODDataSource : public MeshVS_DataSource
 {
 public:
index 4322a46693b1cc3d99578711cfb6cd8e0453548b..1253884018a5f2ce903e1455d406ddae298b0d8d 100644 (file)
@@ -723,8 +723,7 @@ void MeshVS_MeshPrsBuilder::AddFaceWirePrs (const TColStd_Array1OfReal&
 // Function : AddFaceSolidPrs
 // Purpose  :
 //================================================================
-void MeshVS_MeshPrsBuilder::AddFaceSolidPrs (const Handle(MeshVS_DataSource)&          theDataSource,
-                                             const Standard_Integer                    theID,
+void MeshVS_MeshPrsBuilder::AddFaceSolidPrs (const Standard_Integer                    theID,
                                              const TColStd_Array1OfReal&               theCoords,
                                              const Standard_Integer                    theNbNodes,
                                              const Standard_Integer                    theMaxNodes,
@@ -734,7 +733,9 @@ void MeshVS_MeshPrsBuilder::AddFaceSolidPrs (const Handle(MeshVS_DataSource)&
                                              const Standard_Real                       theShrinkingCoef,
                                              const Standard_Boolean                    theIsSmoothShading) const
 {
-  if (theDataSource.IsNull())
+  Handle(MeshVS_DataSource) aDataSource = myParentMesh->GetDataSource();
+
+  if (aDataSource.IsNull())
     return;
 
   Standard_Real aCenterX = 0.0;
@@ -757,7 +758,7 @@ void MeshVS_MeshPrsBuilder::AddFaceSolidPrs (const Handle(MeshVS_DataSource)&
     {
       for (Standard_Integer aNodeIdx = 1; aNodeIdx <= theNbNodes; ++aNodeIdx)
       {
-        if (!theDataSource->GetNodeNormal (aNodeIdx, theID, aNormalX, aNormalY, aNormalZ))
+        if (!aDataSource->GetNodeNormal (aNodeIdx, theID, aNormalX, aNormalY, aNormalZ))
           break;
 
         aVertexNormals.Append (gp_XYZ (aNormalX, aNormalY, aNormalZ));
@@ -766,7 +767,7 @@ void MeshVS_MeshPrsBuilder::AddFaceSolidPrs (const Handle(MeshVS_DataSource)&
 
     if (!theIsSmoothShading || aVertexNormals.Size() != theNbNodes)
     {
-      theDataSource->GetNormal (theID, theMaxNodes, aNormalX, aNormalY, aNormalZ);
+      aDataSource->GetNormal (theID, theMaxNodes, aNormalX, aNormalY, aNormalZ);
     }
   }
 
@@ -819,26 +820,6 @@ void MeshVS_MeshPrsBuilder::AddFaceSolidPrs (const Handle(MeshVS_DataSource)&
   }
 }
 
-//================================================================
-// Function : AddFaceSolidPrs
-// Purpose  :
-//================================================================
-void MeshVS_MeshPrsBuilder::AddFaceSolidPrs (const Standard_Integer                    theID,
-                                             const TColStd_Array1OfReal&               theCoords,
-                                             const Standard_Integer                    theNbNodes,
-                                             const Standard_Integer                    theMaxNodes,
-                                             const Handle(Graphic3d_ArrayOfTriangles)& theTriangles,
-                                             const Standard_Boolean                    theIsShaded,
-                                             const Standard_Boolean                    theIsShrinked,
-                                             const Standard_Real                       theShrinkingCoef,
-                                             const Standard_Boolean                    theIsSmoothShading) const
-{
-  Handle(MeshVS_DataSource) aDataSource = myParentMesh->GetDataSource();
-  AddFaceSolidPrs (aDataSource, theID, theCoords, theNbNodes, theMaxNodes, theTriangles,
-    theIsShaded, theIsShrinked, theShrinkingCoef, theIsSmoothShading);
-}
-
-
 //================================================================
 // Function : AddVolumePrs
 // Purpose  :
index 8bcb372f9a9d02742841407e28c5fdd6cfde0089..4da65717717470b3010bb0a93f7c4687f4ce9dd9 100644 (file)
@@ -95,6 +95,10 @@ public:
                                                  Standard_Integer& Vertices,
                                                  Standard_Integer& Bounds);
 
+  DEFINE_STANDARD_RTTIEXT(MeshVS_MeshPrsBuilder,MeshVS_PrsBuilder)
+
+protected:
+
   //! Add to array of polylines some lines representing link
   Standard_EXPORT void AddLinkPrs (const TColStd_Array1OfReal& theCoords,
                                    const Handle(Graphic3d_ArrayOfSegments)& theLines,
@@ -108,22 +112,6 @@ public:
                                        const Standard_Boolean theIsShrinked,
                                        const Standard_Real theShrinkingCoef) const;
 
-  //! Add to array of polygons a polygon representing face
-  Standard_EXPORT void AddFaceSolidPrs (const Handle(MeshVS_DataSource)& theDataSource,
-                                        const Standard_Integer ID,
-                                        const TColStd_Array1OfReal& theCoords,
-                                        const Standard_Integer theNbNodes,
-                                        const Standard_Integer theMaxNodes,
-                                        const Handle(Graphic3d_ArrayOfTriangles)& theTriangles,
-                                        const Standard_Boolean theIsReflected,
-                                        const Standard_Boolean theIsShrinked,
-                                        const Standard_Real theShrinkCoef,
-                                        const Standard_Boolean theIsMeshSmoothShading) const;
-
-  DEFINE_STANDARD_RTTIEXT(MeshVS_MeshPrsBuilder,MeshVS_PrsBuilder)
-
-protected:
-
   //! Add to array of polygons a polygon representing face
   Standard_EXPORT void AddFaceSolidPrs (const Standard_Integer ID,
                                         const TColStd_Array1OfReal& theCoords,
@@ -136,15 +124,15 @@ protected:
                                         const Standard_Boolean theIsMeshSmoothShading) const;
 
   //! Draw array of polygons and polylines in the certain order according to transparency
-  Standard_EXPORT void DrawArrays (const Handle(Prs3d_Presentation)& Prs,
-                                   const Handle(Graphic3d_ArrayOfPrimitives)& thePolygons,
-                                   const Handle(Graphic3d_ArrayOfPrimitives)& theLines,
-                                   const Handle(Graphic3d_ArrayOfPrimitives)& theLinkLines,
-                                   const Handle(Graphic3d_ArrayOfPrimitives)& theVolumesInShad,
-                                   const Standard_Boolean IsPolygonsEdgesOff,
-                                   const Standard_Boolean IsSelected,
-                                   const Handle(Graphic3d_AspectFillArea3d)& theFillAsp,
-                                   const Handle(Graphic3d_AspectLine3d)& theLineAsp) const;
+  Standard_EXPORT virtual void DrawArrays (const Handle(Prs3d_Presentation)& Prs,
+                                           const Handle(Graphic3d_ArrayOfPrimitives)& thePolygons,
+                                           const Handle(Graphic3d_ArrayOfPrimitives)& theLines,
+                                           const Handle(Graphic3d_ArrayOfPrimitives)& theLinkLines,
+                                           const Handle(Graphic3d_ArrayOfPrimitives)& theVolumesInShad,
+                                           const Standard_Boolean IsPolygonsEdgesOff,
+                                           const Standard_Boolean IsSelected,
+                                           const Handle(Graphic3d_AspectFillArea3d)& theFillAsp,
+                                           const Handle(Graphic3d_AspectLine3d)& theLineAsp) const;
 
   //! Default calculation of center of face or link. This method if useful for shrink mode presentation
   //! theCoords is array of nodes co-ordinates in the strict order X1, Y1, Z1, X2...
index 17f06f9fabed3e91c98d57b445b76eff005bd0ce..da1684386741526228e781b6997a28e7ecb3f084 100644 (file)
@@ -199,6 +199,9 @@ public:
   //! Returns parent of current object in scene hierarchy.
   Standard_EXPORT PrsMgr_PresentableObjectPointer Parent() const;
 
+  //! Must be redefined for objects represented through levels of detail.
+  //! Default implementation returns false, if the object is represented by
+  //! LODs, the method must return true.
   Standard_EXPORT virtual Standard_Boolean HasLevelsOfDetail() const;
 
 
@@ -222,6 +225,7 @@ protected:
   Standard_EXPORT PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
 Standard_EXPORT virtual ~PrsMgr_PresentableObject();
 
+  //! Computes levels of detail for the presentation.
   Standard_EXPORT virtual void ComputeLods (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
                                             const Handle(Prs3d_Presentation)& thePrs,
                                             const Standard_Integer theMode = 0);
index 1f9e1b048118b414e6c0dafcf8b4b50bf1c8d124..bc67ce1e362581492136b91378922caa41ef2110 100644 (file)
@@ -1515,19 +1515,13 @@ static int MeshLod (Draw_Interpretor& theDI,
   }
 
   Handle(MeshVS_Mesh) anOriginMesh = new MeshVS_Mesh();
-  Handle(XSDRAWSTLVRML_DataSource) anOriginDataSource = new XSDRAWSTLVRML_DataSource (aLargestMesh);
-  anOriginMesh->SetDataSource (anOriginDataSource);
-  Handle(MeshVS_MeshPrsBuilder) anOriginBuilder = new MeshVS_MeshPrsBuilder (anOriginMesh.operator->());
-  anOriginMesh->AddBuilder (anOriginBuilder, Standard_True);
-  anOriginMesh->GetDrawer()->SetColor (MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW);
-
   for (NCollection_List<DetailLevelData>::Iterator aLodDataIter (myLODDataList); aLodDataIter.More(); aLodDataIter.Next())
   {
     Handle(MeshVS_LODDataSource) aLod = new MeshVS_LODDataSource (aLodDataIter.Value().myMesh);
     anOriginMesh->AddDataSource (aLod);
     Handle(MeshVS_LODBuilder) aLODBuilder = new MeshVS_LODBuilder (anOriginMesh.operator->());
     aLODBuilder->SetDataSource (aLod);
-    aLODBuilder->SetDrawer (anOriginBuilder->GetDrawer());
+    aLODBuilder->GetDrawer()->SetColor (MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW);
     anOriginMesh->AddBuilder (aLODBuilder);
   }