0027596: Visualization, StdPrs_WFShape - pack isolines into single group of primitives
[occt.git] / src / Prs3d / Prs3d_Arrow.cxx
old mode 100755 (executable)
new mode 100644 (file)
index f5db317..369c69d
@@ -1,36 +1,36 @@
 // Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// 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.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-#include <Prs3d_Arrow.ixx>
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#include <gp_Dir.hxx>
+#include <gp_Pnt.hxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
 #include <Graphic3d_Group.hxx>
-#include <Graphic3d_Array1OfVertex.hxx>
+#include <Prs3d_Arrow.hxx>
+#include <Prs3d_Presentation.hxx>
 
 //=======================================================================
 //function : Draw
 //purpose  : 
 //=======================================================================
-
 void Prs3d_Arrow::Draw(const Handle(Prs3d_Presentation)& aPresentation,
                        const gp_Pnt& aLocation,
-                      const gp_Dir& aDirection,
+                       const gp_Dir& aDirection,
                        const Quantity_PlaneAngle anAngle,
-                      const Quantity_Length aLength) {
-
+                       const Quantity_Length aLength)
+{
   Quantity_Length dx,dy,dz;  aDirection.Coord(dx,dy,dz);
 //
 // Point of the arrow:
@@ -54,34 +54,36 @@ void Prs3d_Arrow::Draw(const Handle(Prs3d_Presentation)& aPresentation,
   Quantity_Length Norme = sqrt ( xi*xi + yi*yi + zi*zi );
   xi = xi / Norme; yi = yi / Norme; zi = zi/Norme;
 
-  Quantity_Length  xj = dy * zi - dz * yi;
-  Quantity_Length  yj = dz * xi - dx * zi;
-  Quantity_Length  zj = dx * yi - dy * xi;
-
-  Standard_Integer NbPoints = 15;
+  const Quantity_Length  xj = dy * zi - dz * yi;
+  const Quantity_Length  yj = dz * xi - dx * zi;
+  const Quantity_Length  zj = dx * yi - dy * xi;
 
-  Graphic3d_Array1OfVertex VN(1,NbPoints+1);
-  Graphic3d_Array1OfVertex V2(1,2);
-  V2(1).SetCoord(xo,yo,zo);
+  const Standard_Integer NbPoints = 15;
 
-  Quantity_Length x,y,z;
-  Standard_Real cosinus,sinus, Tg=tan(anAngle);
+  Handle(Graphic3d_ArrayOfSegments) aPrims1 = new Graphic3d_ArrayOfSegments(2*NbPoints);
+  Handle(Graphic3d_ArrayOfPolylines) aPrims2 = new Graphic3d_ArrayOfPolylines(NbPoints+1);
 
-  for (Standard_Integer i = 1 ; i <= NbPoints ; i++) {
+  gp_Pnt p1;
+  const Standard_Real Tg=tan(anAngle);
 
-    cosinus = cos ( 2 * M_PI / NbPoints * (i-1) );   
-    sinus   = sin ( 2 * M_PI / NbPoints * (i-1) );
+  for (Standard_Integer i = 1; i <= NbPoints ; i++)
+  {
+    const Standard_Real cosinus = cos ( 2 * M_PI / NbPoints * (i-1) );   
+    const Standard_Real sinus   = sin ( 2 * M_PI / NbPoints * (i-1) );
 
-    x = xc + (cosinus * xi + sinus * xj) * aLength * Tg;
-    y = yc + (cosinus * yi + sinus * yj) * aLength * Tg;
-    z = zc + (cosinus * zi + sinus * zj) * aLength * Tg;
+    const gp_Pnt pp(xc + (cosinus * xi + sinus * xj) * aLength * Tg,
+                    yc + (cosinus * yi + sinus * yj) * aLength * Tg,
+                    zc + (cosinus * zi + sinus * zj) * aLength * Tg);
 
-    VN(i).SetCoord(x,y,z);
-    if(i==1) VN(NbPoints+1).SetCoord(x,y,z);
-    V2(2).SetCoord(x,y,z);
-    Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2);
+    aPrims1->AddVertex(aLocation);
+    aPrims1->AddVertex(pp);
+    if(i==1) p1 = pp;
+    aPrims2->AddVertex(pp);
   }
-  Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VN);
+  aPrims2->AddVertex(p1);
+
+  Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims1);
+  Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims2);
 }
 
 //=======================================================================
@@ -93,6 +95,6 @@ void Prs3d_Arrow::Fill(const Handle(Prs3d_Presentation)& /*aPresentation*/,
                        const gp_Pnt& /*aLocation*/,
                        const gp_Dir& /*aDirection*/,
                        const Quantity_PlaneAngle /*anAngle*/,
-                      const Quantity_Length /*aLength*/)
+                       const Quantity_Length /*aLength*/)
 {
 }