]> OCCT Git - occt-copy.git/commitdiff
0028010: Visualization, Prs3d_Arrow - add Shading presentation builder
authorisk <isk@opencascade.com>
Fri, 14 Oct 2016 06:17:36 +0000 (09:17 +0300)
committerapn <apn@opencascade.com>
Thu, 3 Nov 2016 11:15:55 +0000 (14:15 +0300)
StdPrs_ToolCylinder, StdPrs_ToolDisk, StdPrs_ToolQuadric and StdPrs_ToolSphere
have been moved from StdPrs package to Prs3d.

23 files changed:
src/AIS/AIS_Manipulator.cxx
src/AIS/AIS_Manipulator.hxx
src/Prs3d/FILES
src/Prs3d/Prs3d_Arrow.cxx
src/Prs3d/Prs3d_Arrow.hxx
src/Prs3d/Prs3d_ToolCylinder.cxx [new file with mode: 0644]
src/Prs3d/Prs3d_ToolCylinder.hxx [new file with mode: 0644]
src/Prs3d/Prs3d_ToolDisk.cxx [new file with mode: 0644]
src/Prs3d/Prs3d_ToolDisk.hxx [new file with mode: 0644]
src/Prs3d/Prs3d_ToolQuadric.cxx [new file with mode: 0644]
src/Prs3d/Prs3d_ToolQuadric.hxx [new file with mode: 0644]
src/Prs3d/Prs3d_ToolSphere.cxx [new file with mode: 0644]
src/Prs3d/Prs3d_ToolSphere.hxx [new file with mode: 0644]
src/StdPrs/FILES
src/StdPrs/StdPrs_ToolCylinder.cxx [deleted file]
src/StdPrs/StdPrs_ToolCylinder.hxx [deleted file]
src/StdPrs/StdPrs_ToolDisk.cxx [deleted file]
src/StdPrs/StdPrs_ToolDisk.hxx [deleted file]
src/StdPrs/StdPrs_ToolQuadric.cxx [deleted file]
src/StdPrs/StdPrs_ToolQuadric.hxx [deleted file]
src/StdPrs/StdPrs_ToolSphere.cxx [deleted file]
src/StdPrs/StdPrs_ToolSphere.hxx [deleted file]
src/V3d/V3d_Trihedron.cxx

index 0d4afa71523496147bd7e9708f080f18b211ef69..ff0746caf3678131ac496f12dd1f0db38ad70325 100644 (file)
 #include <Geom_Line.hxx>
 #include <Geom_Plane.hxx>
 #include <Geom_Transformation.hxx>
+#include <Prs3d_Arrow.hxx>
 #include <Prs3d_Root.hxx>
 #include <Prs3d_ShadingAspect.hxx>
+#include <Prs3d_ToolDisk.hxx>
+#include <Prs3d_ToolSphere.hxx>
 #include <Select3D_SensitiveCircle.hxx>
 #include <Select3D_SensitivePoint.hxx>
 #include <Select3D_SensitiveSegment.hxx>
 #include <Select3D_SensitiveTriangulation.hxx>
+#include <Select3D_SensitivePrimitiveArray.hxx>
 #include <SelectMgr_SequenceOfOwner.hxx>
-#include <StdPrs_ToolDisk.hxx>
-#include <StdPrs_ToolCylinder.hxx>
-#include <StdPrs_ToolSphere.hxx>
 #include <TColgp_Array1OfPnt.hxx>
 #include <V3d_View.hxx>
 
@@ -925,7 +926,7 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
   {
     anOwner = new SelectMgr_EntityOwner (this, 5);
   }
-  Handle(Select3D_SensitiveTriangulation) aTri;
+
   if (aMode == AIS_MM_Translation || aMode == AIS_MM_None)
   {
     for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
@@ -939,12 +940,10 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
       Handle(Select3D_SensitiveSegment) aLine = new Select3D_SensitiveSegment (anOwner, gp::Origin(), anAxis.TranslatorTipPosition());
       aLine->SetSensitivityFactor (15);
       theSelection->Add (aLine);
+
       // enlarge sensitivity by triangulation
-      aTri = new Select3D_SensitiveTriangulation (anOwner, anAxis.TranslatorCylinder().Triangulation(), TopLoc_Location(), Standard_True);
-      theSelection->Add (aTri);
-      aTri = new Select3D_SensitiveTriangulation (anOwner, anAxis.TranslatorArrow().Triangulation(), TopLoc_Location(), Standard_True);
-      theSelection->Add (aTri);
-      aTri = new Select3D_SensitiveTriangulation (anOwner, anAxis.TranslatorArrowBottom().Triangulation(), TopLoc_Location(), Standard_True);
+      Handle(Select3D_SensitivePrimitiveArray) aTri = new Select3D_SensitivePrimitiveArray (anOwner);
+      aTri->InitTriangulation (anAxis.TriangleArray()->Attributes(), anAxis.TriangleArray()->Indices(), TopLoc_Location());
       theSelection->Add (aTri);
     }
   }
@@ -964,7 +963,7 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
       aCircle->SetSensitivityFactor (15);
       theSelection->Add (aCircle);
       // enlarge sensitivity by triangulation
-      aTri = new Select3D_SensitiveTriangulation (anOwner, myAxes[anIt].RotatorDisk().Triangulation(), TopLoc_Location(), Standard_True);
+      Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation (anOwner, myAxes[anIt].RotatorDisk().Triangulation(), TopLoc_Location(), Standard_True);
       theSelection->Add (aTri);
     }
   }
@@ -982,35 +981,12 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
       aPnt->SetSensitivityFactor (15);
       theSelection->Add (aPnt);
       // enlarge sensitivity by triangulation
-      aTri = new Select3D_SensitiveTriangulation (anOwner, myAxes[anIt].ScalerCube().Triangulation(), TopLoc_Location(), Standard_True);
+      Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation (anOwner, myAxes[anIt].ScalerCube().Triangulation(), TopLoc_Location(), Standard_True);
       theSelection->Add (aTri);
     }
   }
 }
 
-//=======================================================================
-//class    : Cylinder
-//function : Init
-//purpose  : 
-//=======================================================================
-void AIS_Manipulator::Cylinder::Init (const Standard_ShortReal theBotRad, const Standard_ShortReal theTopRad,
-                                      const Standard_ShortReal theHeight,
-                                      const Standard_Integer theSlicesNb, const Standard_Integer theStacksNb,
-                                      const gp_Ax1& thePosition)
-{
-  myPosition = thePosition;
-  myBottomRad = theBotRad;
-  myTopRad = theTopRad;
-  myHeight = theHeight;
-
-  StdPrs_ToolCylinder aTool (myBottomRad, myTopRad, myHeight, theSlicesNb, theStacksNb);
-  gp_Ax3 aSystem (myPosition.Location(), myPosition.Direction());
-  gp_Trsf aTrsf;
-  aTrsf.SetTransformation (aSystem, gp_Ax3());
-
-  aTool.FillArray (myArray, myTriangulation, aTrsf);
-}
-
 //=======================================================================
 //class    : Disk
 //function : Init
