]> OCCT Git - occt-copy.git/commitdiff
0029787: Avoid in presentation edges of certain continuity class
authorasl <asl@opencascade.com>
Fri, 18 May 2018 13:31:40 +0000 (16:31 +0300)
committerasl <asl@opencascade.com>
Mon, 21 May 2018 08:07:06 +0000 (11:07 +0300)
A new flag theMostAllowedEdgeClass is passed to the methods StdPrs_ShadedShape: Add, FillFaceBoundaries. It describes the most allowed continuity class of edges that will be included into the presentation. The edges with more continuity will be ignored. By default, the value is CN, i.e. all edges are included into the presentation.
The new methods in AIS_Shape: SetMostContinuityClass, MostContinuityClass allows specifying the most allowed continuity class of edges at the level of shape's presentation

src/AIS/AIS_Shape.cxx
src/AIS/AIS_Shape.hxx
src/StdPrs/StdPrs_ShadedShape.cxx
src/StdPrs/StdPrs_ShadedShape.hxx
src/ViewerTest/ViewerTest.cxx
tests/bugs/vis/bug29787 [new file with mode: 0644]

index 82b805bc06b96cb5c162070c19dc84de429ee059..148f99154156a24a8ac3605e0b0eb997959e5786 100644 (file)
@@ -90,7 +90,8 @@ AIS_Shape::AIS_Shape(const TopoDS_Shape& theShape)
   myUVRepeat(1.0, 1.0),
   myUVScale (1.0, 1.0),
   myInitAng (0.0),
-  myCompBB (Standard_True)
+  myCompBB (Standard_True),
+  myMostEdgeClass(GeomAbs_CN)
 {
   //
 }
@@ -164,7 +165,8 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
             StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer,
                                      myDrawer->ShadingAspect()->Aspect()->ToMapTexture()
                                  && !myDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(),
-                                     myUVOrigin, myUVRepeat, myUVScale);
+                                     myUVOrigin, myUVRepeat, myUVScale, StdPrs_Volume_Autodetection,
+                                     myMostEdgeClass);
           }
           catch (Standard_Failure const& anException)
           {
@@ -1192,3 +1194,23 @@ Standard_Boolean AIS_Shape::OwnHLRDeviationAngle ( Standard_Real &  anAngle,
   aPreviousAngle = myDrawer->PreviousHLRDeviationAngle (); 
   return myDrawer->HasOwnHLRDeviationAngle();
 }
+
+//=======================================================================
+//function : SetMostContinuityClass
+//purpose  : 
+//=======================================================================
+
+void AIS_Shape::SetMostContinuityClass(const GeomAbs_Shape theMostAllowedEdgeClass)
+{
+  myMostEdgeClass = theMostAllowedEdgeClass;
+}
+
+//=======================================================================
+//function : MostContinuityClass
+//purpose  : 
+//=======================================================================
+
+GeomAbs_Shape AIS_Shape::MostContinuityClass() const
+{
+  return myMostEdgeClass;
+}
index c6f566f2f5a63bd42e9129291ba644f2f5b31b1c..4a46b7d9fc5038e7966dc0ba66d36ca5246115ea 100644 (file)
@@ -22,6 +22,7 @@
 #include <TopoDS_Shape.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_TypeOfHLR.hxx>
+#include <GeomAbs_Shape.hxx>
 
 //! A framework to manage presentation and selection of shapes.
 //! AIS_Shape is the interactive object which is used the
@@ -214,6 +215,14 @@ public:
   //! the current facing model;
   Standard_EXPORT virtual Standard_Real Transparency() const Standard_OVERRIDE;
 
+  //! Set the most edge continuity class
+  //! @param theMostAllowedEdgeClass the most edge continuity class to be included to presentation 
+  //! (edges with more continuity should be ignored)
+  Standard_EXPORT void SetMostContinuityClass(const GeomAbs_Shape theMostAllowedEdgeClass);
+
+  //! Get the most edge continuity class
+  Standard_EXPORT GeomAbs_Shape MostContinuityClass() const;
+
   //! Return shape type for specified selection mode.
   static TopAbs_ShapeEnum SelectionType (const Standard_Integer theSelMode)
   {
@@ -330,7 +339,7 @@ protected:
   gp_Pnt2d         myUVScale;  //!< UV scale  vector for generating texture coordinates
   Standard_Real    myInitAng;
   Standard_Boolean myCompBB;   //!< if TRUE, then bounding box should be recomputed
-
+  GeomAbs_Shape    myMostEdgeClass; //!< the most edge continuity class to be included to the presentation
 };
 
 DEFINE_STANDARD_HANDLE(AIS_Shape, AIS_InteractiveObject)
index e098fc47e684ffc5d6616dc08fe28b7c02e31533..b182a672678864eb83b2ef42489b3d3aeff137ae 100644 (file)
@@ -301,7 +301,8 @@ namespace
   }
 
   //! Compute boundary presentation for faces of the shape.
