0031733: Visualization, Prs3d_ToolQuadric - create indexed arrays
authormzernova <mzernova@opencascade.com>
Mon, 31 Aug 2020 14:28:25 +0000 (17:28 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 4 Sep 2020 15:14:23 +0000 (18:14 +0300)
Prs3d_ToolQuadric has been modified to return an indexed triangulation.
Added methods Prs3d_ToolQuadric::CreateTriangulation() and Prs3d_ToolQuadric::CreateTriangulation()
as more straightforward API returning generated triangulation.
Added missing const to constant methods.

Confusing method Prs3d_ToolQuadric::FillArray() filling both
Graphic3d_ArrayOfTriangles and Poly_Triangulation at once has been marked deprecated.

V3d_Trihedron, AIS_ViewCube and AIS_Manipulator
now set Closed flag to groups with shaded sphere and arrows.

14 files changed:
src/AIS/AIS_Manipulator.cxx
src/AIS/AIS_ViewCube.cxx
src/Prs3d/Prs3d_Arrow.cxx
src/Prs3d/Prs3d_ToolCylinder.cxx
src/Prs3d/Prs3d_ToolCylinder.hxx
src/Prs3d/Prs3d_ToolDisk.cxx
src/Prs3d/Prs3d_ToolDisk.hxx
src/Prs3d/Prs3d_ToolQuadric.cxx
src/Prs3d/Prs3d_ToolQuadric.hxx
src/Prs3d/Prs3d_ToolSector.cxx
src/Prs3d/Prs3d_ToolSector.hxx
src/Prs3d/Prs3d_ToolSphere.cxx
src/Prs3d/Prs3d_ToolSphere.hxx
src/V3d/V3d_Trihedron.cxx

index c3e89ec..45e5ca4 100644 (file)
@@ -1212,7 +1212,8 @@ void AIS_Manipulator::Disk::Init (const Standard_ShortReal theInnerRadius,
   gp_Ax3 aSystem (myPosition.Location(), myPosition.Direction());
   gp_Trsf aTrsf;
   aTrsf.SetTransformation (aSystem, gp_Ax3());
-  aTool.FillArray (myArray, myTriangulation, aTrsf);
+  myArray = aTool.CreateTriangulation (aTrsf);
+  myTriangulation = aTool.CreatePolyTriangulation (aTrsf);
 }
 
 //=======================================================================
@@ -1231,7 +1232,8 @@ void AIS_Manipulator::Sphere::Init (const Standard_ShortReal theRadius,
   Prs3d_ToolSphere aTool (theRadius, theSlicesNb, theStacksNb);
   gp_Trsf aTrsf;
   aTrsf.SetTranslation (gp_Vec(gp::Origin(), thePosition));
-  aTool.FillArray (myArray, myTriangulation, aTrsf);
+  myArray = aTool.CreateTriangulation (aTrsf);
+  myTriangulation = aTool.CreatePolyTriangulation (aTrsf);
 }
 
 //=======================================================================
@@ -1267,24 +1269,24 @@ void AIS_Manipulator::Cube::Init (const gp_Ax1& thePosition, const Standard_Shor
   addTriangle (1, aBottomLeft, aV3, aV4, -thePosition.Direction());
 
   // Front
-  addTriangle (2, aV3, aV4, aV5, aFront);
-  addTriangle (3, aV3, aV5, aTopRight, aFront);
+  addTriangle (2, aV3, aV5, aV4, -aFront);
+  addTriangle (3, aV3, aTopRight, aV5, -aFront);
 
   // Back
-  addTriangle (4, aBottomLeft, aV2, aV7, -aFront);
-  addTriangle (5, aBottomLeft, aV7, aV6, -aFront);
+  addTriangle (4, aBottomLeft, aV7, aV2, aFront);
+  addTriangle (5, aBottomLeft, aV6, aV7, aFront);
 
   // aTop
   addTriangle (6, aV7, aV6, aV5, thePosition.Direction());
   addTriangle (7, aTopRight, aV7, aV5, thePosition.Direction());
 
-  //Left
-  addTriangle (8, aV6, aV5, aV4, -aRight);
-  addTriangle (9, aBottomLeft, aV6, aV4, -aRight);
+  // Left
+  addTriangle (8, aV6, aV4, aV5, aRight);
+  addTriangle (9, aBottomLeft, aV4, aV6, aRight);
 
   // Right
-  addTriangle (10, aV3, aTopRight, aV7, aRight);
-  addTriangle (11, aV3, aV7, aV2, aRight);
+  addTriangle (10, aV3, aV7, aTopRight, -aRight);
+  addTriangle (11, aV3, aV2, aV7, -aRight);
 }
 
 //=======================================================================
@@ -1321,7 +1323,8 @@ void AIS_Manipulator::Sector::Init (const Standard_ShortReal theRadius,
   gp_Ax3 aSystem(thePosition.Location(), thePosition.Direction(), theXDirection);
   gp_Trsf aTrsf;
   aTrsf.SetTransformation(aSystem, gp_Ax3());
-  aTool.FillArray(myArray, myTriangulation, aTrsf);
+  myArray = aTool.CreateTriangulation (aTrsf);
+  myTriangulation = aTool.CreatePolyTriangulation (aTrsf);
 }
 
 //=======================================================================
@@ -1373,7 +1376,8 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
                                                myAxisRadius * 1.5,
                                                anArrowLength,
                                                myFacettesNumber);