@@ -1026,7 +1002,7 @@ void AIS_Manipulator::Disk::Init (const Standard_ShortReal theInnerRadius,
   myInnerRad = theInnerRadius;
   myOuterRad = theOuterRadius;
 
-  StdPrs_ToolDisk aTool (theInnerRadius, theOuterRadius, theSlicesNb, theStacksNb);
+  Prs3d_ToolDisk aTool (theInnerRadius, theOuterRadius, theSlicesNb, theStacksNb);
   gp_Ax3 aSystem (myPosition.Location(), myPosition.Direction());
   gp_Trsf aTrsf;
   aTrsf.SetTransformation (aSystem, gp_Ax3());
@@ -1046,7 +1022,7 @@ void AIS_Manipulator::Sphere::Init (const Standard_ShortReal theRadius,
   myPosition = thePosition;
   myRadius = theRadius;
 
-  StdPrs_ToolSphere aTool (theRadius, theSlicesNb, theStacksNb);
+  Prs3d_ToolSphere aTool (theRadius, theSlicesNb, theStacksNb);
   gp_Trsf aTrsf;
   aTrsf.SetTranslation (gp_Vec(gp::Origin(), thePosition));
   aTool.FillArray (myArray, myTriangulation, aTrsf);
@@ -1153,44 +1129,39 @@ AIS_Manipulator::Axis::Axis (const gp_Ax1& theAxis,
 //=======================================================================
 //class    : Axis
 //function : Compute
-//purpose  : 
+//purpose  :
 //=======================================================================
-void AIS_Manipulator::Axis::Compute (const Handle_PrsMgr_PresentationManager3d& thePrsMgr,
+
+void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
                                      const Handle(Prs3d_Presentation)& thePrs,
                                      const Handle(Prs3d_ShadingAspect)& theAspect)
 {
-  Handle(Graphic3d_Group) aGroup;
-
   if (myHasTranslation)
   {
-    const Standard_ShortReal anArrowLength = 0.25f * myLength;
-    const Standard_ShortReal aCylinderLength = myLength - anArrowLength;
-
-    myCylinder.Init (myAxisRadius, myAxisRadius, aCylinderLength, myFacettesNumber, 2, gp_Ax1 (gp::Origin(), myReferenceAxis.Direction()));
-
-    gp_Pnt anArrowBottom (0.0, 0.0, 0.0);
-    anArrowBottom.Translate (myReferenceAxis.Direction().XYZ() * aCylinderLength);
-
-    myArrow.Init (myAxisRadius * 1.5f, 0.0f, anArrowLength, myFacettesNumber, 2, gp_Ax1 (anArrowBottom, myReferenceAxis.Direction()));
-    myArrowBottom.Init (myAxisRadius, myAxisRadius * 1.5f, gp_Ax1 (anArrowBottom, myReferenceAxis.Direction()), myFacettesNumber);
-    myArrowTipPos = anArrowBottom;
-
+    const Standard_Real anArrowLength   = 0.25 * myLength;
+    const Standard_Real aCylinderLength = myLength - anArrowLength;
+    myArrowTipPos = gp_Pnt (0.0, 0.0, 0.0).Translated (myReferenceAxis.Direction().XYZ() * aCylinderLength);
+
+    myTriangleArray = Prs3d_Arrow::DrawShaded (gp_Ax1(gp::Origin(), myReferenceAxis.Direction()),
+                                               myAxisRadius,
+                                               myLength,
+                                               myAxisRadius * 1.5,
+                                               anArrowLength,
+                                               myFacettesNumber);
     myTranslatorGroup = Prs3d_Root::NewGroup (thePrs);
     myTranslatorGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
-    myTranslatorGroup->AddPrimitiveArray (myCylinder.Array());
-    myTranslatorGroup->AddPrimitiveArray (myArrow.Array());
-    myTranslatorGroup->AddPrimitiveArray (myArrowBottom.Array());
+    myTranslatorGroup->AddPrimitiveArray (myTriangleArray);
 
     if (myHighlightTranslator.IsNull())
     {
       myHighlightTranslator = new Prs3d_Presentation (thePrsMgr->StructureManager());
     }
-
-    myHighlightTranslator->Clear();
-    aGroup = Prs3d_Root::CurrentGroup (myHighlightTranslator);
-    aGroup->AddPrimitiveArray (myCylinder.Array());
-    aGroup->AddPrimitiveArray (myArrow.Array());
-    aGroup->AddPrimitiveArray (myArrowBottom.Array());
+    else
+    {
+      myHighlightTranslator->Clear();
+    }
+    Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightTranslator);
+    aGroup->AddPrimitiveArray (myTriangleArray);
   }
 
   if (myHasScaling)
@@ -1206,9 +1177,11 @@ void AIS_Manipulator::Axis::Compute (const Handle_PrsMgr_PresentationManager3d&
     {
       myHighlightScaler = new Prs3d_Presentation (thePrsMgr->StructureManager());
     }
-
-    myHighlightScaler->Clear();
-    aGroup = Prs3d_Root::CurrentGroup (myHighlightScaler);
+    else
+    {
+      myHighlightScaler->Clear();
+    }
+    Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightScaler);
     aGroup->AddPrimitiveArray (myCube.Array());
   }
 
@@ -1224,9 +1197,11 @@ void AIS_Manipulator::Axis::Compute (const Handle_PrsMgr_PresentationManager3d&
     {
       myHighlightRotator = new Prs3d_Presentation (thePrsMgr->StructureManager());
     }
-
-    myHighlightRotator->Clear();
-    aGroup = Prs3d_Root::CurrentGroup (myHighlightRotator);
+    else
+    {
+      myHighlightRotator->Clear();
+    }
+    Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightRotator);
     Prs3d_Root::CurrentGroup (myHighlightRotator)->AddPrimitiveArray (myCircle.Array());
   }
 }
index 13588bafc0b942f5ccd0e3529a8cc1e915cc184a..6700c401c6711b3fcf561777c58d44e5a85564c0 100644 (file)
@@ -375,32 +375,6 @@ protected: //! @name Auxilliary classes to fill presentation with proper primiti
     Handle(Graphic3d_ArrayOfTriangles) myArray;
   };
 
-  class Cylinder : public Quadric
-  {
-  public:
-
-    Cylinder()
-    : Quadric(),
-      myBottomRad(1.0f),
-      myTopRad(1.0f),
-      myHeight(1.0f)
-    { }
-
-    virtual ~Cylinder() {}
-
-    void Init (const Standard_ShortReal theBotRad, const Standard_ShortReal theTopRad,
-               const Standard_ShortReal theHeight,
-               const Standard_Integer theSlicesNb, const Standard_Integer theStacksNb,
-               const gp_Ax1& thePosition);
-
-  protected:
-
-    gp_Ax1 myPosition;
-    Standard_ShortReal myBottomRad;
-    Standard_ShortReal myTopRad;
-    Standard_ShortReal myHeight;
-  };
-
   class Disk : public Quadric
   {
   public:
@@ -482,7 +456,7 @@ protected: //! @name Auxilliary classes to fill presentation with proper primiti
           const Quantity_Color& theColor     = Quantity_Color(),
           const Standard_ShortReal theLength = 10.0f);
 
-    void Compute (const Handle_PrsMgr_PresentationManager3d& thePrsMgr,
+    void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
                   const Handle(Prs3d_Presentation)& thePrs,
                   const Handle(Prs3d_ShadingAspect)& theAspect);
 
@@ -560,6 +534,8 @@ protected: //! @name Auxilliary classes to fill presentation with proper primiti
 
     const Handle(Graphic3d_Group)& ScalerGroup() const { return myScalerGroup; }
 
+    const Handle(Graphic3d_ArrayOfTriangles)& TriangleArray() const { return myTriangleArray; }
+
     void SetIndent (const Standard_ShortReal theValue) { myIndent = theValue; }
 
     Standard_ShortReal Size() const { return myLength + myBoxSize + myDiskThickness + myIndent * 2.0f; }
@@ -590,10 +566,7 @@ protected: //! @name Auxilliary classes to fill presentation with proper primiti
 
   public:
 
-    const Cylinder& TranslatorCylinder() const { return myCylinder; }
-    const Cylinder& TranslatorArrow() const { return myArrow; }
     const gp_Pnt& TranslatorTipPosition() const { return myArrowTipPos; }
-    const Disk& TranslatorArrowBottom() const { return myArrowBottom; }
     const Disk& RotatorDisk() const { return myCircle; }
     float RotatorDiskRadius() const { return myCircleRadius; }
     const Cube& ScalerCube() const { return myCube; }
@@ -621,10 +594,7 @@ protected: //! @name Auxilliary classes to fill presentation with proper primiti
 
     Standard_Integer myFacettesNumber;
 
-    Cylinder myCylinder;
-    Cylinder myArrow;
     gp_Pnt   myArrowTipPos;
-    Disk     myArrowBottom;
     Disk     myCircle;
     float    myCircleRadius;
     Cube     myCube;
