0023948: Wrong intersection between a surface of revolution and a plane.
[occt.git] / src / DsgPrs / DsgPrs_EqualRadiusPresentation.cxx
CommitLineData
b311480e 1// Created on: 1998-01-20
2// Created by: Julia GERASIMOVA
3// Copyright (c) 1998-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
7fd59977 17#include <DsgPrs_EqualRadiusPresentation.ixx>
18
19#include <DsgPrs.hxx>
20#include <Graphic3d_Group.hxx>
a6eb515f 21#include <Prs3d_DimensionAspect.hxx>
7fd59977 22#include <Prs3d_LineAspect.hxx>
b8ddfc2f 23#include <Graphic3d_ArrayOfPolylines.hxx>
7fd59977 24#include <Prs3d_Root.hxx>
25#include <gp_Dir.hxx>
26#include <gce_MakeDir.hxx>
27#include <gp_Vec.hxx>
28#include <gp_Pln.hxx>
29#include <Precision.hxx>
30#include <TCollection_ExtendedString.hxx>
31#include <Prs3d_Text.hxx>
32
33void DsgPrs_EqualRadiusPresentation::Add( const Handle( Prs3d_Presentation )& aPresentation,
34 const Handle( Prs3d_Drawer )& aDrawer,
35 const gp_Pnt& FirstCenter,
36 const gp_Pnt& SecondCenter,
37 const gp_Pnt& FirstPoint,
38 const gp_Pnt& SecondPoint,
39 const Handle( Geom_Plane )& Plane )
40{
a6eb515f 41 Handle( Prs3d_DimensionAspect ) LA = aDrawer->DimensionAspect();
7fd59977 42 Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() );
43
b8ddfc2f 44 Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(4);
45 aPrims->AddVertex(FirstPoint);
46 aPrims->AddVertex(FirstCenter);
47 aPrims->AddVertex(SecondCenter);
48 aPrims->AddVertex(SecondPoint);
49 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
7fd59977 50
51 // Add presentation of arrows
52 gp_Dir FirstDir = gce_MakeDir( FirstCenter, FirstPoint ), SecondDir = gce_MakeDir( SecondCenter, SecondPoint );
b8ddfc2f 53 DsgPrs::ComputeSymbol( aPresentation, LA, FirstCenter, FirstPoint, FirstDir.Reversed(), FirstDir, DsgPrs_AS_FIRSTPT_LASTAR );
54 DsgPrs::ComputeSymbol( aPresentation, LA, SecondCenter, SecondPoint, SecondDir.Reversed(), SecondDir, DsgPrs_AS_FIRSTPT_LASTAR );
7fd59977 55
7fd59977 56//ota === beging ===
7fd59977 57 gp_Pnt Middle( (FirstCenter.XYZ() + SecondCenter.XYZ()) *0.5 ), aTextPos;
58 Standard_Real SmallDist;
59 //Mark of constraint
60 TCollection_ExtendedString aText("==");
61
62 Standard_Real Dist = FirstCenter.Distance( SecondCenter );
63 if (Dist > Precision::Confusion())
b8ddfc2f 64 {
65 SmallDist = Dist * 0.05; // take 1/20 part of length;
66 if (SmallDist <= Precision::Confusion())
67 SmallDist = Dist;
68 gp_Dir LineDir = gce_MakeDir( FirstCenter, SecondCenter );
69 gp_Dir OrtDir = Plane->Pln().Axis().Direction() ^ LineDir;
7fd59977 70
b8ddfc2f 71 gp_Vec OrtVec = gp_Vec( OrtDir ) * SmallDist;
7fd59977 72
b8ddfc2f 73 //Compute the text position
74 aTextPos = Middle.Translated(OrtVec);
75 }
7fd59977 76 else
b8ddfc2f 77 {
78 Standard_Real Rad = Max(FirstCenter.Distance( FirstPoint ), SecondCenter.Distance(SecondPoint));
7fd59977 79
b8ddfc2f 80 SmallDist = Rad *0.05; // take 1/20 part of length;
81 if (SmallDist <= Precision::Confusion())
82 SmallDist = Rad;
7fd59977 83
b8ddfc2f 84 gp_Vec aVec(SmallDist, SmallDist, SmallDist);
7fd59977 85
b8ddfc2f 86 //Compute the text position
87 aTextPos = FirstCenter.Translated(aVec);
88 }
7fd59977 89
90 //Draw the text
b8ddfc2f 91 Prs3d_Text::Draw(aPresentation, LA->TextAspect(),aText, aTextPos);
7fd59977 92//ota === end ===
93}