]> OCCT Git - occt.git/commitdiff
0028213: Visualization, StdPrs_ShadedShape - compute face edges for triangulation...
authorkgv <kgv@opencascade.com>
Mon, 12 Dec 2016 09:54:25 +0000 (12:54 +0300)
committerapn <apn@opencascade.com>
Thu, 15 Dec 2016 13:37:35 +0000 (16:37 +0300)
src/StdPrs/StdPrs_ShadedShape.cxx
src/StdPrs/StdPrs_WFShape.cxx
src/StdPrs/StdPrs_WFShape.hxx
tests/bugs/vis/bug27821

index e8c6810a23dc78ef72856f2d27b5679e926d6a18..e76fa32a8e91608ab58d34d74094122cba48dd22 100644 (file)
@@ -304,6 +304,17 @@ namespace
     Standard_Integer aNbPolylines = 0;
 
     TopLoc_Location aTrsf;
+    TColgp_SequenceOfPnt aSeqPntsExtra;
+    for (TopExp_Explorer aFaceIter (theShape, TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
+    {
+      const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Current());
+      TopoDS_Iterator aSubShapeIter (aFace);
+      if (!aSubShapeIter.More())
+      {
+        // handle specifically faces without boundary definition (triangulation-only)
+        StdPrs_WFShape::AddEdgesOnTriangulation (aSeqPntsExtra, aFace, Standard_False);
+      }
+    }
 
     // explore all boundary edges
     TopTools_IndexedDataMapOfShapeListOfShape anEdgesMap;
@@ -335,12 +346,24 @@ namespace
     }
     if (aNodeNumber == 0)
     {
-      return Handle(Graphic3d_ArrayOfSegments)();
+      if (aSeqPntsExtra.Size() < 2)
+      {
+        return Handle(Graphic3d_ArrayOfSegments)();
+      }
+
+      Standard_Integer aNbVertices = aSeqPntsExtra.Size();
+      Handle(Graphic3d_ArrayOfSegments) aSegments = new Graphic3d_ArrayOfSegments (aNbVertices);
+      for (Standard_Integer aPntIter = 1; aPntIter <= aNbVertices; aPntIter += 2)
+      {
+        aSegments->AddVertex (aSeqPntsExtra.Value (aPntIter));
+        aSegments->AddVertex (aSeqPntsExtra.Value (aPntIter + 1));
+      }
+      return aSegments;
     }
 
     // create indexed segments array to pack polylines from different edges into single array
     const Standard_Integer aSegmentEdgeNb = (aNodeNumber - aNbPolylines) * 2;
-    Handle(Graphic3d_ArrayOfSegments) aSegments = new Graphic3d_ArrayOfSegments (aNodeNumber, aSegmentEdgeNb);
+    Handle(Graphic3d_ArrayOfSegments) aSegments = new Graphic3d_ArrayOfSegments (aNodeNumber + aSeqPntsExtra.Size(), aSegmentEdgeNb + aSeqPntsExtra.Size());
     for (TopTools_IndexedDataMapOfShapeListOfShape::Iterator anEdgeIter (anEdgesMap); anEdgeIter.More(); anEdgeIter.Next())
     {
       if (anEdgeIter.Value().Extent() == 0)
@@ -388,6 +411,19 @@ namespace
         }
       }
     }
+
+    {
+      Standard_Integer aSegmentEdge = aSegments->VertexNumber();
+      const Standard_Integer aNbVertices = aSeqPntsExtra.Size();
+      for (Standard_Integer aPntIter = 1; aPntIter <= aNbVertices; aPntIter += 2)
+      {
+        aSegments->AddVertex (aSeqPntsExtra.Value (aPntIter));
+        aSegments->AddEdge (++aSegmentEdge);
+        aSegments->AddVertex (aSeqPntsExtra.Value (aPntIter + 1));
+        aSegments->AddEdge (++aSegmentEdge);
+      }
+    }
+
     return aSegments;
   }
 