@@ -637,6 +607,9 @@ protected: //! @name Auxilliary classes to fill presentation with proper primiti
     Handle(Prs3d_Presentation) myHighlightTranslator;
     Handle(Prs3d_Presentation) myHighlightScaler;
     Handle(Prs3d_Presentation) myHighlightRotator;
+
+    Handle(Graphic3d_ArrayOfTriangles) myTriangleArray;
+
   };
 
 protected:
index 4bd4270717e7018dffbe5c427b7257ade47a99dd..a982836f3d97ef1e06f9625e4cc53174be365e7f 100755 (executable)
@@ -46,6 +46,14 @@ Prs3d_Text.cxx
 Prs3d_Text.hxx
 Prs3d_TextAspect.cxx
 Prs3d_TextAspect.hxx
+Prs3d_ToolDisk.hxx
+Prs3d_ToolDisk.cxx
+Prs3d_ToolCylinder.hxx
+Prs3d_ToolCylinder.cxx
+Prs3d_ToolQuadric.hxx
+Prs3d_ToolQuadric.cxx
+Prs3d_ToolSphere.hxx
+Prs3d_ToolSphere.cxx
 Prs3d_TypeOfHLR.hxx
 Prs3d_TypeOfLinePicking.hxx
 Prs3d_VertexDrawMode.hxx
index 619d6aa712c69b7662213a29275fdeafee752ae0..3c9d12bbc3d9508ea7177cb94e2075dbaefec493 100644 (file)
 
 #include <Prs3d_Arrow.hxx>
 
+#include <gp_Ax3.hxx>
 #include <gp_Dir.hxx>
 #include <gp_Pnt.hxx>
+#include <gp_Trsf.hxx>
 #include <Graphic3d_ArrayOfPolylines.hxx>
 #include <Graphic3d_ArrayOfSegments.hxx>
 #include <Graphic3d_Group.hxx>
 #include <Prs3d_Presentation.hxx>
+#include <Prs3d_ToolCylinder.hxx>
+#include <Prs3d_ToolDisk.hxx>
+#include <Prs3d_ToolSphere.hxx>
 
 //=======================================================================
 //function : Draw
@@ -85,3 +90,61 @@ void Prs3d_Arrow::Draw(const Handle(Graphic3d_Group)& theGroup,
   theGroup->AddPrimitiveArray (aPrims1);
   theGroup->AddPrimitiveArray (aPrims2);
 }
+
+// ============================================================================
+// function : DrawShaded
+// purpose  :
+// ============================================================================
+Handle(Graphic3d_ArrayOfTriangles) Prs3d_Arrow::DrawShaded (const gp_Ax1&          theAxis,
+                                                            const Standard_Real    theTubeRadius,
+                                                            const Standard_Real    theAxisLength,
+                                                            const Standard_Real    theConeRadius,
+                                                            const Standard_Real    theConeLength,
+                                                            const Standard_Integer theNbFacettes)
+{
+  const Standard_Real aTubeLength = Max (0.0, theAxisLength - theConeLength);
+  const Standard_Integer aNbTrisTube = (theTubeRadius > 0.0 && aTubeLength > 0.0)
+                                     ? Prs3d_ToolCylinder::TrianglesNb (theNbFacettes, 1)
+                                     : 0;
+  const Standard_Integer aNbTrisCone = (theConeRadius > 0.0 && theConeLength > 0.0)
+                                     ? (Prs3d_ToolDisk    ::TrianglesNb (theNbFacettes, 1)
+                                      + Prs3d_ToolCylinder::TrianglesNb (theNbFacettes, 1))
+                                     : 0;
+
+  const Standard_Integer aNbTris = aNbTrisTube + aNbTrisCone;
+  if (aNbTris == 0)
+  {
+    return Handle(Graphic3d_ArrayOfTriangles)();
+  }
+
+  Handle(Graphic3d_ArrayOfTriangles) anArray = new Graphic3d_ArrayOfTriangles (aNbTris * 3, 0, Standard_True);
+  if (aNbTrisTube != 0)
+  {
+    gp_Ax3  aSystem (theAxis.Location(), theAxis.Direction());
+    gp_Trsf aTrsf;
+    aTrsf.SetTransformation (aSystem, gp_Ax3());
+
+    Prs3d_ToolCylinder aTool (theTubeRadius, theTubeRadius, aTubeLength, theNbFacettes, 1);
+    aTool.FillArray (anArray, aTrsf);
+  }
+
+  if (aNbTrisCone != 0)
+  {
+    gp_Pnt aConeOrigin = theAxis.Location().Translated (gp_Vec (theAxis.Direction().X() * aTubeLength,
+                                                                theAxis.Direction().Y() * aTubeLength,
+                                                                theAxis.Direction().Z() * aTubeLength));
+    gp_Ax3  aSystem (aConeOrigin, theAxis.Direction());
+    gp_Trsf aTrsf;
+    aTrsf.SetTransformation (aSystem, gp_Ax3());
+    {
+      Prs3d_ToolDisk aTool (0.0, theConeRadius, theNbFacettes, 1);
+      aTool.FillArray (anArray, aTrsf);
+    }
+    {
+      Prs3d_ToolCylinder aTool (theConeRadius, 0.0, theConeLength, theNbFacettes, 1);
+      aTool.FillArray (anArray, aTrsf);
+    }
+  }
+
+  return anArray;
+}
index 6e813620c88a5dee6f0e27e22534b31c59e40b8a..21917b7203cfcab6451cd469df19b83e1a411302 100644 (file)
 #define _Prs3d_Arrow_HeaderFile
 
 #include <Prs3d_Root.hxx>
+
+#include <Graphic3d_ArrayOfTriangles.hxx>
 #include <Quantity_PlaneAngle.hxx>
 #include <Quantity_Length.hxx>
 
+class gp_Ax1;
 class gp_Pnt;
 class gp_Dir;
 
@@ -29,7 +32,19 @@ class Prs3d_Arrow : public Prs3d_Root
 {
 public:
 
-  DEFINE_STANDARD_ALLOC
+  //! Defines the representation of the arrow as shaded triangulation.
+  //! @param theAxis       axis definition (arrow origin and direction)
+  //! @param theTubeRadius tube (cylinder) radius
+  //! @param theAxisLength overall arrow length (cylinder + cone)
+  //! @param theConeRadius cone radius (arrow tip)
+  //! @param theConeLength cone length (arrow tip)
+  //! @param theNbFacettes tessellation quality for each part
+  Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) DrawShaded (const gp_Ax1&          theAxis,
+                                                                        const Standard_Real    theTubeRadius,
+                                                                        const Standard_Real    theAxisLength,
+                                                                        const Standard_Real    theConeRadius,
+                                                                        const Standard_Real    theConeLength,
+                                                                        const Standard_Integer theNbFacettes);
 
   //! Defines the representation of the arrow.
   //! Note that this method does NOT assign any presentation aspects to the primitives group!
