0023634: Eliminate Polyline and Polygon usage in drawers
[occt.git] / src / DsgPrs / DsgPrs_PerpenPresentation.cxx
index 122a02f..7275c1f 100755 (executable)
@@ -38,7 +38,8 @@
 #include <Prs3d_LengthAspect.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_Array1OfVertex.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
 
 #include <StdPrs_Point.hxx>
 
@@ -56,82 +57,49 @@ void DsgPrs_PerpenPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta
   LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID); // ou DOT ou DOTDASH
   Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
   
-  Graphic3d_Array1OfVertex V1(1,2);
-  Graphic3d_Array1OfVertex V2(1,2);
-  Quantity_Length X1,Y1,Z1;
-  Quantity_Length X2,Y2,Z2;
-  
-  // 1er segment
-  OffsetPoint.Coord(X1,Y1,Z1);
-  V1(1).SetCoord(X1,Y1,Z1);
-  pAx1.Coord(X2,Y2,Z2);
-  V1(2).SetCoord(X2,Y2,Z2);  //ou directt dir1.XYZ
-  
-  Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V1);
-  Prs3d_Root::NewGroup(aPresentation);
-  Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
-  
-  // 2e segment
-  pAx2.Coord(X2,Y2,Z2);
-  V2(1).SetCoord(X1,Y1,Z1);
-  V2(2).SetCoord(X2,Y2,Z2);
-
-  Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2);
-  Prs3d_Root::NewGroup(aPresentation);
-  Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
+  // segments
+  Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines(6,2);
 
-  // points attache
-  Graphic3d_Array1OfVertex V3(1,2);
-  if (intOut1) {
-    pAx1.Coord(X1,Y1,Z1);
-    V3(1).SetCoord(X1,Y1,Z1);
-    pnt1.Coord(X2,Y2,Z2);
-    V3(2).SetCoord(X2,Y2,Z2);
-    LA->LineAspect()->SetTypeOfLine(Aspect_TOL_DOT); // ou DOT ou DOTDASH
-    Prs3d_Root::NewGroup(aPresentation);
-    Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
-    Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V3);
-  }
-  if (intOut2) {
-    pAx2.Coord(X1,Y1,Z1);
-    V3(1).SetCoord(X1,Y1,Z1);
-    pnt2.Coord(X2,Y2,Z2);
-    V3(2).SetCoord(X2,Y2,Z2);
-    LA->LineAspect()->SetTypeOfLine(Aspect_TOL_DOT); // ou DOT ou DOTDASH
-    Prs3d_Root::NewGroup(aPresentation);
-    Prs3d_Root::CurrentGroup(aPresentation)->
-      SetPrimitivesAspect(LA->LineAspect()->Aspect());
-    Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V3);
-  }
+  aPrims->AddBound(3);
+  aPrims->AddVertex(OffsetPoint);
+  aPrims->AddVertex(pAx1);
+  aPrims->AddVertex(pAx2);
 
   // Symbol
-  Graphic3d_Array1OfVertex V4(1,3);
   gp_Vec vec1(gce_MakeDir(OffsetPoint,pAx1));
   gp_Vec vec2(gce_MakeDir(OffsetPoint,pAx2));
-  Standard_Real dist1(OffsetPoint.Distance(pAx1));
-  Standard_Real dist2(OffsetPoint.Distance(pAx2));
-  vec1 *= dist1;
-  vec1 *= .2;
-  vec2 *= dist2;
-  vec2 *= .2;
+  vec1 *= .2 * OffsetPoint.Distance(pAx1);
+  vec2 *= .2 * OffsetPoint.Distance(pAx2);
 
   gp_Pnt pAx11 = OffsetPoint.Translated(vec1);
   gp_Pnt pAx22 = OffsetPoint.Translated(vec2);
   gp_Pnt p_symb = pAx22.Translated(vec1);
 
-  pAx11.Coord(X1,Y1,Z1);
-  V4(1).SetCoord(X1,Y1,Z1);
-  p_symb.Coord(X1,Y1,Z1);
-  V4(2).SetCoord(X1,Y1,Z1);
-  pAx22.Coord(X1,Y1,Z1);
-  V4(3).SetCoord(X1,Y1,Z1);
-  
-  LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID); 
-  Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
-  Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V4);
-  Prs3d_Root::NewGroup(aPresentation);
-}
-
+  aPrims->AddBound(3);
+  aPrims->AddVertex(pAx11);
+  aPrims->AddVertex(p_symb);
+  aPrims->AddVertex(pAx22);
 
+  Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
 
+  // points attache
+  if (intOut1 || intOut2)
+  {
+    LA->LineAspect()->SetTypeOfLine(Aspect_TOL_DOT); // ou DOT ou DOTDASH
+    Prs3d_Root::NewGroup(aPresentation);
+    Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
 
+    if (intOut1) {
+      aPrims = new Graphic3d_ArrayOfSegments(2);
+      aPrims->AddVertex(pAx1);
+      aPrims->AddVertex(pnt1);
+      Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
+    }
+    if (intOut2) {
+      aPrims = new Graphic3d_ArrayOfSegments(2);
+      aPrims->AddVertex(pAx2);
+      aPrims->AddVertex(pnt2);
+      Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
+    }
+  }
+}