1 // File: DrawDim_Angle.cxx
2 // Created: Tue May 28 12:36:20 1996
3 // Author: Denis PASCAL
7 #include <DrawDim_Angle.ixx>
10 #include <BRepAdaptor_Surface.hxx>
11 #include <BRep_Tool.hxx>
20 #include <IntAna_QuadQuadGeo.hxx>
21 #include <Precision.hxx>
22 #include <TopExp_Explorer.hxx>
23 #include <TopoDS_Vertex.hxx>
24 #include <IntAna_QuadQuadGeo.hxx>
26 //=======================================================================
27 //function : DrawDim_Angle
29 //=======================================================================
31 DrawDim_Angle::DrawDim_Angle(const TopoDS_Face& plane1, const TopoDS_Face& plane2)
37 //=======================================================================
40 //=======================================================================
42 const TopoDS_Face& DrawDim_Angle::Plane1() const
47 //=======================================================================
50 //=======================================================================
52 void DrawDim_Angle::Plane1(const TopoDS_Face& plane)
57 //=======================================================================
60 //=======================================================================
62 const TopoDS_Face& DrawDim_Angle::Plane2() const
67 //=======================================================================
70 //=======================================================================
72 void DrawDim_Angle::Plane2(const TopoDS_Face& plane)
78 //=======================================================================
81 //=======================================================================
83 void DrawDim_Angle::DrawOn(Draw_Display& ) const
87 TopoDS_Shape myFShape = myPlane1;
88 TopoDS_Shape mySShape = myPlane2;
89 Standard_Real myVal = GetValue();
99 gp_Pnt myPosition(0.,0.,0.);
103 Standard_Boolean myAutomaticPosition = Standard_True;
107 // calculation of myAxis
109 if (!DrawDim::Pln(myPlane1,pln1)) return;
110 if (!DrawDim::Pln(myPlane2,pln2)) return;
111 IntAna_QuadQuadGeo ip (pln1,pln2,Precision::Confusion(), Precision::Angular());
112 if (!ip.IsDone()) return;
118 //Handle(Geom_Surface) curve1 = BRep_Tool::Surface(myPlane1);
119 //Handle(Geom_PlaneLine) line1 = Handle(Geom_Line)::DownCast(curve1);
123 //=======================================================================
124 //function : ComputeTwoFacesAngle
126 //=======================================================================
128 // void AIS_AngleDimension::ComputeTwoFacesAngle(const Handle(Prs3d_Presentation)& aPresentation)
133 gp_Ax1 AxePos = myAxis;
134 gp_Dir theAxisDir = AxePos.Direction();
135 gp_Lin theaxis= gp_Lin (myAxis);
137 if (myAutomaticPosition) {
138 TopExp_Explorer explo1(myFShape,TopAbs_VERTEX);
139 Standard_Real curdist = 0;
140 while (explo1.More()) {
141 TopoDS_Vertex vertref = TopoDS::Vertex(explo1.Current());
142 gp_Pnt curpt = BRep_Tool::Pnt(vertref);
143 if (theaxis.Distance(curpt) > curdist) {
144 curdist = theaxis.Distance(curpt);
145 myFAttach = BRep_Tool::Pnt(vertref);
149 curpos = myFAttach.Rotated(AxePos,myVal/2.);
150 myCenter = ElCLib::Value(ElCLib::Parameter(theaxis,curpos),theaxis);
151 Standard_Real thedista = myCenter.Distance(myFAttach);
152 if (thedista > Precision::Confusion()) {
153 curpos.Scale(myCenter,1.05);
156 myAutomaticPosition = Standard_True;
160 //myFAttach = the point of myFShape closest to curpos (except for the case when this is a point on the axis)
161 Standard_Real dist = RealLast();
162 TopExp_Explorer explo1(myFShape,TopAbs_VERTEX);
163 gp_Pnt AxePosition = AxePos.Location();
164 gp_Vec AxeVector (theAxisDir);
165 gp_XYZ AxeXYZ = AxeVector.XYZ();
166 while (explo1.More()) {
167 gp_Pnt curpt = BRep_Tool::Pnt(TopoDS::Vertex(explo1.Current()));
168 gp_Vec curvec (AxePosition, curpt);
169 gp_XYZ curXYZ = curvec.XYZ();
170 gp_XYZ Norm (curXYZ.Crossed(AxeXYZ));
172 Standard_Real NormMod =
175 if (Norm.Modulus() > gp::Resolution()) {
176 Standard_Real curdist = curpos.Distance (curpt);
177 if (curdist < dist) {
184 myCenter = ElCLib::Value(ElCLib::Parameter(theaxis,myFAttach),theaxis);
187 mySAttach = myFAttach.Rotated(AxePos,myVal);
189 gp_Vec FVec (myCenter, myFAttach);
190 myFDir.SetXYZ (FVec.XYZ());
191 gp_Vec SVec (myCenter, mySAttach);
192 mySDir.SetXYZ (SVec.XYZ());
194 if (!myAutomaticPosition) {
195 //Projection of the position on the plane defined by myFDir mySDir and normal theAxisDir
196 gp_Pln aPln (myCenter, theAxisDir);
198 ElSLib::Parameters (aPln, curpos, U, V);
199 curpos = ElSLib::Value (U, V, aPln);
203 // Add (myVal, myText,myCenter,myFAttach,mySAttach,myFDir,mySDir,theAxisDir,curpos)