diff --git a/src/Prs3d/Prs3d_ToolCylinder.cxx b/src/Prs3d/Prs3d_ToolCylinder.cxx
new file mode 100644 (file)
index 0000000..a570e5f
--- /dev/null
@@ -0,0 +1,80 @@
+// Created on: 1995-07-27
+// Created by: Modelistation
+// Copyright (c) 1995-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Prs3d_ToolCylinder.hxx>
+
+#include <Graphic3d_ArrayOfTriangles.hxx>
+#include <Poly_Array1OfTriangle.hxx>
+#include <Prs3d_ToolQuadric.hxx>
+
+//=======================================================================
+//function : Constructor
+//purpose  :
+//=======================================================================
+Prs3d_ToolCylinder::Prs3d_ToolCylinder (const Standard_Real    theBottomRad,
+                                        const Standard_Real    theTopRad,
+                                        const Standard_Real    theHeight,
+                                        const Standard_Integer theNbSlices,
+                                        const Standard_Integer theNbStacks)
+: myBottomRadius (theBottomRad),
+  myTopRadius (theTopRad),
+  myHeight (theHeight)
+{
+  myStacksNb = theNbStacks;
+  mySlicesNb = theNbSlices;
+}
+
+//=======================================================================
+//function : Vertex
+//purpose  :
+//=======================================================================
+gp_Pnt Prs3d_ToolCylinder::Vertex (const Standard_Real theU, const Standard_Real theV)
+{
+  const Standard_Real aU      = theU * M_PI * 2.0;
+  const Standard_Real aRadius = myBottomRadius + (myTopRadius - myBottomRadius) * theV;
+  return gp_Pnt (Cos (aU) * aRadius,
+                 Sin (aU) * aRadius,
+                 theV * myHeight);
+}
+
+//=======================================================================
+//function : Add
+//purpose  :
+//=======================================================================
+gp_Dir Prs3d_ToolCylinder::Normal (const Standard_Real theU, const Standard_Real /*theV*/)
+{
+  const Standard_Real aU = theU * M_PI * 2.0;
+  return gp_Dir (Cos (aU) * myHeight,
+                 Sin (aU) * myHeight,
+                 myBottomRadius - myTopRadius);
+}
+
+//=======================================================================
+//function : Perform
+//purpose  :
+//=======================================================================
+Handle(Graphic3d_ArrayOfTriangles) Prs3d_ToolCylinder::Create (const Standard_Real    theBottomRad,
+                                                               const Standard_Real    theTopRad,
+                                                               const Standard_Real    theHeight,
+                                                               const Standard_Integer theNbSlices,
+                                                               const Standard_Integer theNbStacks,
+                                                               const gp_Trsf&         theTrsf)
+{
+  Handle(Graphic3d_ArrayOfTriangles) anArray;
+  Prs3d_ToolCylinder aTool (theBottomRad, theTopRad, theHeight, theNbSlices, theNbStacks);
+  aTool.FillArray (anArray, theTrsf);
+  return anArray;
+}
diff --git a/src/Prs3d/Prs3d_ToolCylinder.hxx b/src/Prs3d/Prs3d_ToolCylinder.hxx
new file mode 100644 (file)
index 0000000..681778b
--- /dev/null
@@ -0,0 +1,59 @@
+// Created on: 2016-02-04
+// Created by: Anastasia BORISOVA
+// Copyright (c) 2016 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Prs3d_ToolCylinder_HeaderFile
+#define _Prs3d_ToolCylinder_HeaderFile
+
+#include <Standard.hxx>
+#include <Prs3d_ToolQuadric.hxx>
+
+//! Standard presentation algorithm that outputs graphical primitives for cylindrical surface.
+class Prs3d_ToolCylinder : public Prs3d_ToolQuadric
+{
+public:
+
+  //! Generate primitives for 3D quadric surface and return a filled array.
+  Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real    theBottomRad,
+                                                                    const Standard_Real    theTopRad,
+                                                                    const Standard_Real    theHeight,
+                                                                    const Standard_Integer theNbSlices,
+                                                                    const Standard_Integer theNbStacks,
+                                                                    const gp_Trsf&         theTrsf);
+public:
+
+  //! Initializes the algorithm.
+  Standard_EXPORT Prs3d_ToolCylinder (const Standard_Real    theBottomRad,
+                                      const Standard_Real    theTopRad,
+                                      const Standard_Real    theHeight,
+                                      const Standard_Integer theNbSlices,
+                                      const Standard_Integer theNbStacks);
+
+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;
+
+  //! 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;
+
+protected:
+
+  Standard_Real myBottomRadius;
+  Standard_Real myTopRadius;
+  Standard_Real myHeight;
+
+};
+
+#endif // _Prs3d_ToolCylinder_HeaderFile
diff --git a/src/Prs3d/Prs3d_ToolDisk.cxx b/src/Prs3d/Prs3d_ToolDisk.cxx
new file mode 100644 (file)
index 0000000..3857d15
--- /dev/null
@@ -0,0 +1,73 @@
+// Created on: 2016-02-04
+// Created by: Anastasia BORISOVA
+// Copyright (c) 2016 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Prs3d_ToolDisk.hxx>
+
+#include <Graphic3d_ArrayOfTriangles.hxx>
+#include <Poly_Array1OfTriangle.hxx>
+#include <Prs3d_ToolQuadric.hxx>
+
+//=======================================================================
+//function : Constructor
+//purpose  :
+//=======================================================================
+Prs3d_ToolDisk::Prs3d_ToolDisk (const Standard_Real    theInnerRadius,
+                                const Standard_Real    theOuterRadius,
+                                const Standard_Integer theNbSlices,
+                                const Standard_Integer theNbStacks)
+: myInnerRadius (theInnerRadius),
+  myOuterRadius (theOuterRadius)
+{
+  mySlicesNb = theNbSlices;
+  myStacksNb = theNbStacks;
+}
+
+//=======================================================================
+//function : Vertex
+//purpose  :
+//=======================================================================
+gp_Pnt Prs3d_ToolDisk::Vertex (const Standard_Real theU, const Standard_Real theV)
+{
+  const Standard_Real aU      = theU * M_PI * 2.0;
+  const Standard_Real aRadius = myInnerRadius + (myOuterRadius - myInnerRadius) * theV;
+  return gp_Pnt (Cos (aU) * aRadius,
+                 Sin (aU) * aRadius,
+                 0.0);
+}
+
+//=======================================================================
+//function : Add
+//purpose  :
+//=======================================================================
+gp_Dir Prs3d_ToolDisk::Normal (const Standard_Real /*theU*/, const Standard_Real /*theV*/)
+{
+  return gp_Dir (0.0, 0.0, -1.0);
+}
+
+//=======================================================================
+//function : Perform
+//purpose  :
+//=======================================================================
+Handle(Graphic3d_ArrayOfTriangles) Prs3d_ToolDisk::Create (const Standard_Real    theInnerRadius,
+                                                           const Standard_Real    theOuterRadius,
+                                                           const Standard_Integer theNbSlices,
+                                                           const Standard_Integer theNbStacks,
+                                                           const gp_Trsf&         theTrsf)
+{
+  Handle(Graphic3d_ArrayOfTriangles) anArray;
+  Prs3d_ToolDisk aTool (theInnerRadius, theOuterRadius, theNbSlices, theNbStacks);
+  aTool.FillArray (anArray, theTrsf);
+  return anArray;
+}
diff --git a/src/Prs3d/Prs3d_ToolDisk.hxx b/src/Prs3d/Prs3d_ToolDisk.hxx
new file mode 100644 (file)
index 0000000..1e66093
--- /dev/null
@@ -0,0 +1,55 @@
+// Created on: 2016-02-04
+// Created by: Anastasia BORISOVA
+// Copyright (c) 2016 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Prs3d_ToolDisk_HeaderFile
+#define _Prs3d_ToolDisk_HeaderFile
+
+#include <Standard.hxx>
+#include <Prs3d_ToolQuadric.hxx>
+
+//! Standard presentation algorithm that outputs graphical primitives for disk surface.
+class Prs3d_ToolDisk : public Prs3d_ToolQuadric
+{
+public:
+
+  //! Generate primitives for 3D quadric surface and return a filled array.
+  Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real    theInnerRadius,
+                                                                    const Standard_Real    theOuterRadius,
+                                                                    const Standard_Integer theNbSlices,
+                                                                    const Standard_Integer theNbStacks,
+                                                                    const gp_Trsf&         theTrsf);
+public:
+
+  //! Initializes the algorithm.
+  Standard_EXPORT Prs3d_ToolDisk (const Standard_Real    theInnerRadius,
+                                  const Standard_Real    theOuterRadius,
+                                  const Standard_Integer theNbSlices,
+                                  const Standard_Integer theNbStacks);
+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;
+
+  //! 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;
+
+protected:
+
+  Standard_Real myInnerRadius;
+  Standard_Real myOuterRadius;
+
+};
+
+#endif
diff --git a/src/Prs3d/Prs3d_ToolQuadric.cxx b/src/Prs3d/Prs3d_ToolQuadric.cxx
new file mode 100644 (file)
index 0000000..5af6cfd
--- /dev/null
@@ -0,0 +1,121 @@
+// Created on: 2016-02-04
+// Created by: Anastasia BORISOVA
+// Copyright (c) 2016 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Prs3d_ToolQuadric.hxx>
+
+#include <gp_Quaternion.hxx>
+#include <Graphic3d_ArrayOfTriangles.hxx>
+#include <Poly_Array1OfTriangle.hxx>
+#include <TColgp_Array1OfPnt.hxx>
+
+//=======================================================================
+//function : fillArrays
+//purpose  :
+//=======================================================================
+void Prs3d_ToolQuadric::fillArrays (const gp_Trsf& theTrsf, TColgp_Array1OfPnt& theArray, NCollection_Array1<gp_Dir>& theNormals)
+{
+  Standard_ShortReal aStepU = 1.0f / mySlicesNb;
+  Standard_ShortReal aStepV = 1.0f / myStacksNb;
+
+  for (Standard_Integer aU = 0; aU <= mySlicesNb; aU++)
+  {
+    const Standard_Real aParamU = aU * aStepU;
+    for (Standard_Integer aV = 0; aV <= myStacksNb; aV++)
+    {
+      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);
+
+      theArray.SetValue (aVertId, aVertex);
+      theNormals.SetValue (aVertId, aNormal);
+    }
+  }
+}
+
+//=======================================================================
+//function : FIllArray
+//purpose  :
+//=======================================================================
+void Prs3d_ToolQuadric::FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray, const gp_Trsf& theTrsf)
+{
+  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));
+    }
+  }
+}
+
+//=======================================================================
+//function : FillTriangulation
+//purpose  :
+//=======================================================================
+void Prs3d_ToolQuadric::FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray,
+                                   Handle(Poly_Triangulation)& theTriangulation,
+                                   const gp_Trsf& theTrsf)
+{
+  const Standard_Integer aTrianglesNb = TrianglesNb();
+  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 triangles
+  for (Standard_Integer aU = 0, anIndex = 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));
+
+      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));
+    }
+  }
+
+  theTriangulation = new Poly_Triangulation (anArray, aPolyTriangles);
+}
diff --git a/src/Prs3d/Prs3d_ToolQuadric.hxx b/src/Prs3d/Prs3d_ToolQuadric.hxx
new file mode 100644 (file)
index 0000000..8b6befa
--- /dev/null
@@ -0,0 +1,71 @@
+// Created on: 2016-02-04
+// Created by: Anastasia BORISOVA
+// Copyright (c) 2016 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Prs3d_ToolQuadric_HeaderFile
+#define _Prs3d_ToolQuadric_HeaderFile
+
+#include <gp_Ax1.hxx>
+#include <Graphic3d_ArrayOfPrimitives.hxx>
+#include <Graphic3d_ArrayOfTriangles.hxx>
+#include <Poly_Triangulation.hxx>
+#include <Prs3d_Root.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard.hxx>
+
+//! Base class to build 3D surfaces presentation of quadric surfaces.
+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.
+  static Standard_Integer TrianglesNb (const Standard_Integer theSlicesNb,
+                                       const Standard_Integer theStacksNb)
+  {
+    return theSlicesNb * theStacksNb * 2;
+  }
+
+protected:
+
+  //! 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);
+
+  //! Number of triangles in generated presentation.
+  Standard_Integer TrianglesNb() const
+  {
+    return mySlicesNb * myStacksNb * 2;
+  }
+
+  //! Redefine this method to generate vertex at given parameters.
+  virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) = 0;
+
+  //! Redefine this method to generate normal at given parameters.
+  virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) = 0;
+
+protected:
+
+  Standard_Integer mySlicesNb;
+  Standard_Integer myStacksNb;
+};
+
+#endif // _Prs3d_ToolQuadric_HeaderFile
diff --git a/src/Prs3d/Prs3d_ToolSphere.cxx b/src/Prs3d/Prs3d_ToolSphere.cxx
new file mode 100644 (file)
index 0000000..973a71b
--- /dev/null
@@ -0,0 +1,74 @@
+// Created on: 2016-02-04
+// Created by: Anastasia BORISOVA
+// Copyright (c) 2016 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Prs3d_ToolSphere.hxx>
+
+#include <Graphic3d_ArrayOfTriangles.hxx>
+#include <Poly_Array1OfTriangle.hxx>
+#include <Prs3d_ToolQuadric.hxx>
+
+//=======================================================================
+//function : Constructor
+//purpose  :
+//=======================================================================
+Prs3d_ToolSphere::Prs3d_ToolSphere (const Standard_Real    theRadius,
+                                    const Standard_Integer theNbSlices,
+                                    const Standard_Integer theNbStacks)
+: myRadius (theRadius)
+{
+  mySlicesNb = theNbSlices;
+  myStacksNb = theNbStacks;
+}
+
+//=======================================================================
+//function : Vertex
+//purpose  :
+//=======================================================================
+gp_Pnt Prs3d_ToolSphere::Vertex (const Standard_Real theU, const Standard_Real theV)
+{
+  const Standard_Real aU = theU * M_PI * 2.0;
+  const Standard_Real aV = theV * M_PI;
+  return gp_Pnt (myRadius * Cos (aU) * Sin (aV),
+                -myRadius * Sin (aU) * Sin (aV),
+                 myRadius * Cos (aV));
+}
+
+//=======================================================================
+//function : Add
+//purpose  :
+//=======================================================================
+gp_Dir Prs3d_ToolSphere::Normal (const Standard_Real theU, const Standard_Real theV)
+{
+  const Standard_Real aU = theU * M_PI * 2.0;
+  const Standard_Real aV = theV * M_PI;
+  return gp_Dir (Cos (aU) * Sin (aV),
+                -Sin (aU) * Sin (aV),
+                 Cos (aV));
+}
+
+//=======================================================================
+//function : Perform
+//purpose  :
+//=======================================================================
+Handle(Graphic3d_ArrayOfTriangles) Prs3d_ToolSphere::Create (const Standard_Real    theRadius,
+                                                             const Standard_Integer theNbSlices,
+                                                             const Standard_Integer theNbStacks,
+                                                             const gp_Trsf&         theTrsf)
+{
+  Handle(Graphic3d_ArrayOfTriangles) anArray;
+  Prs3d_ToolSphere aTool (theRadius, theNbSlices, theNbStacks);
+  aTool.FillArray (anArray, theTrsf);
+  return anArray;
+}
diff --git a/src/Prs3d/Prs3d_ToolSphere.hxx b/src/Prs3d/Prs3d_ToolSphere.hxx
new file mode 100644 (file)
index 0000000..671262c
--- /dev/null
@@ -0,0 +1,60 @@
+// Created on: 2016-02-04
+// Created by: Anastasia BORISOVA
+// Copyright (c) 2016 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Prs3d_ToolSphere_HeaderFile
+#define _Prs3d_ToolSphere_HeaderFile
+
+#include <Graphic3d_ArrayOfPrimitives.hxx>
+#include <Graphic3d_ArrayOfTriangles.hxx>
+#include <Poly_Triangulation.hxx>
+#include <Prs3d_Root.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard.hxx>
+#include <Standard_Handle.hxx>
+#include <Prs3d_ToolQuadric.hxx>
+
+//! Standard presentation algorithm that outputs graphical primitives for spherical surface.
+class Prs3d_ToolSphere : public Prs3d_ToolQuadric
+{
+public:
+
+  //! Generate primitives for 3D quadric surface and return a filled array.
+  Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real    theRadius,
+                                                                    const Standard_Integer theNbSlices,
+                                                                    const Standard_Integer theNbStacks,
+                                                                    const gp_Trsf&         theTrsf);
+public:
+
+  //! Initializes the algorithm.
+  Standard_EXPORT Prs3d_ToolSphere (const Standard_Real    theRadius,
+                                    const Standard_Integer theNbSlices,
+                                    const Standard_Integer theNbStacks);
+
+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;
+
+  //! 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;
+
+protected:
+
+  Standard_Real myRadius;
+
+};
+
+#endif
index 31829a8951ba84ed5888dc224215811fecd9c3b5..94ffef116e245a94c7b200c8a08fa3dd55c44a70 100644 (file)
@@ -21,16 +21,8 @@ StdPrs_ShadedShape.cxx
 StdPrs_ShadedShape.hxx
 StdPrs_ShadedSurface.cxx
 StdPrs_ShadedSurface.hxx