-  static Handle(Graphic3d_ArrayOfSegments) fillFaceBoundaries (const TopoDS_Shape& theShape)
+  static Handle(Graphic3d_ArrayOfSegments) fillFaceBoundaries
+    (const TopoDS_Shape& theShape, const GeomAbs_Shape theMostAllowedEdgeClass)
   {
     // collection of all triangulation nodes on edges
     // for computing boundaries presentation
@@ -341,6 +342,16 @@ namespace
       }
 
       const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Key());
+      if (anEdgeIter.Value().Extent() > 1)
+      {
+        TopTools_ListIteratorOfListOfShape anIter2(anEdgeIter.Value());
+        anIter2.Next();
+        const TopoDS_Face& aFace2 = TopoDS::Face(anIter2.Value());
+        GeomAbs_Shape aShape = BRep_Tool::Continuity(anEdge, aFace, aFace2);
+        if (aShape > theMostAllowedEdgeClass)
+          continue;
+      }
+
       Handle(Poly_PolygonOnTriangulation) anEdgePoly = BRep_Tool::PolygonOnTriangulation (anEdge, aTriangulation, aTrsf);
       if (!anEdgePoly.IsNull()
         && anEdgePoly->Nodes().Length() >= 2)
@@ -384,6 +395,16 @@ namespace
       }
 
       const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Key());
+      if (anEdgeIter.Value().Extent() > 1)
+      {
+        TopTools_ListIteratorOfListOfShape anIter2(anEdgeIter.Value());
+        anIter2.Next();
+        const TopoDS_Face& aFace2 = TopoDS::Face(anIter2.Value());
+        GeomAbs_Shape aShape = BRep_Tool::Continuity(anEdge, aFace, aFace2);
+        if (aShape > theMostAllowedEdgeClass)
+          continue;
+      }
+
       Handle(Poly_PolygonOnTriangulation) anEdgePoly = BRep_Tool::PolygonOnTriangulation (anEdge, aTriangulation, aTrsf);
       if (anEdgePoly.IsNull()
        || anEdgePoly->Nodes().Length () < 2)
@@ -501,11 +522,12 @@ void StdPrs_ShadedShape::ExploreSolids (const TopoDS_Shape&    theShape,
 void StdPrs_ShadedShape::Add (const Handle(Prs3d_Presentation)& thePrs,
                               const TopoDS_Shape&               theShape,
                               const Handle(Prs3d_Drawer)&       theDrawer,
-                              const StdPrs_Volume               theVolume)
+                              const StdPrs_Volume               theVolume,
+                              const GeomAbs_Shape               theMostAllowedEdgeClass)
 {
   gp_Pnt2d aDummy;
   StdPrs_ShadedShape::Add (thePrs, theShape, theDrawer,
-                           Standard_False, aDummy, aDummy, aDummy, theVolume);
+                           Standard_False, aDummy, aDummy, aDummy, theVolume, theMostAllowedEdgeClass);
 }
 
 // =======================================================================
@@ -519,7 +541,8 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
                               const gp_Pnt2d&                    theUVOrigin,
                               const gp_Pnt2d&                    theUVRepeat,
                               const gp_Pnt2d&                    theUVScale,