-    myTranslatorGroup = thePrs->NewGroup ();
+    myTranslatorGroup = thePrs->NewGroup();
+    myTranslatorGroup->SetClosed (true);
     myTranslatorGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
     myTranslatorGroup->AddPrimitiveArray (myTriangleArray);
 
@@ -1397,7 +1401,8 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
     myCubePos = myReferenceAxis.Direction().XYZ() * (myLength + myIndent);
     myCube.Init (gp_Ax1 (myCubePos, myReferenceAxis.Direction()), myBoxSize);
 
-    myScalerGroup = thePrs->NewGroup ();
+    myScalerGroup = thePrs->NewGroup();
+    myScalerGroup->SetClosed (true);
     myScalerGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
     myScalerGroup->AddPrimitiveArray (myCube.Array());
 
index ff60577..bb95443 100644 (file)
@@ -598,6 +598,7 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
       }
 
       Handle(Graphic3d_Group) anAxisGroup = thePrs->NewGroup();
+      anAxisGroup->SetClosed (true);
       anAxisGroup->SetGroupPrimitivesAspect (aDatumAspect->ShadingAspect (aPart)->Aspect());
 
       const Standard_Real anArrowLength = 0.2 * anAxisSize;
@@ -620,6 +621,7 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
     // Display center
     {
       Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
+      aGroup->SetClosed (true);
       Handle(Prs3d_ShadingAspect) anAspectCen = new Prs3d_ShadingAspect();
       anAspectCen->SetColor (Quantity_NOC_WHITE);
       aGroup->SetGroupPrimitivesAspect (anAspectCen->Aspect());
index cedd23a..5294ec3 100644 (file)
@@ -138,7 +138,10 @@ Handle(Graphic3d_ArrayOfTriangles) Prs3d_Arrow::DrawShaded (const gp_Ax1&
     return Handle(Graphic3d_ArrayOfTriangles)();
   }
 
-  Handle(Graphic3d_ArrayOfTriangles) anArray = new Graphic3d_ArrayOfTriangles (aNbTris * 3, 0, Standard_True);
+  Standard_Integer aMaxVertexs = (aNbTrisTube > 0 ? Prs3d_ToolCylinder::VerticesNb (theNbFacettes, 1) : 0)
+                               + (aNbTrisCone > 0 ? Prs3d_ToolDisk    ::VerticesNb (theNbFacettes, 1)
+                                                  + Prs3d_ToolCylinder::VerticesNb (theNbFacettes, 1) : 0);
+  Handle(Graphic3d_ArrayOfTriangles) anArray = new Graphic3d_ArrayOfTriangles (aMaxVertexs, aNbTris * 3, Graphic3d_ArrayFlags_VertexNormal);
   if (aNbTrisTube != 0)
   {
     gp_Ax3  aSystem (theAxis.Location(), theAxis.Direction());
index a570e5f..83325c9 100644 (file)
@@ -41,7 +41,7 @@ Prs3d_ToolCylinder::Prs3d_ToolCylinder (const Standard_Real    theBottomRad,
 //function : Vertex
 //purpose  :
 //=======================================================================
-gp_Pnt Prs3d_ToolCylinder::Vertex (const Standard_Real theU, const Standard_Real theV)
+gp_Pnt Prs3d_ToolCylinder::Vertex (const Standard_Real theU, const Standard_Real theV) const
 {
   const Standard_Real aU      = theU * M_PI * 2.0;
   const Standard_Real aRadius = myBottomRadius + (myTopRadius - myBottomRadius) * theV;
@@ -51,10 +51,10 @@ gp_Pnt Prs3d_ToolCylinder::Vertex (const Standard_Real theU, const Standard_Real
 }
 
 //=======================================================================
-//function : Add
+//function : Normal
 //purpose  :
 //=======================================================================
-gp_Dir Prs3d_ToolCylinder::Normal (const Standard_Real theU, const Standard_Real /*theV*/)
+gp_Dir Prs3d_ToolCylinder::Normal (const Standard_Real theU, const Standard_Real ) const
 {
   const Standard_Real aU = theU * M_PI * 2.0;
   return gp_Dir (Cos (aU) * myHeight,
@@ -63,7 +63,7 @@ gp_Dir Prs3d_ToolCylinder::Normal (const Standard_Real theU, const Standard_Real
 }
 
 //=======================================================================
-//function : Perform
+//function : Create
 //purpose  :
 //=======================================================================
 Handle(Graphic3d_ArrayOfTriangles) Prs3d_ToolCylinder::Create (const Standard_Real    theBottomRad,
index fecfba1..93ce58c 100644 (file)
@@ -42,10 +42,10 @@ public:
 protected:
 
   //! Computes vertex at given parameter location of the surface.
-  Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
+  Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) const Standard_OVERRIDE;
 
   //! Computes normal at given parameter location of the surface.
-  Standard_EXPORT virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
+  Standard_EXPORT virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) const Standard_OVERRIDE;
 
 protected:
 
index 5eec91b..6377d79 100644 (file)
@@ -40,7 +40,7 @@ Prs3d_ToolDisk::Prs3d_ToolDisk (const Standard_Real    theInnerRadius,
 //function : Vertex
 //purpose  :
 //=======================================================================
-gp_Pnt Prs3d_ToolDisk::Vertex (const Standard_Real theU, const Standard_Real theV)
+gp_Pnt Prs3d_ToolDisk::Vertex (const Standard_Real theU, const Standard_Real theV) const
 {
   const Standard_Real aU      = myStartAngle + theU * (myEndAngle - myStartAngle);
   const Standard_Real aRadius = myInnerRadius + (myOuterRadius - myInnerRadius) * theV;
@@ -50,7 +50,7 @@ gp_Pnt Prs3d_ToolDisk::Vertex (const Standard_Real theU, const Standard_Real the
 }
 
 //=======================================================================
-//function : Perform
+//function : Create
 //purpose  :
 //=======================================================================
 Handle(Graphic3d_ArrayOfTriangles) Prs3d_ToolDisk::Create (const Standard_Real    theInnerRadius,
index c722639..afaf8f6 100644 (file)
@@ -50,10 +50,13 @@ public:
 protected:
 
   //! Computes vertex at given parameter location of the surface.
-  Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
+  Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) const Standard_OVERRIDE;
 
   //! Computes normal at given parameter location of the surface.
-  virtual gp_Dir Normal (const Standard_Real , const Standard_Real ) Standard_OVERRIDE { return gp_Dir (0.0, 0.0, -1.0); }
+  virtual gp_Dir Normal (const Standard_Real , const Standard_Real ) const Standard_OVERRIDE
+  {
+    return gp_Dir (0.0, 0.0, -1.0);
+  }
 
 protected:
 
index 5af6cfd..e74c500 100644 (file)
 #include <TColgp_Array1OfPnt.hxx>
 
 //=======================================================================
-//function : fillArrays
+//function : FIllArray
 //purpose  :
 //=======================================================================
-void Prs3d_ToolQuadric::fillArrays (const gp_Trsf& theTrsf, TColgp_Array1OfPnt& theArray, NCollection_Array1<gp_Dir>& theNormals)
+void Prs3d_ToolQuadric::FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray,
+                                   const gp_Trsf& theTrsf) const
 {
-  Standard_ShortReal aStepU = 1.0f / mySlicesNb;
-  Standard_ShortReal aStepV = 1.0f / myStacksNb;
+  if (theArray.IsNull())
+  {
+    theArray = new Graphic3d_ArrayOfTriangles (VerticesNb(), TrianglesNb() * 3, Graphic3d_ArrayFlags_VertexNormal);
+  }
 
-  for (Standard_Integer aU = 0; aU <= mySlicesNb; aU++)
+  const Standard_Real aStepU = 1.0f / mySlicesNb;
+  const Standard_Real aStepV = 1.0f / myStacksNb;
+  if (theArray->EdgeNumberAllocated() > 0)
   {
-    const Standard_Real aParamU = aU * aStepU;
-    for (Standard_Integer aV = 0; aV <= myStacksNb; aV++)
+    // indexed array
+    for (Standard_Integer aU = 0; aU <= mySlicesNb; ++aU)
     {
-      const Standard_ShortReal aParamV = aV * aStepV;
-      const Standard_Integer   aVertId = aU * (myStacksNb + 1) + aV + 1;
-      gp_Pnt aVertex = Vertex(aParamU, aParamV);
-      gp_Dir aNormal = Normal(aParamU, aParamV);
-
-      aVertex.Transform (theTrsf);
-      aNormal.Transform (theTrsf);
+      const Standard_Real aParamU = aU * aStepU;
+      for (Standard_Integer aV = 0; aV <= myStacksNb; ++aV)
+      {
+        const Standard_Real aParamV = aV * aStepV;
+        const gp_Pnt aVertex = Vertex (aParamU, aParamV).Transformed (theTrsf);
+        const gp_Dir aNormal = Normal (aParamU, aParamV).Transformed (theTrsf);
+        theArray->AddVertex (aVertex, aNormal);
 
-      theArray.SetValue (aVertId, aVertex);
-      theNormals.SetValue (aVertId, aNormal);
+        if (aU != 0 && aV != 0)
+        {
+          const int aVertId = theArray->VertexNumber();
+          theArray->AddTriangleEdges (aVertId, aVertId - myStacksNb - 2, aVertId - 1);
+          theArray->AddTriangleEdges (aVertId - myStacksNb - 2, aVertId, aVertId - myStacksNb - 1);
+        }
+      }
+    }
+  }
+  else
+  {
+    // non-indexed array
+    for (Standard_Integer aU = 0; aU < mySlicesNb; ++aU)
+    {
+      const Standard_Real aParamU = aU * aStepU;
+      for (Standard_Integer aV = 0; aV < myStacksNb; ++aV)
+      {
+        const Standard_Real aParamV = aV * aStepV;
+        theArray->AddVertex (Vertex (aParamU, aParamV).Transformed (theTrsf),
+                             Normal (aParamU, aParamV).Transformed (theTrsf));
+        theArray->AddVertex (Vertex (aParamU + aStepU, aParamV).Transformed (theTrsf),
+                             Normal (aParamU + aStepU, aParamV).Transformed (theTrsf));
+        theArray->AddVertex (Vertex (aParamU + aStepU, aParamV + aStepV).Transformed (theTrsf),
+                             Normal (aParamU + aStepU, aParamV + aStepV).Transformed (theTrsf));
+        theArray->AddVertex (Vertex (aParamU + aStepU, aParamV + aStepV).Transformed (theTrsf),
+                             Normal (aParamU + aStepU, aParamV + aStepV).Transformed (theTrsf));
+        theArray->AddVertex (Vertex (aParamU, aParamV + aStepV).Transformed (theTrsf),
+                             Normal (aParamU, aParamV + aStepV).Transformed (theTrsf));
+        theArray->AddVertex (Vertex (aParamU, aParamV).Transformed (theTrsf),
+                             Normal (aParamU, aParamV).Transformed (theTrsf));
+      }
     }
   }
 }
 
 //=======================================================================
-//function : FIllArray
+//function : CreateTriangulation
 //purpose  :
 //=======================================================================
-void Prs3d_ToolQuadric::FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray, const gp_Trsf& theTrsf)
+Handle(Graphic3d_ArrayOfTriangles) Prs3d_ToolQuadric::CreateTriangulation (const gp_Trsf& theTrsf) const
 {
-  const Standard_Integer aTrianglesNb = TrianglesNb();
-  if (theArray.IsNull())
-  {
-    theArray = new Graphic3d_ArrayOfTriangles (aTrianglesNb * 3, 0, Standard_True);
-  }
-
-  Poly_Array1OfTriangle aPolyTriangles (1, aTrianglesNb);
-  TColgp_Array1OfPnt anArray (1, aTrianglesNb * 3);
-  NCollection_Array1<gp_Dir> aNormals (1, aTrianglesNb * 3);
-  fillArrays (theTrsf, anArray, aNormals);
-
-  // Fill primitives
-  for (Standard_Integer aU = 0; aU < mySlicesNb; ++aU)
-  {
-    for (Standard_Integer aV = 1; aV <= myStacksNb; ++aV)
-    {
-      theArray->AddVertex (anArray.Value (aU * (myStacksNb + 1) + aV), aNormals.Value (aU * (myStacksNb + 1) + aV));
-      theArray->AddVertex (anArray.Value ((aU + 1) * (myStacksNb + 1) + aV), aNormals.Value ((aU + 1) * (myStacksNb + 1) + aV));
-      theArray->AddVertex (anArray.Value ((aU + 1) * (myStacksNb + 1) + (aV + 1)), aNormals.Value ((aU + 1) * (myStacksNb + 1) + (aV + 1)));
-      theArray->AddVertex (anArray.Value ((aU + 1) * (myStacksNb + 1) + (aV + 1)), aNormals.Value ((aU + 1) * (myStacksNb + 1) + (aV + 1)));
-      theArray->AddVertex (anArray.Value (aU * (myStacksNb + 1) + (aV + 1)), aNormals.Value (aU * (myStacksNb + 1) + (aV + 1)));
-      theArray->AddVertex (anArray.Value (aU * (myStacksNb + 1) + aV), aNormals.Value (aU * (myStacksNb + 1) + aV));
-    }
-  }
+  Handle(Graphic3d_ArrayOfTriangles) aTriangulation;
+  FillArray (aTriangulation, theTrsf);
+  return aTriangulation;
 }
 
 //=======================================================================
-//function : FillTriangulation
+//function : CreatePolyTriangulation
 //purpose  :
 //=======================================================================
-void Prs3d_ToolQuadric::FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray,
-                                   Handle(Poly_Triangulation)& theTriangulation,
-                                   const gp_Trsf& theTrsf)
+Handle(Poly_Triangulation) Prs3d_ToolQuadric::CreatePolyTriangulation (const gp_Trsf& theTrsf) const
 {
-  const Standard_Integer aTrianglesNb = TrianglesNb();
-  theArray = new Graphic3d_ArrayOfTriangles(aTrianglesNb * 3, 0, Standard_True);
+  Handle(Poly_Triangulation) aTriangulation = new Poly_Triangulation (VerticesNb(), TrianglesNb(), Standard_False);
+  TColgp_Array1OfPnt& aNodes = aTriangulation->ChangeNodes();
+  Poly_Array1OfTriangle& aTriangles = aTriangulation->ChangeTriangles();
 
-  Poly_Array1OfTriangle aPolyTriangles(1, aTrianglesNb);
-  TColgp_Array1OfPnt anArray(1, aTrianglesNb * 3);
-  NCollection_Array1<gp_Dir> aNormals(1, aTrianglesNb * 3);
-  fillArrays(theTrsf, anArray, aNormals);
+  Standard_ShortReal aStepU = 1.0f / mySlicesNb;
+  Standard_ShortReal aStepV = 1.0f / myStacksNb;
 
   // Fill triangles
-  for (Standard_Integer aU = 0, anIndex = 0; aU < mySlicesNb; ++aU)
+  for (Standard_Integer aU = 0, anIndex = 0; aU <= mySlicesNb; ++aU)
   {
-    for (Standard_Integer aV = 1; aV <= myStacksNb; ++aV)
+    const Standard_Real aParamU = aU * aStepU;
+    for (Standard_Integer aV = 0; aV <= myStacksNb; ++aV)
     {
-      theArray->AddVertex(anArray.Value(aU * (myStacksNb + 1) + aV), aNormals.Value(aU * (myStacksNb + 1) + aV));
-      theArray->AddVertex(anArray.Value((aU + 1) * (myStacksNb + 1) + aV), aNormals.Value((aU + 1) * (myStacksNb + 1) + aV));
-      theArray->AddVertex(anArray.Value((aU + 1) * (myStacksNb + 1) + (aV + 1)), aNormals.Value((aU + 1) * (myStacksNb + 1) + (aV + 1)));
-      theArray->AddVertex(anArray.Value((aU + 1) * (myStacksNb + 1) + (aV + 1)), aNormals.Value((aU + 1) * (myStacksNb + 1) + (aV + 1)));
-      theArray->AddVertex(anArray.Value(aU * (myStacksNb + 1) + (aV + 1)), aNormals.Value(aU * (myStacksNb + 1) + (aV + 1)));
-      theArray->AddVertex(anArray.Value(aU * (myStacksNb + 1) + aV), aNormals.Value(aU * (myStacksNb + 1) + aV));
+      const Standard_ShortReal aParamV = aV * aStepV;
+      const Standard_Integer   aVertId = aU * (myStacksNb + 1) + (aV + 1);
+      gp_Pnt aVertex = Vertex (aParamU, aParamV).Transformed (theTrsf);
 
-      aPolyTriangles.SetValue (++anIndex, Poly_Triangle(aU * (myStacksNb + 1) + aV,
-                               (aU + 1) * (myStacksNb + 1) + aV,
-                               (aU + 1) * (myStacksNb + 1) + (aV + 1)));
-      aPolyTriangles.SetValue (++anIndex, Poly_Triangle((aU + 1) * (myStacksNb + 1) + (aV + 1),
-                               aU * (myStacksNb + 1) + (aV + 1),
-                               aU * (myStacksNb + 1) + aV));
+      aNodes.SetValue (aVertId, aVertex);
+      if (aU != 0 && aV != 0)
+      {
+        aTriangles.SetValue (++anIndex, Poly_Triangle (aVertId, aVertId - myStacksNb - 2, aVertId - 1));
+        aTriangles.SetValue (++anIndex, Poly_Triangle (aVertId - myStacksNb - 2, aVertId, aVertId - myStacksNb - 1));
+      }
     }
   }
+  return aTriangulation;
+}
 
-  theTriangulation = new Poly_Triangulation (anArray, aPolyTriangles);
+//=======================================================================
+//function : FillArray
+//purpose  :
+//=======================================================================
+void Prs3d_ToolQuadric::FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray,
+                                   Handle(Poly_Triangulation)& theTriangulation,
+                                   const gp_Trsf& theTrsf) const
+{
+  theArray = CreateTriangulation (theTrsf);
+  theTriangulation = CreatePolyTriangulation (theTrsf);
 }
index c3493ed..eb0c9fe 100644 (file)
 class Prs3d_ToolQuadric
 {
 public:
-
   DEFINE_STANDARD_ALLOC
 
-  //! Generate primitives for 3D quadric surface and fill the given array. Optional transformation is applied.
-  Standard_EXPORT void FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray, const gp_Trsf& theTrsf);
-
-  //! Generate primitives for 3D quadric surface presentation and fill the given array and poly triangulation structure. Optional transformation is applied.
-  Standard_EXPORT void FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray, Handle(Poly_Triangulation)& theTriangulation, const gp_Trsf& theTrsf);
-
-  //! Number of triangles for presentation with the given params.
+  //! Return number of triangles for presentation with the given params.
   static Standard_Integer TrianglesNb (const Standard_Integer theSlicesNb,
                                        const Standard_Integer theStacksNb)
   {
     return theSlicesNb * theStacksNb * 2;
   }
 
-protected:
+  //! Return number of vertices for presentation with the given params.
+  static Standard_Integer VerticesNb (const Standard_Integer theSlicesNb,
+                                      const Standard_Integer theStacksNb,
+                                      const Standard_Boolean theIsIndexed = Standard_True)
+  {
+    return theIsIndexed
+      ? (theSlicesNb + 1) * (theStacksNb + 1)
+      : TrianglesNb (theSlicesNb, theStacksNb) * 3;
+  }
+
+public:
+
+  //! Generate primitives for 3D quadric surface presentation.
+  //! @param theTrsf [in] optional transformation to apply
+  //! @return generated triangulation
+  Standard_EXPORT Handle(Graphic3d_ArrayOfTriangles) CreateTriangulation (const gp_Trsf& theTrsf) const;
 
-  //! Method implements an algorithm to generate arrays of vertices and normals for 3D surface.
-  Standard_EXPORT void fillArrays (const gp_Trsf& theTrsf, TColgp_Array1OfPnt& theArray, NCollection_Array1<gp_Dir>& theNormals);
+  //! Generate primitives for 3D quadric surface presentation.
+  //! @param theTrsf [in] optional transformation to apply
+  //! @return generated triangulation
+  Standard_EXPORT Handle(Poly_Triangulation) CreatePolyTriangulation (const gp_Trsf& theTrsf) const;
 
-  //! Number of triangles in generated presentation.
+  //! Generate primitives for 3D quadric surface and fill the given array.
+  //! @param theArray [in][out] the array of vertices;
+  //!                           when NULL, function will create an indexed array;
+  //!                           when not NULL, triangles will be appended to the end of array
+  //!                           (will raise an exception if reserved array size is not large enough)
+  //! @param theTrsf [in] optional transformation to apply
+  Standard_EXPORT void FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray,
+                                  const gp_Trsf& theTrsf) const;
+
+public:
+
+  //! Generate primitives for 3D quadric surface presentation.
+  //! @param theArray [out] generated array of triangles
+  //! @param theTriangulation [out] generated triangulation
+  //! @param theTrsf [in] optional transformation to apply
+  Standard_DEPRECATED("Deprecated method, CreateTriangulation() and CreatePolyTriangulation() should be used instead")
+  Standard_EXPORT void FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray,
+                                  Handle(Poly_Triangulation)& theTriangulation,
+                                  const gp_Trsf& theTrsf) const;
+
+protected:
+
+  //! Return number of triangles in generated presentation.
   Standard_Integer TrianglesNb() const
   {
     return mySlicesNb * myStacksNb * 2;
   }
 