-StdPrs_ToolDisk.hxx
-StdPrs_ToolDisk.cxx
-StdPrs_ToolCylinder.hxx
-StdPrs_ToolCylinder.cxx
 StdPrs_ToolPoint.cxx
 StdPrs_ToolPoint.hxx
-StdPrs_ToolQuadric.hxx
-StdPrs_ToolQuadric.cxx
-StdPrs_ToolSphere.hxx
-StdPrs_ToolSphere.cxx
 StdPrs_ToolRFace.cxx
 StdPrs_ToolRFace.hxx
 StdPrs_ToolTriangulatedShape.cxx
diff --git a/src/StdPrs/StdPrs_ToolCylinder.cxx b/src/StdPrs/StdPrs_ToolCylinder.cxx
deleted file mode 100644 (file)
index cbfec93..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-// Created on: 1995-07-27
-// Created by: Modelistation
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <StdPrs_ToolCylinder.hxx>
-
-#include <Graphic3d_ArrayOfTriangles.hxx>
-#include <Poly_Array1OfTriangle.hxx>
-#include <StdPrs_ToolQuadric.hxx>
-
-//=======================================================================
-//function : Constructor
-//purpose  :
-//=======================================================================
-StdPrs_ToolCylinder::StdPrs_ToolCylinder (const Standard_Real    theBottomRad,
-                                          const Standard_Real    theTopRad,
-                                          const Standard_Real    theHeight,
-                                          const Standard_Integer theNbSlices,
-                                          const Standard_Integer theNbStacks)
-: myBottomRadius (theBottomRad),
-  myTopRadius (theTopRad),
-  myHeight (theHeight)
-{
-  myStacksNb = theNbStacks;
-  mySlicesNb = theNbSlices;
-}
-
-//=======================================================================
-//function : Vertex
-//purpose  :
-//=======================================================================
-gp_Pnt StdPrs_ToolCylinder::Vertex (const Standard_Real theU, const Standard_Real theV)
-{
-  const Standard_Real aU      = theU * M_PI * 2.0;
-  const Standard_Real aRadius = myBottomRadius + (myTopRadius - myBottomRadius) * theV;
-  return gp_Pnt (Cos (aU) * aRadius,
-                 Sin (aU) * aRadius,
-                 theV * myHeight);
-}
-
-//=======================================================================
-//function : Add
-//purpose  :
-//=======================================================================
-gp_Dir StdPrs_ToolCylinder::Normal (const Standard_Real theU, const Standard_Real /*theV*/)
-{
-  const Standard_Real aU = theU * M_PI * 2.0;
-  return gp_Dir (Cos (aU) * myHeight,
-                 Sin (aU) * myHeight,
-                 myBottomRadius - myTopRadius);
-}
-
-//=======================================================================
-//function : Perform
-//purpose  :
-//=======================================================================
-Handle(Graphic3d_ArrayOfTriangles) StdPrs_ToolCylinder::Create (const Standard_Real    theBottomRad,
-                                                                const Standard_Real    theTopRad,
-                                                                const Standard_Real    theHeight,
-                                                                const Standard_Integer theNbSlices,
-                                                                const Standard_Integer theNbStacks,
-                                                                const gp_Trsf&         theTrsf)
-{
-  Handle(Graphic3d_ArrayOfTriangles) anArray;
-  StdPrs_ToolCylinder aTool (theBottomRad, theTopRad, theHeight, theNbSlices, theNbStacks);
-  aTool.FillArray (anArray, theTrsf);
-  return anArray;
-}
diff --git a/src/StdPrs/StdPrs_ToolCylinder.hxx b/src/StdPrs/StdPrs_ToolCylinder.hxx
deleted file mode 100644 (file)
index eaff0db..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-// Created on: 2016-02-04
-// Created by: Anastasia BORISOVA
-// Copyright (c) 2016 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _StdPrs_ToolCylinder_HeaderFile
-#define _StdPrs_ToolCylinder_HeaderFile
-
-#include <Standard.hxx>
-#include <StdPrs_ToolQuadric.hxx>
-
-//! Standard presentation algorithm that outputs graphical primitives for cylindrical surface.
-class StdPrs_ToolCylinder : public StdPrs_ToolQuadric
-{
-public:
-
-  //! Generate primitives for 3D quadric surface and return a filled array.
-  Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real    theBottomRad,
-                                                                    const Standard_Real    theTopRad,
-                                                                    const Standard_Real    theHeight,
-                                                                    const Standard_Integer theNbSlices,
-                                                                    const Standard_Integer theNbStacks,
-                                                                    const gp_Trsf&         theTrsf);
-public:
-
-  DEFINE_STANDARD_ALLOC
-
-  //! Initializes the algorithm.
-  Standard_EXPORT StdPrs_ToolCylinder (const Standard_Real    theBottomRad,
-                                       const Standard_Real    theTopRad,
-                                       const Standard_Real    theHeight,
-                                       const Standard_Integer theNbSlices,
-                                       const Standard_Integer theNbStacks);
-
-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;
-
-  //! 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;
-
-protected:
-
-  Standard_Real myBottomRadius;
-  Standard_Real myTopRadius;
-  Standard_Real myHeight;
-
-};
-
-#endif // _StdPrs_ToolCylinder_HeaderFile
diff --git a/src/StdPrs/StdPrs_ToolDisk.cxx b/src/StdPrs/StdPrs_ToolDisk.cxx
deleted file mode 100644 (file)
index 8eff597..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-// Created on: 2016-02-04
-// Created by: Anastasia BORISOVA
-// Copyright (c) 2016 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <StdPrs_ToolDisk.hxx>
-
-#include <Graphic3d_ArrayOfTriangles.hxx>
-#include <Poly_Array1OfTriangle.hxx>
-#include <StdPrs_ToolQuadric.hxx>
-
-//=======================================================================
-//function : Constructor
-//purpose  :
-//=======================================================================
-StdPrs_ToolDisk::StdPrs_ToolDisk (const Standard_Real    theInnerRadius,
-                                  const Standard_Real    theOuterRadius,
-                                  const Standard_Integer theNbSlices,
-                                  const Standard_Integer theNbStacks)
-: myInnerRadius (theInnerRadius),
-  myOuterRadius (theOuterRadius)
-{
-  mySlicesNb = theNbSlices;
-  myStacksNb = theNbStacks;
-}
-
-//=======================================================================
-//function : Vertex
-//purpose  :
-//=======================================================================
-gp_Pnt StdPrs_ToolDisk::Vertex (const Standard_Real theU, const Standard_Real theV)
-{
-  const Standard_Real aU      = theU * M_PI * 2.0;
-  const Standard_Real aRadius = myInnerRadius + (myOuterRadius - myInnerRadius) * theV;
-  return gp_Pnt (Cos (aU) * aRadius,
-                 Sin (aU) * aRadius,
-                 0.0);
-}
-
-//=======================================================================
-//function : Add
-//purpose  :
-//=======================================================================
-gp_Dir StdPrs_ToolDisk::Normal (const Standard_Real /*theU*/, const Standard_Real /*theV*/)
-{
-  return gp_Dir (0.0, 0.0, -1.0);
-}
-
-//=======================================================================
-//function : Perform
-//purpose  :
-//=======================================================================
-Handle(Graphic3d_ArrayOfTriangles) StdPrs_ToolDisk::Create (const Standard_Real    theInnerRadius,
-                                                            const Standard_Real    theOuterRadius,
-                                                            const Standard_Integer theNbSlices,
-                                                            const Standard_Integer theNbStacks,
-                                                            const gp_Trsf&         theTrsf)
-{
-  Handle(Graphic3d_ArrayOfTriangles) anArray;
-  StdPrs_ToolDisk aTool (theInnerRadius, theOuterRadius, theNbSlices, theNbStacks);
-  aTool.FillArray (anArray, theTrsf);
-  return anArray;
-}
diff --git a/src/StdPrs/StdPrs_ToolDisk.hxx b/src/StdPrs/StdPrs_ToolDisk.hxx
deleted file mode 100644 (file)
index fae2d9f..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-// Created on: 2016-02-04
-// Created by: Anastasia BORISOVA
-// Copyright (c) 2016 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _StdPrs_ToolDisk_HeaderFile
-#define _StdPrs_ToolDisk_HeaderFile
-
-#include <Standard.hxx>
-#include <StdPrs_ToolQuadric.hxx>
-
-//! Standard presentation algorithm that outputs graphical primitives for disk surface.
-class StdPrs_ToolDisk : public StdPrs_ToolQuadric
-{
-public:
-
-  //! Generate primitives for 3D quadric surface and return a filled array.
-  Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real    theInnerRadius,
-                                                                    const Standard_Real    theOuterRadius,
-                                                                    const Standard_Integer theNbSlices,
-                                                                    const Standard_Integer theNbStacks,
-                                                                    const gp_Trsf&         theTrsf);
-public:
-
-  DEFINE_STANDARD_ALLOC
-
-  //! Initializes the algorithm.
-  Standard_EXPORT StdPrs_ToolDisk (const Standard_Real    theInnerRadius,
-                                   const Standard_Real    theOuterRadius,
-                                   const Standard_Integer theNbSlices,
-                                   const Standard_Integer theNbStacks);
-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;
-
-  //! 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;
-
-protected:
-
-  Standard_Real myInnerRadius;
-  Standard_Real myOuterRadius;
-
-};
-
-#endif
diff --git a/src/StdPrs/StdPrs_ToolQuadric.cxx b/src/StdPrs/StdPrs_ToolQuadric.cxx
deleted file mode 100644 (file)
index f06b1fc..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-// Created on: 2016-02-04
-// Created by: Anastasia BORISOVA
-// Copyright (c) 2016 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <StdPrs_ToolQuadric.hxx>
-
-#include <gp_Quaternion.hxx>
-#include <Graphic3d_ArrayOfTriangles.hxx>
-#include <Poly_Array1OfTriangle.hxx>
-#include <TColgp_Array1OfPnt.hxx>
-
-//=======================================================================
-//function : fillArrays
-//purpose  :
-//=======================================================================
-void StdPrs_ToolQuadric::fillArrays (const gp_Trsf& theTrsf, TColgp_Array1OfPnt& theArray, NCollection_Array1<gp_Dir>& theNormals)
-{
-  Standard_ShortReal aStepU = 1.0f / mySlicesNb;
-  Standard_ShortReal aStepV = 1.0f / myStacksNb;
-
-  for (Standard_Integer aU = 0; aU <= mySlicesNb; aU++)
-  {
-    const Standard_Real aParamU = aU * aStepU;
-    for (Standard_Integer aV = 0; aV <= myStacksNb; aV++)
-    {
-      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);
-
-      theArray.SetValue (aVertId, aVertex);
-      theNormals.SetValue (aVertId, aNormal);
-    }
-  }
-}
-
-//=======================================================================
-//function : FIllArray
-//purpose  :
-//=======================================================================
-void StdPrs_ToolQuadric::FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray, const gp_Trsf& theTrsf)
-{
-  const Standard_Integer aTrianglesNb = TrianglesNb();
-  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));
-    }
-  }
-}
-
-//=======================================================================
-//function : FillTriangulation
-//purpose  :
-//=======================================================================
-void StdPrs_ToolQuadric::FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray,
-                                    Handle(Poly_Triangulation)& theTriangulation,
-                                    const gp_Trsf& theTrsf)
-{
-  const Standard_Integer aTrianglesNb = TrianglesNb();
-  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 triangles
-  for (Standard_Integer aU = 0, anIndex = 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));
-
-      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));
-    }
-  }
-
-  theTriangulation = new Poly_Triangulation (anArray, aPolyTriangles);
-}
diff --git a/src/StdPrs/StdPrs_ToolQuadric.hxx b/src/StdPrs/StdPrs_ToolQuadric.hxx
deleted file mode 100644 (file)
index 264f7bf..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-// Created on: 2016-02-04
-// Created by: Anastasia BORISOVA
-// Copyright (c) 2016 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _StdPrs_ToolQuadric_HeaderFile
-#define _StdPrs_ToolQuadric_HeaderFile
-
-#include <gp_Ax1.hxx>
-#include <Graphic3d_ArrayOfPrimitives.hxx>
-#include <Graphic3d_ArrayOfTriangles.hxx>
-#include <Poly_Triangulation.hxx>
-#include <Prs3d_Root.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard.hxx>
-
-//! Base class to build 3D surfaces presentation of quadric surfaces.
-class StdPrs_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);
-
-protected:
-
-  //! 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);
-
-  //! Number of triangles in generated presentation.
-  Standard_Integer TrianglesNb() const
-  {
-    return mySlicesNb * myStacksNb * 2;
-  }
-
-  //! Redefine this method to generate vertex at given parameters.
-  virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) = 0;
-
-  //! Redefine this method to generate normal at given parameters.
-  virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) = 0;
-
-protected:
-
-  Standard_Integer mySlicesNb;
-  Standard_Integer myStacksNb;
-};
-
-#endif // _StdPrs_ShadedSurface_HeaderFile
diff --git a/src/StdPrs/StdPrs_ToolSphere.cxx b/src/StdPrs/StdPrs_ToolSphere.cxx
deleted file mode 100644 (file)
index 62e51b2..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-// Created on: 2016-02-04
-// Created by: Anastasia BORISOVA
-// Copyright (c) 2016 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <StdPrs_ToolSphere.hxx>
-
-#include <Graphic3d_ArrayOfTriangles.hxx>
-#include <Poly_Array1OfTriangle.hxx>
-#include <StdPrs_ToolQuadric.hxx>
-
-//=======================================================================
-//function : Constructor
-//purpose  :
-//=======================================================================
-StdPrs_ToolSphere::StdPrs_ToolSphere (const Standard_Real    theRadius,
-                                      const Standard_Integer theNbSlices,
-                                      const Standard_Integer theNbStacks)
-: myRadius (theRadius)
-{
-  mySlicesNb = theNbSlices;
-  myStacksNb = theNbStacks;
-}
-
-//=======================================================================
-//function : Vertex
-//purpose  :
-//=======================================================================
-gp_Pnt StdPrs_ToolSphere::Vertex (const Standard_Real theU, const Standard_Real theV)
-{
-  const Standard_Real aU = theU * M_PI * 2.0;
-  const Standard_Real aV = theV * M_PI;
-  return gp_Pnt (myRadius * Cos (aU) * Sin (aV),
-                -myRadius * Sin (aU) * Sin (aV),
-                 myRadius * Cos (aV));
-}
-
-//=======================================================================
-//function : Add
-//purpose  :
-//=======================================================================
-gp_Dir StdPrs_ToolSphere::Normal (const Standard_Real theU, const Standard_Real theV)
-{
-  const Standard_Real aU = theU * M_PI * 2.0;
-  const Standard_Real aV = theV * M_PI;
-  return gp_Dir (Cos (aU) * Sin (aV),
-                -Sin (aU) * Sin (aV),
-                 Cos (aV));
-}
-
-//=======================================================================
-//function : Perform
-//purpose  :
-//=======================================================================
-Handle(Graphic3d_ArrayOfTriangles) StdPrs_ToolSphere::Create (const Standard_Real    theRadius,
-                                                              const Standard_Integer theNbSlices,
-                                                              const Standard_Integer theNbStacks,
-                                                              const gp_Trsf&         theTrsf)
-{
-  Handle(Graphic3d_ArrayOfTriangles) anArray;
-  StdPrs_ToolSphere aTool (theRadius, theNbSlices, theNbStacks);
-  aTool.FillArray (anArray, theTrsf);
-  return anArray;
-}
diff --git a/src/StdPrs/StdPrs_ToolSphere.hxx b/src/StdPrs/StdPrs_ToolSphere.hxx
deleted file mode 100644 (file)
index 1347a95..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-// Created on: 2016-02-04
-// Created by: Anastasia BORISOVA
-// Copyright (c) 2016 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _StdPrs_ToolSphere_HeaderFile
-#define _StdPrs_ToolSphere_HeaderFile
-
-#include <Graphic3d_ArrayOfPrimitives.hxx>
-#include <Graphic3d_ArrayOfTriangles.hxx>
-#include <Poly_Triangulation.hxx>
-#include <Prs3d_Root.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <Standard.hxx>
-#include <Standard_Handle.hxx>
-#include <StdPrs_ToolQuadric.hxx>
-
-//! Standard presentation algorithm that outputs graphical primitives for spherical surface.
-class StdPrs_ToolSphere : public StdPrs_ToolQuadric
-{
-public:
-
-  //! Generate primitives for 3D quadric surface and return a filled array.
-  Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real    theRadius,
-                                                                    const Standard_Integer theNbSlices,
-                                                                    const Standard_Integer theNbStacks,
-                                                                    const gp_Trsf&         theTrsf);
-public:
-
-  DEFINE_STANDARD_ALLOC
-
-  //! Initializes the algorithm.
-  Standard_EXPORT StdPrs_ToolSphere (const Standard_Real    theRadius,
-                                     const Standard_Integer theNbSlices,
-                                     const Standard_Integer theNbStacks);
-
-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;
-
-  //! 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;
-
-protected:
-
-  Standard_Real myRadius;
-
-};
-
-#endif
index 77ad2e8b3ca2889b1db9be780fbe5aeb20b1a3d4..ca6e2ada0f35e7834d5470c8a7657e331cca2001 100644 (file)
 #include <Graphic3d_Camera.hxx>
 #include <Graphic3d_TransformPers.hxx>
 #include <Prs3d.hxx>
