0030895: Coding Rules - specify std namespace explicitly for std::cout and streams
[occt.git] / src / TopOpeBRep / TopOpeBRep_Point2d.cxx
1 // Created on: 1998-10-29
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifdef DRAW
18 #include <TopOpeBRepTool_DRAW.hxx>
19 #endif
20
21
22 #include <BRep_Tool.hxx>
23 #include <gp_Pnt.hxx>
24 #include <gp_Pnt2d.hxx>
25 #include <IntRes2d_IntersectionPoint.hxx>
26 #include <TopoDS_Vertex.hxx>
27 #include <TopOpeBRep_define.hxx>
28 #include <TopOpeBRep_EdgesIntersector.hxx>
29 #include <TopOpeBRep_Hctxee2d.hxx>
30 #include <TopOpeBRep_Hctxff2d.hxx>
31 #include <TopOpeBRep_Point2d.hxx>
32 #include <TopOpeBRepDS.hxx>
33 #include <TopOpeBRepDS_Transition.hxx>
34
35 //=======================================================================
36 //function : TopOpeBRep_Point2d
37 //purpose  : 
38 //=======================================================================
39 TopOpeBRep_Point2d::TopOpeBRep_Point2d() :
40 myhaspint(Standard_False),
41 myisvertex1(Standard_False),
42 myparameter1(0.),
43 myisvertex2(Standard_False),
44 myparameter2(0.),
45 myispointofsegment(Standard_False),
46 myips1(0),myips2(0),myhasancestors(Standard_False),
47 mystatus(TopOpeBRep_P2DUNK),
48 myindex(0),
49 mykeep(Standard_True),
50 myedgesconfig(TopOpeBRepDS_UNSHGEOMETRY),
51 mytolerance(0.)
52 {
53 }
54
55 //=======================================================================
56 //function : Vertex
57 //purpose  : 
58 //=======================================================================
59 const TopoDS_Vertex& TopOpeBRep_Point2d::Vertex(const Standard_Integer Index) const
60 {
61   if (!IsVertex(Index)) throw Standard_Failure("TopOpeBRep_Point2d::Vertex");
62   if      (Index == 1) return myvertex1;
63   else if (Index == 2) return myvertex2;
64   else throw Standard_Failure("TopOpeBRep_Point2d::Vertex");
65 }
66
67 //=======================================================================
68 //function : Transition
69 //purpose  : 
70 //=======================================================================
71 const TopOpeBRepDS_Transition& TopOpeBRep_Point2d::Transition(const Standard_Integer Index) const
72 {
73   if      (Index == 1) return mytransition1;
74   else if (Index == 2) return mytransition2;
75   else throw Standard_Failure("TopOpeBRep_Point2d::Transition");
76 }
77
78 //=======================================================================
79 //function : ChangeTransition
80 //purpose  : 
81 //=======================================================================
82 TopOpeBRepDS_Transition& TopOpeBRep_Point2d::ChangeTransition(const Standard_Integer Index)
83 {
84   if      (Index == 1) return mytransition1;
85   else if (Index == 2) return mytransition2;
86   else throw Standard_Failure("TopOpeBRep_Point2d::ChangeTransition");
87 }
88
89 //=======================================================================
90 //function : Dump
91 //purpose  : 
92 //=======================================================================
93 #ifdef OCCT_DEBUG
94 void TopOpeBRep_Point2d::Dump(const Standard_Integer E1index,const Standard_Integer E2index) const
95 {
96   Standard_Real par1 = Parameter(1);
97   Standard_Real par2 = Parameter(2);
98   
99   Standard_Integer index = Index();
100   Standard_Boolean keep = Keep();
101   Standard_Integer sts = Status();
102   Standard_Boolean pos = IsPointOfSegment();
103
104   Standard_Boolean isvertex1 = IsVertex(1); TopoDS_Vertex V1; if (isvertex1) V1 = Vertex(1);
105   Standard_Boolean isvertex2 = IsVertex(2); TopoDS_Vertex V2; if (isvertex2) V2 = Vertex(2);
106
107   Standard_Integer ia1,ia2; SegmentAncestors(ia1,ia2);
108   std::cout<<std::endl<<"p2d "<<index<<"  k="<<keep<<" pos="<<pos;
109   switch (sts) {
110   case TopOpeBRep_P2DUNK : std::cout<<" sts=u";break;
111   case TopOpeBRep_P2DSGF : std::cout<<" sts=f";break;
112   case TopOpeBRep_P2DSGL : std::cout<<" sts=l";break;
113   case TopOpeBRep_P2DNEW :
114     std::cout<<" sts=n";
115     std::cout<<" anc="<<ia1<<","<<ia2;
116     break;
117   case TopOpeBRep_P2DINT : std::cout<<" sts=i";break;
118   } // switch
119   std::cout<<" cfg=";TopOpeBRepDS::Print(myedgesconfig,std::cout);
120   std::cout<<std::endl;
121   
122   gp_Pnt P3D = Value();
123 #ifdef DRAW
124   std::cout<<FUN_tool_PRODINP()<<"P"<<Index()<<" "<<P3D.X()<<" "<<P3D.Y()<<" "<<P3D.Z()<<"; # tol = "<<tol<<std::endl;
125 #endif
126   std::cout<<"     on (1) :";
127   std::cout<<" vertex(1) : ";
128   std::cout<<(isvertex1?1:0);
129   std::cout<<"  T "<<E1index<<"(1)";
130   std::cout<<" par(1) = "<<par1;
131   if (isvertex1) {
132     P3D = BRep_Tool::Pnt(V1);
133     std::cout<<" PV(1) : "<<P3D.X()<<" "<<P3D.Y()<<" "<<P3D.Z();
134   }
135   std::cout<<std::endl;
136   
137   std::cout<<"     on (2) :";
138   std::cout<<" vertex(2) : ";
139   std::cout<<(isvertex2?1:0);
140   std::cout<<"  T "<<E2index<<"(2)";
141   std::cout<<" par(2) = "<<par2;
142   if (isvertex2) {
143     P3D = BRep_Tool::Pnt(V2);
144     std::cout<<" PV(2) : "<<P3D.X()<<" "<<P3D.Y()<<" "<<P3D.Z();
145   }
146   std::cout<<std::endl;
147 }
148 #else
149 void TopOpeBRep_Point2d::Dump(const Standard_Integer,const Standard_Integer) const {}
150 #endif