index 5522ea5fe186279a1d8a77a3fbc2c61f88003b8f..f566250dae92a7c8676d13d06f3a5acdd5d73499 100644 (file)
@@ -73,15 +73,13 @@ void StdPrs_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
 
   // Draw shape elements
   {
-    TopTools_ListOfShape aDiscreteFaces;
-    for (aTool.InitFace(); aTool.MoreFace(); aTool.NextFace())
+    Handle(Graphic3d_ArrayOfPrimitives) aTriFreeEdges = AddEdgesOnTriangulation (theShape, Standard_True);
+    if (!aTriFreeEdges.IsNull())
     {
-      if (!aTool.HasSurface())
-      {
-        aDiscreteFaces.Append (aTool.GetFace());
-      }
+      Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
+      aGroup->SetPrimitivesAspect (theDrawer->FreeBoundaryAspect()->Aspect());
+      aGroup->AddPrimitiveArray (aTriFreeEdges);
     }
-    addEdgesOnTriangulation (thePresentation, aDiscreteFaces, theDrawer->FreeBoundaryAspect());
   }
 
   Prs3d_NListOfSequenceOfPnt aCommonPolylines;
@@ -263,19 +261,47 @@ void StdPrs_WFShape::addEdges (const TopTools_ListOfShape&  theEdges,
 // function : AddEdgesOnTriangulation
 // purpose  :
 // =========================================================================
-void StdPrs_WFShape::addEdgesOnTriangulation (const Handle(Prs3d_Presentation)& thePresentation,
-                                              const TopTools_ListOfShape&       theFaces,
-                                              const Handle (Prs3d_LineAspect)&  theAspect)
+Handle(Graphic3d_ArrayOfPrimitives) StdPrs_WFShape::AddEdgesOnTriangulation (const TopoDS_Shape& theShape,
+                                                                             const Standard_Boolean theToExcludeGeometric)
 {
-  TColgp_SequenceOfPnt aSurfPoints;
+  TColgp_SequenceOfPnt aSeqPnts;
+  AddEdgesOnTriangulation (aSeqPnts, theShape, theToExcludeGeometric);
+  if (aSeqPnts.Size() < 2)
+  {
+    return Handle(Graphic3d_ArrayOfSegments)();
+  }
 
-  TopLoc_Location aLocation;
-  TopTools_ListIteratorOfListOfShape aFaceIter;
-  for (aFaceIter.Initialize (theFaces); aFaceIter.More(); aFaceIter.Next())
+  Standard_Integer aNbVertices = aSeqPnts.Size();
+  Handle(Graphic3d_ArrayOfSegments) aSurfArray = new Graphic3d_ArrayOfSegments (aNbVertices);
+  for (Standard_Integer anI = 1; anI <= aNbVertices; anI += 2)
   {
-    const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Value());
+    aSurfArray->AddVertex (aSeqPnts.Value (anI));
+    aSurfArray->AddVertex (aSeqPnts.Value (anI + 1));
+  }
+  return aSurfArray;
+}
 