+#include <Prs3d_Arrow.hxx>
 #include <Prs3d_LineAspect.hxx>
 #include <Prs3d_ShadingAspect.hxx>
 #include <Prs3d_Text.hxx>
 #include <Prs3d_TextAspect.hxx>
-#include <StdPrs_ToolCylinder.hxx>
-#include <StdPrs_ToolDisk.hxx>
-#include <StdPrs_ToolSphere.hxx>
+#include <Prs3d_ToolSphere.hxx>
 #include <V3d_View.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT (V3d_Trihedron, Standard_Transient)
@@ -255,13 +254,13 @@ void V3d_Trihedron::compute()
   myStructure->GraphicClear (Standard_False);
 
   // Create trihedron.
-  const Standard_Real aScale           = myScale * myRatio * THE_INTERNAL_SCALE_FACTOR;
-  const Standard_Real aCylinderLength  = aScale * THE_CYLINDER_LENGTH;
-  const Standard_Real aCylinderDiametr = aScale * myDiameter;
-  const Standard_Real aConeDiametr     = myIsWireframe ? aCylinderDiametr : (aCylinderDiametr * 2.0);
-  const Standard_Real aConeLength      = aScale * (1.0 - THE_CYLINDER_LENGTH);
-  const Standard_Real aSphereRadius    = aCylinderDiametr * 2.0;
-  const Standard_Real aRayon           = aScale / 30.0;
+  const Standard_Real aScale          = myScale * myRatio * THE_INTERNAL_SCALE_FACTOR;
+  const Standard_Real aCylinderLength = aScale * THE_CYLINDER_LENGTH;
+  const Standard_Real aCylinderRadius = aScale * myDiameter;
+  const Standard_Real aConeRadius     = myIsWireframe ? aCylinderRadius : (aCylinderRadius * 2.0);
+  const Standard_Real aConeLength     = aScale * (1.0 - THE_CYLINDER_LENGTH);
+  const Standard_Real aSphereRadius   = aCylinderRadius * 2.0;
+  const Standard_Real aRayon          = aScale / 30.0;
   {
     Handle(Graphic3d_Group) aSphereGroup = myStructure->NewGroup();
 
@@ -284,7 +283,7 @@ void V3d_Trihedron::compute()
     {
       gp_Trsf aSphereTransform;
       aSphereGroup->SetGroupPrimitivesAspect (mySphereShadingAspect->Aspect());
-      aSphereGroup->AddPrimitiveArray (StdPrs_ToolSphere::Create (aSphereRadius, myNbFacettes, myNbFacettes, aSphereTransform));
+      aSphereGroup->AddPrimitiveArray (Prs3d_ToolSphere::Create (aSphereRadius, myNbFacettes, myNbFacettes, aSphereTransform));
     }
   }
 