-                              const StdPrs_Volume                theVolume)
+                              const StdPrs_Volume                theVolume,
+                              const GeomAbs_Shape                theMostAllowedEdgeClass)
 {
   if (theShape.IsNull())
   {
@@ -578,7 +601,7 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
 
   if (theDrawer->FaceBoundaryDraw())
   {
-    Handle(Graphic3d_ArrayOfSegments) aBndSegments = fillFaceBoundaries (theShape);
+    Handle(Graphic3d_ArrayOfSegments) aBndSegments = fillFaceBoundaries (theShape, theMostAllowedEdgeClass);
     if (!aBndSegments.IsNull())
     {
       Handle(Graphic3d_AspectLine3d) aBoundaryAspect = theDrawer->FaceBoundaryAspect()->Aspect();
@@ -606,9 +629,10 @@ Handle(Graphic3d_ArrayOfTriangles) StdPrs_ShadedShape::FillTriangles (const Topo
 // function : FillFaceBoundaries
 // purpose  :
 // =======================================================================
-Handle(Graphic3d_ArrayOfSegments) StdPrs_ShadedShape::FillFaceBoundaries (const TopoDS_Shape& theShape)
+Handle(Graphic3d_ArrayOfSegments) StdPrs_ShadedShape::FillFaceBoundaries (const TopoDS_Shape& theShape,
+                                                                          const GeomAbs_Shape theMostAllowedEdgeClass)
 {
-  return fillFaceBoundaries (theShape);
+  return fillFaceBoundaries (theShape, theMostAllowedEdgeClass);
 }
 
 // =======================================================================
index cbb2a7df75b91d3d2181620c6035cd1ff2671407..dc5bdcc12f8f78a9c753720014c2d365973e25dc 100644 (file)
@@ -25,6 +25,7 @@
 #include <Prs3d_Drawer.hxx>
 #include <StdPrs_Volume.hxx>
 #include <Standard_Boolean.hxx>
+#include <GeomAbs_Shape.hxx>
 
 class Graphic3d_ArrayOfSegments;
 class Graphic3d_ArrayOfTriangles;
@@ -43,13 +44,27 @@ public:
   //! @param theVolumeType defines the way how to interpret input shapes - as Closed volumes (to activate back-face
   //! culling and capping plane algorithms), as Open volumes (shells or solids with holes)
   //! or to perform Autodetection (would split input shape into two groups)
-  Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation, const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer, const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
+  //! @param theMostAllowedEdgeClass the most edge continuity class to be included to result (edges with more continuity should be ignored)
+  Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation,
+                                   const TopoDS_Shape& theShape,
+                                   const Handle(Prs3d_Drawer)& theDrawer,
+                                   const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection,
+                                   const GeomAbs_Shape theMostAllowedEdgeClass = GeomAbs_CN);
   
   //! Shades <theShape> with texture coordinates.
   //! @param theVolumeType defines the way how to interpret input shapes - as Closed volumes (to activate back-face
   //! culling and capping plane algorithms), as Open volumes (shells or solids with holes)
   //! or to perform Autodetection (would split input shape into two groups)
-  Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation, const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer, const Standard_Boolean theHasTexels, const gp_Pnt2d& theUVOrigin, const gp_Pnt2d& theUVRepeat, const gp_Pnt2d& theUVScale, const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
+  //! @param theMostAllowedEdgeClass the most edge continuity class to be included to result (edges with more continuity should be ignored)
+  Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation,
+                                   const TopoDS_Shape& theShape,
+                                   const Handle(Prs3d_Drawer)& theDrawer,
+                                   const Standard_Boolean theHasTexels,
+                                   const gp_Pnt2d& theUVOrigin,
+                                   const gp_Pnt2d& theUVRepeat,
+                                   const gp_Pnt2d& theUVScale,
+                                   const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection,
+                                   const GeomAbs_Shape theMostAllowedEdgeClass = GeomAbs_CN);
   
   //! Searches closed and unclosed subshapes in shape structure and puts them
   //! into two compounds for separate processing of closed and unclosed sub-shapes
@@ -90,8 +105,9 @@ public:
 
   //! Define primitive array of boundary segments for specified shape.
   //! @param theShape segments array or NULL if specified face does not have computed triangulation
-  Standard_EXPORT static Handle(Graphic3d_ArrayOfSegments) FillFaceBoundaries (const TopoDS_Shape& theShape);
-
+  //! @param theMostAllowedEdgeClass the most edge continuity class to be included to result (edges with more continuity should be ignored)
+  Standard_EXPORT static Handle(Graphic3d_ArrayOfSegments) FillFaceBoundaries
+    (const TopoDS_Shape& theShape, const GeomAbs_Shape theMostAllowedEdgeClass = GeomAbs_CN);
 };
 
 #endif // _StdPrs_ShadedShape_HeaderFile
index 14f40829130155af9023d4edabb794186f815ff0..92af723a20693390537262e2a907d3d3cbbb7059 100644 (file)
@@ -1619,6 +1619,72 @@ static int VSetInteriorStyle (Draw_Interpretor& theDI,
   return 0;
 }
 
+//==============================================================================
+//function : VSetMostCont
+//purpose  : sets the most continuity class of edges in presentation
+//==============================================================================
+static int VSetMostCont(Draw_Interpretor& theDI,
+  Standard_Integer  theArgNb,
+  const char**      theArgVec)
+{
+  const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+  ViewerTest_AutoUpdater anUpdateTool(aCtx, ViewerTest::CurrentView());
+  if (aCtx.IsNull())
+  {
+    std::cerr << "Error: no active view!\n";
+    return 1;
+  }
+
+  if (theArgNb != 3)
+  {
+    std::cout << "Error: wrong number of arguments! See usage:\n";
+    theDI.PrintHelp(theArgVec[0]);
+    return 1;
+  }
+
+  TCollection_AsciiString aName = theArgVec[1];
+  TCollection_AsciiString aClassArg = theArgVec[2];
+  aClassArg.LowerCase();
+
+  GeomAbs_Shape aClass = GeomAbs_CN;
+  if (aClassArg == "c0")
+    aClass = GeomAbs_C0;
+  else if (aClassArg == "c1")
+    aClass = GeomAbs_C1;
+  else if (aClassArg == "c2")
+    aClass = GeomAbs_C2;
+  else if (aClassArg == "c3")
+    aClass = GeomAbs_C3;
+  else if (aClassArg == "cn")
+    aClass = GeomAbs_CN;
+  else
+  {
+    std::cout << "Error: incorrect class! See usage:\n";
+    theDI.PrintHelp(theArgVec[0]);
+    return 1;
+  }
+
+  if (!aName.IsEmpty()
+    && !GetMapOfAIS().IsBound2(aName))
+  {
+    std::cout << "Error: object " << aName << " is not displayed!\n";
+    return 1;
+  }
+
+  for (ViewTest_PrsIter anIter(aName); anIter.More(); anIter.Next())
+  {
+    const Handle(AIS_Shape)& aShape = Handle(AIS_Shape)::DownCast(anIter.Current());
+    if (!aShape.IsNull())
+    {
+      aShape->SetMostContinuityClass(aClass);
+      aCtx->RecomputePrsOnly(aShape, Standard_False, Standard_True);
+    }
+  }
+  return 0;
+}
+
+
+
 //! Auxiliary structure for VAspects
 struct ViewerTest_AspectsChangeSet
 {
@@ -6074,6 +6140,12 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
       "\n\t\t: Where style is: 0 = EMPTY, 1 = HOLLOW, 2 = HATCH, 3 = SOLID, 4 = HIDDENLINE.",
                  __FILE__,VSetInteriorStyle,group);
 
+  theCommands.Add("vsetmostcont",
+    "vsetmostcont : ObjectName class"
+    "- sets the most continuity class of edges in presentation",
+    "\n\t\t: Where class is c0, c1, c2, c3, cn"
+    __FILE__, VSetMostCont, group);
+
   theCommands.Add("vsensdis",
       "vsensdis : Display active entities (sensitive entities of one of the standard types corresponding to active selection modes)."
       "\n\t\t: Standard entity types are those defined in Select3D package:"
diff --git a/tests/bugs/vis/bug29787 b/tests/bugs/vis/bug29787
new file mode 100644 (file)
index 0000000..bbfe712
--- /dev/null
@@ -0,0 +1,25 @@
+puts "========"
+puts "0029787: Avoid in presentation edges of certain continuity class"
+puts "========"
+puts ""
+
+pload MODELING VISUALIZATION
+
+vclear
+vinit View1
+vsetcolorbg 255 255 255
+
+psphere sph1 1.0
+psphere sph2 1.0
+psphere sph3 1.0
+
+ttranslate sph2 4.0 0.0 0.0
+ttranslate sph3 8.0 0.0 0.0
+
+vdisplay -dispMode 0 sph1
+vdisplay -dispMode 1 sph2
+vshowfaceboundary sph2 1 255 0 0
+vdisplay -dispMode 1 sph3
+vshowfaceboundary sph3 1 255 0 0
+vsetmostcont sph3 c2
+vfit