1 // File: HLRBRep_PolyHLRToShape.cxx
2 // Created: Mon Oct 11 16:55:56 1993
3 // Author: Christophe MARION
4 // Copyright: OPEN CASCADE 2000
6 // Modified by cma, Fri Nov 10 17:36:13 1995
8 #include <HLRBRep_PolyHLRToShape.ixx>
9 #include <BRep_Builder.hxx>
10 #include <BRepLib_MakeEdge2d.hxx>
12 #include <TopExp_Explorer.hxx>
13 #include <TopTools_MapOfShape.hxx>
14 #include <HLRBRep_BiPnt2D.hxx>
15 #include <HLRBRep_ListIteratorOfListOfBPnt2D.hxx>
16 #include <HLRAlgo_EdgeStatus.hxx>
17 #include <HLRAlgo_EdgeIterator.hxx>
19 #define PntX1 ((Standard_Real*)Coordinates)[0]
20 #define PntY1 ((Standard_Real*)Coordinates)[1]
21 #define PntZ1 ((Standard_Real*)Coordinates)[2]
22 #define PntX2 ((Standard_Real*)Coordinates)[3]
23 #define PntY2 ((Standard_Real*)Coordinates)[4]
24 #define PntZ2 ((Standard_Real*)Coordinates)[5]
26 //=======================================================================
27 //function : HLRBRep_PolyHLRToShape
29 //=======================================================================
31 HLRBRep_PolyHLRToShape::HLRBRep_PolyHLRToShape ()
34 //=======================================================================
37 //=======================================================================
39 void HLRBRep_PolyHLRToShape::Update (const Handle(HLRBRep_PolyAlgo)& A)
42 myHideMode = Standard_True;
43 Standard_Real sta,end,XSta,YSta,ZSta,XEnd,YEnd,ZEnd,dx,dy;
44 Standard_ShortReal tolsta,tolend;
45 HLRAlgo_EdgeIterator It;
49 Standard_Boolean reg1,regn,outl,intl;
50 const gp_Trsf& T = myAlgo->Projector().Transformation();
51 HLRAlgo_EdgeStatus status;
52 Standard_Address Coordinates;
54 for (myAlgo->InitHide(); myAlgo->MoreHide(); myAlgo->NextHide()) {
55 myAlgo->Hide(Coordinates,status,S,reg1,regn,outl,intl);
62 T.Transforms(XSta,YSta,ZSta);
63 T.Transforms(XEnd,YEnd,ZEnd);
66 if (sqrt(dx * dx + dy * dy) > 1.e-10) {
68 for (It.InitVisible(status);
71 It.Visible(sta,tolsta,end,tolend);
74 (XSta + sta * dx,YSta + sta * dy,
75 XSta + end * dx,YSta + end * dy,
76 S,reg1,regn,outl,intl));
79 for (It.InitHidden(status);
82 It.Hidden(sta,tolsta,end,tolend);
85 (XSta + sta * dx,YSta + sta * dy,
86 XSta + end * dx,YSta + end * dy,
87 S,reg1,regn,outl,intl));
93 //=======================================================================
94 //function : InternalCompound
96 //=======================================================================
99 HLRBRep_PolyHLRToShape::InternalCompound (const Standard_Integer typ,
100 const Standard_Boolean visible,
101 const TopoDS_Shape& S)
103 TopTools_MapOfShape Map;
106 for (ex.Init(S,TopAbs_EDGE); ex.More(); ex.Next())
107 Map.Add(ex.Current());
108 for (ex.Init(S,TopAbs_FACE); ex.More(); ex.Next())
109 Map.Add(ex.Current());
111 Standard_Boolean todraw,reg1,regn,outl,intl;
112 Standard_Boolean added = Standard_False;
115 B.MakeCompound(TopoDS::Compound(Result));
118 HLRBRep_ListIteratorOfListOfBPnt2D It;
119 if (visible) It.Initialize(myBiPntVis);
120 else It.Initialize(myBiPntHid);
122 for (; It.More(); It.Next()) {
123 const HLRBRep_BiPnt2D& BP = It.Value();
128 if (typ == 1) todraw = intl;
129 else if (typ == 2) todraw = reg1 && !regn && !outl;
130 else if (typ == 3) todraw = regn && !outl;
131 else todraw = !(intl || (reg1 && !outl));
133 if (!S.IsNull()) todraw = Map.Contains(BP.Shape());
135 B.Add(Result,BRepLib_MakeEdge2d(BP.P1(),BP.P2()));
136 added = Standard_True;
141 const gp_Trsf& T = myAlgo->Projector().Transformation();
143 Standard_Real XSta,YSta,ZSta,XEnd,YEnd,ZEnd,dx,dy;
144 Standard_Address Coordinates;
146 for (myAlgo->InitShow(); myAlgo->MoreShow(); myAlgo->NextShow()) {
147 myAlgo->Show(Coordinates,SBP,reg1,regn,outl,intl);
148 if (typ == 1) todraw = intl;
149 else if (typ == 2) todraw = reg1 && !regn && !outl;
150 else if (typ == 3) todraw = regn && !outl;
151 else todraw = !(intl || (reg1 && !outl));
153 if (!S.IsNull()) todraw = Map.Contains(SBP);
161 T.Transforms(XSta,YSta,ZSta);
162 T.Transforms(XEnd,YEnd,ZEnd);
165 if (sqrt(dx * dx + dy * dy) > 1.e-10) {
166 B.Add(Result,BRepLib_MakeEdge2d(gp_Pnt2d(XSta,YSta),
167 gp_Pnt2d(XEnd,YEnd)));
168 added = Standard_True;
173 if (!added) Result = TopoDS_Shape();