@@ -294,13 +293,9 @@ void V3d_Trihedron::compute()
     for (Standard_Integer anIter = 0; anIter < 3; ++anIter)
     {
       Handle(Graphic3d_Group) anAxisGroup = myStructure->NewGroup();
-      anAxisGroup->SetGroupPrimitivesAspect (myArrowShadingAspects[anIter]->Aspect());
-
-      gp_Ax1 aPosition (anAxes[anIter]);
-
-      // Create a tube.
       if (myIsWireframe)
       {
+        // create a tube
         Handle(Graphic3d_ArrayOfPrimitives) anArray = new Graphic3d_ArrayOfSegments (2);
         anArray->AddVertex (0.0f, 0.0f, 0.0f);
         anArray->AddVertex (anAxes[anIter].Direction().XYZ() * aCylinderLength);
@@ -308,35 +303,15 @@ void V3d_Trihedron::compute()
         anAxisGroup->SetGroupPrimitivesAspect (myArrowLineAspects[anIter]->Aspect());
         anAxisGroup->AddPrimitiveArray (anArray);
       }
-      else
-      {
-        gp_Ax3  aSystem (aPosition.Location(), aPosition.Direction());
-        gp_Trsf aTrsf;
-        aTrsf.SetTransformation (aSystem, gp_Ax3());
-
-        anAxisGroup->AddPrimitiveArray (StdPrs_ToolCylinder::Create (aCylinderDiametr, aCylinderDiametr, aCylinderLength, myNbFacettes, 1, aTrsf));
-      }
-
-      aPosition.Translate (gp_Vec (aPosition.Direction().X() * aCylinderLength,
-                                   aPosition.Direction().Y() * aCylinderLength,
-                                   aPosition.Direction().Z() * aCylinderLength));
-      // Create a disk.
-      {
-        gp_Ax3  aSystem (aPosition.Location(), aPosition.Direction());
-        gp_Trsf aTrsf;
-        aTrsf.SetTransformation (aSystem, gp_Ax3());
-
-        anAxisGroup->AddPrimitiveArray (StdPrs_ToolDisk::Create (0.0, aConeDiametr, myNbFacettes, 1, aTrsf));
-      }
 
-      // Create a cone.
-      {
-        gp_Ax3  aSystem (aPosition.Location(), aPosition.Direction());
-        gp_Trsf aTrsf;
-        aTrsf.SetTransformation (aSystem, gp_Ax3());
-
-        anAxisGroup->AddPrimitiveArray (StdPrs_ToolCylinder::Create (aConeDiametr, 0.0, aConeLength, myNbFacettes, 1, aTrsf));
-      }
+      Handle(Graphic3d_ArrayOfTriangles) aTriangles = Prs3d_Arrow::DrawShaded (anAxes[anIter],
+                                                                               myIsWireframe ? 0.0 : aCylinderRadius,
+                                                                               aCylinderLength + aConeLength,
+                                                                               aConeRadius,
+                                                                               aConeLength,
+                                                                               myNbFacettes);
+      anAxisGroup->SetGroupPrimitivesAspect (myArrowShadingAspects[anIter]->Aspect());
+      anAxisGroup->AddPrimitiveArray (aTriangles);
     }
   }