-    Handle(Poly_Triangulation) T = BRep_Tool::Triangulation (aFace, aLocation);
+// =========================================================================
+// function : AddEdgesOnTriangulation
+// purpose  :
+// =========================================================================
+void StdPrs_WFShape::AddEdgesOnTriangulation (TColgp_SequenceOfPnt& theSegments,
+                                              const TopoDS_Shape& theShape,
+                                              const Standard_Boolean theToExcludeGeometric)
+{
+  TopLoc_Location aLocation, aDummyLoc;
+  for (TopExp_Explorer aFaceIter (theShape, TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
+  {
+    const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Current());
+    if (theToExcludeGeometric)
+    {
+      const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface (aFace, aDummyLoc);
+      if (!aSurf.IsNull())
+      {
+        continue;
+      }
+    }
+    const Handle(Poly_Triangulation)& T = BRep_Tool::Triangulation (aFace, aLocation);
     if (T.IsNull())
     {
       continue;
@@ -345,26 +371,10 @@ void StdPrs_WFShape::addEdgesOnTriangulation (const Handle(Prs3d_Presentation)&
     {
       gp_Pnt aPoint1 = aNodes (aFree (2 * anI - 1)).Transformed (aLocation);
       gp_Pnt aPoint2 = aNodes (aFree (2 * anI    )).Transformed (aLocation);
-      aSurfPoints.Append (aPoint1);
-      aSurfPoints.Append (aPoint2);
+      theSegments.Append (aPoint1);
+      theSegments.Append (aPoint2);
     }
   }
-
-  if (aSurfPoints.Length() < 2)
-  {
-    return;
-  }
-
-  Standard_Integer aNbVertices = aSurfPoints.Length();
-  Handle(Graphic3d_ArrayOfSegments) aSurfArray = new Graphic3d_ArrayOfSegments (aNbVertices);
-  for (Standard_Integer anI = 1; anI <= aNbVertices; anI += 2)
-  {
-    aSurfArray->AddVertex (aSurfPoints.Value (anI));
-    aSurfArray->AddVertex (aSurfPoints.Value (anI + 1));
-  }
-  Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
-  aGroup->SetPrimitivesAspect (theAspect->Aspect());
-  aGroup->AddPrimitiveArray (aSurfArray);
 }
 
 // =========================================================================
index 8d27dbe9daf87c8e88456561c3f7d9bf652504d7..db759de52cc353f9f5ff7bbfada05e52c4f7b4f1 100755 (executable)
@@ -37,6 +37,20 @@ public:
                                    const TopoDS_Shape&                theShape,
                                    const Handle (Prs3d_Drawer)&       theDrawer);
 
+  //! Compute free and boundary edges on a triangulation of each face in the given shape.
+  //! @param theShape              [in] the list of triangulated faces
+  //! @param theToExcludeGeometric [in] flag indicating that Faces with defined Surface should be skipped
+  Standard_EXPORT static Handle(Graphic3d_ArrayOfPrimitives) AddEdgesOnTriangulation (const TopoDS_Shape&    theShape,
+                                                                                      const Standard_Boolean theToExcludeGeometric = Standard_True);
+
+  //! Compute free and boundary edges on a triangulation of each face in the given shape.
+  //! @param theSegments           [in] the sequence of points defining segments
+  //! @param theShape              [in] the list of triangulated faces
+  //! @param theToExcludeGeometric [in] flag indicating that Faces with defined Surface should be skipped
+  Standard_EXPORT static void AddEdgesOnTriangulation (TColgp_SequenceOfPnt&  theSegments,
+                                                       const TopoDS_Shape&    theShape,
+                                                       const Standard_Boolean theToExcludeGeometric = Standard_True);
+
 private:
 
   //! Compute edge presentations for a shape.
@@ -48,15 +62,6 @@ private:
                         const Standard_Real         theShapeDeflection,
                         Prs3d_NListOfSequenceOfPnt& thePolylines);
 
-  //! Compute free and boundary edges on a triangulation of a face.
-  //! @param thePresentation [in] the presentation.
-  //! @param theFaces [in] the list of triangulated faces.
-  //! @param theAspect [in] the edge drawing aspect.
-  //! @param theDrawer [in] the drawer settings.
-  static void addEdgesOnTriangulation (const Handle(Prs3d_Presentation)& thePresentation,
-                                       const TopTools_ListOfShape& theFaces,
-                                       const Handle (Prs3d_LineAspect)& theAspect);
-
   //! Compute vertex presentation for a shape.
   //! @param thePresentation [in] the presentation.
   //! @param theVertices [in] the list of points.
index 96c3eb252326472ae54590272e35cb38c25a93a0..f0e5c8750642c9ed0fda4a872f43c374baab95e0 100644 (file)
@@ -18,7 +18,7 @@ vaxo
 vdisplay -noupdate -dispMode 0 s
 vaspects s -subshapes s_1 -setcolor RED
 vdisplay -noupdate -dispMode 1 s
-vshowfaceboundary s 1
+vshowfaceboundary s 1 255 0 0 2
 vfit
 vselect 250 250