+  //! Return number of vertices in generated presentation.
+  Standard_Integer VerticesNb (const Standard_Boolean theIsIndexed = Standard_True) const
+  {
+    return theIsIndexed
+         ? (mySlicesNb + 1) * (myStacksNb + 1)
+         : TrianglesNb() * 3;
+  }
+
   //! Redefine this method to generate vertex at given parameters.
-  virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) = 0;
+  virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) const = 0;
 
   //! Redefine this method to generate normal at given parameters.
-  virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) = 0;
+  virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) const = 0;
 
 protected:
 
index ce8330d..646a6b5 100644 (file)
@@ -36,7 +36,7 @@ Prs3d_ToolSector::Prs3d_ToolSector (const Standard_Real    theRadius,
 //function : Vertex
 //purpose  :
 //=======================================================================
-gp_Pnt Prs3d_ToolSector::Vertex (const Standard_Real theU, const Standard_Real theV)
+gp_Pnt Prs3d_ToolSector::Vertex (const Standard_Real theU, const Standard_Real theV) const
 {
   const Standard_Real aU      = theU * M_PI / 2.0;
   const Standard_Real aRadius = myRadius * theV;
@@ -46,16 +46,7 @@ gp_Pnt Prs3d_ToolSector::Vertex (const Standard_Real theU, const Standard_Real t
 }
 
 //=======================================================================
-//function : Add
-//purpose  :
-//=======================================================================
-gp_Dir Prs3d_ToolSector::Normal (const Standard_Real /*theU*/, const Standard_Real /*theV*/)
-{
-  return gp_Dir (0.0, 0.0, -1.0);
-}
-
-//=======================================================================
-//function : Perform
+//function : Create
 //purpose  :
 //=======================================================================
 Handle(Graphic3d_ArrayOfTriangles) Prs3d_ToolSector::Create (const Standard_Real    theRadius,
index 383de71..2f98c02 100644 (file)
@@ -37,10 +37,13 @@ public:
 protected:
 
   //! Computes vertex at given parameter location of the surface.
-  Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
+  Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) const Standard_OVERRIDE;
 
   //! Computes normal at given parameter location of the surface.
-  Standard_EXPORT virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
+  virtual gp_Dir Normal (const Standard_Real , const Standard_Real ) const Standard_OVERRIDE
+  {
+    return gp_Dir (0.0, 0.0, -1.0);
+  }
 
 protected:
 
index 973a71b..459f920 100644 (file)
@@ -36,7 +36,7 @@ Prs3d_ToolSphere::Prs3d_ToolSphere (const Standard_Real    theRadius,
 //function : Vertex
 //purpose  :
 //=======================================================================
-gp_Pnt Prs3d_ToolSphere::Vertex (const Standard_Real theU, const Standard_Real theV)
+gp_Pnt Prs3d_ToolSphere::Vertex (const Standard_Real theU, const Standard_Real theV) const
 {
   const Standard_Real aU = theU * M_PI * 2.0;
   const Standard_Real aV = theV * M_PI;
@@ -46,10 +46,10 @@ gp_Pnt Prs3d_ToolSphere::Vertex (const Standard_Real theU, const Standard_Real t
 }
 
 //=======================================================================
-//function : Add
+//function : Normal
 //purpose  :
 //=======================================================================
-gp_Dir Prs3d_ToolSphere::Normal (const Standard_Real theU, const Standard_Real theV)
+gp_Dir Prs3d_ToolSphere::Normal (const Standard_Real theU, const Standard_Real theV) const
 {
   const Standard_Real aU = theU * M_PI * 2.0;
   const Standard_Real aV = theV * M_PI;
@@ -59,7 +59,7 @@ gp_Dir Prs3d_ToolSphere::Normal (const Standard_Real theU, const Standard_Real t
 }
 
 //=======================================================================
-//function : Perform
+//function : Create
 //purpose  :
 //=======================================================================
 Handle(Graphic3d_ArrayOfTriangles) Prs3d_ToolSphere::Create (const Standard_Real    theRadius,
index ed893a7..59f39d0 100644 (file)
@@ -38,10 +38,10 @@ public:
 protected:
 
   //! Computes vertex at given parameter location of the surface.
-  Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
+  Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) const Standard_OVERRIDE;
 
   //! Computes normal at given parameter location of the surface.
-  Standard_EXPORT virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
+  Standard_EXPORT virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) const Standard_OVERRIDE;
 
 protected:
 
index 20bb067..6d28d63 100644 (file)
@@ -292,6 +292,7 @@ void V3d_Trihedron::compute()
   Standard_Integer aGroupIter = myStructure->Groups().Lower();
   {
     Handle(Graphic3d_Group) aSphereGroup = addGroup (myStructure, aGroupIter);
+    aSphereGroup->SetClosed (!myIsWireframe);
 
     // Display origin.
     if (myIsWireframe)
@@ -322,6 +323,7 @@ void V3d_Trihedron::compute()
     for (Standard_Integer anIter = 0; anIter < 3; ++anIter)
     {
       Handle(Graphic3d_Group) anAxisGroup = addGroup (myStructure, aGroupIter);
+      anAxisGroup->SetClosed (!myIsWireframe);
       if (myIsWireframe)
       {
         // create a tube