1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
19 #include <gp_GTrsf.hxx>
22 #include <IGESData_IGESEntity.hxx>
23 #include <IGESGeom_Plane.hxx>
24 #include <Standard_Type.hxx>
26 IMPLEMENT_STANDARD_RTTIEXT(IGESGeom_Plane,IGESData_IGESEntity)
28 IGESGeom_Plane::IGESGeom_Plane () { }
31 void IGESGeom_Plane::Init
32 (const Standard_Real A, const Standard_Real B,
33 const Standard_Real C, const Standard_Real D,
34 const Handle(IGESData_IGESEntity)& aCurve,
35 const gp_XYZ& attach, const Standard_Real aSize)
44 InitTypeAndForm(108,FormNumber());
45 // FormNumber : 0 No Curve. +1 Bound. -1 Hole
48 void IGESGeom_Plane::SetFormNumber (const Standard_Integer form)
50 Standard_Integer fn = 0;
51 if (form < 0) fn = -1;
53 InitTypeAndForm(108,fn);
56 void IGESGeom_Plane::Equation
57 (Standard_Real& A, Standard_Real& B, Standard_Real& C, Standard_Real& D) const
65 Standard_Boolean IGESGeom_Plane::HasBoundingCurve () const
67 return (!theCurve.IsNull());
70 Standard_Boolean IGESGeom_Plane::HasBoundingCurveHole () const
72 return ((FormNumber() == -1) && (!theCurve.IsNull()));
75 Handle(IGESData_IGESEntity) IGESGeom_Plane::BoundingCurve () const
80 Standard_Boolean IGESGeom_Plane::HasSymbolAttach () const
85 gp_Pnt IGESGeom_Plane::SymbolAttach () const
87 gp_Pnt attach(theAttach);
91 gp_Pnt IGESGeom_Plane::TransformedSymbolAttach () const
93 if (theSize > 0 && HasTransf())
95 gp_XYZ Symbol = theAttach;
96 Location().Transforms(Symbol);
97 return gp_Pnt(Symbol);
99 else return gp_Pnt(0, 0, 0);
102 Standard_Real IGESGeom_Plane::SymbolSize () const
107 void IGESGeom_Plane::TransformedEquation
108 (Standard_Real& A, Standard_Real& B, Standard_Real& C, Standard_Real& D) const
110 //eqn of plane AX + BY + CZ = D
112 Standard_Real x1,y1,z1,x2,y2,z2,x3,y3,z3;
114 //case 1 intersection of the plane with the XY plane.
119 //case 2 intersection of the plane with the XZ plane.
124 //case 3 intersection of the plane with the YZ plane.
131 Location().Transforms(P1);
132 Location().Transforms(P2);
133 Location().Transforms(P3);
145 General eqn of plane can also be written as
146 a(x1 -x2) + b(y1 - y2) + c(z1 - z2) = 0
147 a(x3 - x2) + b(y3 - y2) + c(z3 -z2) = 0
148 Applying Cramer's Rule :
150 ------------- = --------------- = --------------- = k
151 |y3-y2 z3-z2| |z3-z2 x3-x2| |x3-x2 y3-y2|
152 |y1-y2 z1-z2| |z1-z2 x1-x2| |x1-x2 y1-y2|
155 . . a = c1*k , b = c2*k , c = c3*k
156 hence c1(x - x2) + c2(y - y2) + c3(z - z2) = 0
159 Standard_Real c1,c2,c3;
161 c1 = (y1*(-z3 + z2) + y2*(-z1 + z3) + y3*(z1 - z2));
162 c2 = (x1*(z3 - z2) + x2*(-z3 + z1) + x3*(-z1 + z2));
163 c3 = (x1*(-y3 + y2) + x2*(-y1 + y3) + x3*(y1 - y2));
168 D = c1*x2 + c2*y2 + c3*z3;