3 #include "ISession2D_Shape.h"
4 #include <TopTools_ListIteratorOfListOfShape.hxx>
5 #include <HLRBRep_PolyHLRToShape.hxx>
6 #include <HLRBRep_HLRToShape.hxx>
9 IMPLEMENT_STANDARD_RTTIEXT(ISession2D_Shape,AIS_InteractiveObject)
11 ISession2D_Shape::ISession2D_Shape ()
12 :AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependent)
15 void ISession2D_Shape::Add(const TopoDS_Shape& aShape)
17 myListOfShape.Append(aShape);
21 UpdatePresentations();
24 void ISession2D_Shape::Remove (const TopoDS_Shape& theShape)
26 if (myListOfShape.Size() == 0)
31 for (NCollection_List<TopoDS_Shape>::Iterator anIt (myListOfShape); anIt.More(); anIt.Next())
33 if (anIt.Value() == theShape)
35 myListOfShape.Remove (anIt);
41 void ISession2D_Shape::SetProjector (HLRAlgo_Projector& aProjector)
43 myProjector= aProjector;
47 UpdatePresentations();
51 void ISession2D_Shape::SetNbIsos(Standard_Integer& aNbIsos)
56 UpdatePresentations();
59 void ISession2D_Shape::BuildAlgo()
61 myAlgo = new HLRBRep_Algo();
62 NCollection_List<TopoDS_Shape>::Iterator anIterator(myListOfShape);
63 for (;anIterator.More();anIterator.Next()) myAlgo->Add(anIterator.Value(),myNbIsos);
64 myAlgo->Projector(myProjector);
69 void ISession2D_Shape::BuildPolyAlgo()
71 myPolyAlgo = new HLRBRep_PolyAlgo();
72 NCollection_List<TopoDS_Shape>::Iterator anIterator(myListOfShape);
73 for (;anIterator.More();anIterator.Next()) myPolyAlgo->Load(anIterator.Value());
74 myPolyAlgo->Projector(myProjector);
78 void ISession2D_Shape::Compute(const Handle(PrsMgr_PresentationManager)& /*thePresentationManager*/,
79 const Handle(Prs3d_Presentation)& thePresentation,
80 const Standard_Integer theMode)
83 Standard_Integer aMode = theMode;
84 Standard_Boolean DrawHiddenLine= Standard_True;
85 thePresentation->Clear();
88 DrawHiddenLine = Standard_False;
92 Standard_Boolean UsePolyAlgo= Standard_True;
95 UsePolyAlgo = Standard_False;
98 TopoDS_Shape VCompound;
99 TopoDS_Shape Rg1LineVCompound;
100 TopoDS_Shape RgNLineVCompound;
101 TopoDS_Shape OutLineVCompound;
102 TopoDS_Shape IsoLineVCompound; // only for Exact algo
103 TopoDS_Shape HCompound;
104 TopoDS_Shape Rg1LineHCompound;
105 TopoDS_Shape RgNLineHCompound;
106 TopoDS_Shape OutLineHCompound;
107 TopoDS_Shape IsoLineHCompound; // only for Exact algo
111 if (myPolyAlgo.IsNull()) BuildPolyAlgo();
112 HLRBRep_PolyHLRToShape aPolyHLRToShape;
113 aPolyHLRToShape.Update(myPolyAlgo);
115 VCompound = aPolyHLRToShape.VCompound();
116 Rg1LineVCompound = aPolyHLRToShape.Rg1LineVCompound();
117 RgNLineVCompound = aPolyHLRToShape.RgNLineVCompound();
118 OutLineVCompound = aPolyHLRToShape.OutLineVCompound();
119 HCompound = aPolyHLRToShape.HCompound();
120 Rg1LineHCompound = aPolyHLRToShape.Rg1LineHCompound();
121 RgNLineHCompound = aPolyHLRToShape.RgNLineHCompound();
122 OutLineHCompound = aPolyHLRToShape.OutLineHCompound();
126 if (myAlgo.IsNull()) BuildAlgo();
127 HLRBRep_HLRToShape aHLRToShape(myAlgo);
129 VCompound = aHLRToShape.VCompound();
130 Rg1LineVCompound = aHLRToShape.Rg1LineVCompound();
131 RgNLineVCompound = aHLRToShape.RgNLineVCompound();
132 OutLineVCompound = aHLRToShape.OutLineVCompound();
133 IsoLineVCompound = aHLRToShape.IsoLineVCompound();
134 HCompound = aHLRToShape.HCompound();
135 Rg1LineHCompound = aHLRToShape.Rg1LineHCompound();
136 RgNLineHCompound = aHLRToShape.RgNLineHCompound();
137 OutLineHCompound = aHLRToShape.OutLineHCompound();
138 IsoLineHCompound = aHLRToShape.IsoLineHCompound();
143 Handle(Prs3d_LineAspect) aLineAspectHighlighted = new Prs3d_LineAspect(Quantity_NOC_ALICEBLUE,
144 Aspect_TOL_DOTDASH,1);
145 Handle(Prs3d_LineAspect) aLineAspect = new Prs3d_LineAspect(Quantity_NOC_WHITE,
153 DrawCompound(thePresentation, VCompound, aLineAspectHighlighted);
158 DrawCompound(thePresentation, Rg1LineVCompound, aLineAspectHighlighted);
163 DrawCompound(thePresentation, RgNLineVCompound, aLineAspectHighlighted);
168 DrawCompound(thePresentation, OutLineVCompound, aLineAspectHighlighted);
173 DrawCompound(thePresentation,VCompound, aLineAspect);
174 DrawCompound(thePresentation,Rg1LineVCompound, aLineAspect);
175 DrawCompound(thePresentation,RgNLineVCompound, aLineAspect);
176 DrawCompound(thePresentation,OutLineVCompound, aLineAspect);
182 Handle(Prs3d_LineAspect) aLineAspectHighlightedHLR = new Prs3d_LineAspect(Quantity_NOC_RED,
183 Aspect_TOL_DOTDASH,2);
184 Handle(Prs3d_LineAspect) aLineAspectHLR = new Prs3d_LineAspect(Quantity_NOC_BLUE1,
185 Aspect_TOL_DOTDASH,1);
191 DrawCompound(thePresentation, HCompound, aLineAspectHighlightedHLR);
196 DrawCompound(thePresentation, Rg1LineHCompound, aLineAspectHighlightedHLR);
201 DrawCompound(thePresentation, RgNLineHCompound, aLineAspectHighlightedHLR);
206 DrawCompound(thePresentation, OutLineHCompound, aLineAspectHighlightedHLR);
211 DrawCompound(thePresentation, HCompound, aLineAspectHLR);
212 DrawCompound(thePresentation, Rg1LineHCompound, aLineAspectHLR);
213 DrawCompound(thePresentation, RgNLineHCompound, aLineAspectHLR);
214 DrawCompound(thePresentation, OutLineHCompound, aLineAspectHLR);
221 Handle(Prs3d_LineAspect) aLineAspectHighlighted = new Prs3d_LineAspect(Quantity_NOC_RED,
223 Handle(Prs3d_LineAspect) aLineAspect = new Prs3d_LineAspect(Quantity_NOC_WHITE,
230 DrawCompound(thePresentation, VCompound, aLineAspectHighlighted);
235 DrawCompound(thePresentation, Rg1LineVCompound, aLineAspectHighlighted);
240 DrawCompound(thePresentation, RgNLineVCompound, aLineAspectHighlighted);
245 DrawCompound(thePresentation, OutLineVCompound, aLineAspectHighlighted);
250 DrawCompound(thePresentation, IsoLineVCompound, aLineAspectHighlighted);
255 DrawCompound(thePresentation, VCompound, aLineAspect);
256 DrawCompound(thePresentation, Rg1LineVCompound, aLineAspect);
257 DrawCompound(thePresentation, RgNLineVCompound, aLineAspect);
258 DrawCompound(thePresentation, OutLineVCompound, aLineAspect);
259 DrawCompound(thePresentation, IsoLineVCompound , aLineAspect);
265 Handle(Prs3d_LineAspect) aLineAspectHighlightedHLR = new Prs3d_LineAspect(Quantity_NOC_RED,
272 DrawCompound(thePresentation, HCompound, aLineAspectHighlightedHLR);
277 DrawCompound(thePresentation, Rg1LineHCompound, aLineAspectHighlightedHLR);
282 DrawCompound(thePresentation, RgNLineHCompound, aLineAspectHighlightedHLR);
287 DrawCompound(thePresentation, OutLineHCompound, aLineAspectHighlightedHLR);
292 DrawCompound(thePresentation, IsoLineHCompound, aLineAspectHighlightedHLR);
297 Handle(Prs3d_LineAspect) aLineAspectHLR =
298 new Prs3d_LineAspect(Quantity_NOC_ALICEBLUE, Aspect_TOL_DOT, 1);
299 DrawCompound(thePresentation, HCompound, aLineAspectHLR);
300 DrawCompound(thePresentation, Rg1LineHCompound, aLineAspectHLR);
301 DrawCompound(thePresentation, RgNLineHCompound, aLineAspectHLR);
302 DrawCompound(thePresentation, OutLineHCompound, aLineAspectHLR);
303 DrawCompound(thePresentation, IsoLineHCompound, aLineAspectHLR);
310 void ISession2D_Shape::DrawCompound(const Handle(Prs3d_Presentation)& thePresentation,
311 const TopoDS_Shape& theCompound,
312 const Handle(Prs3d_LineAspect) theAspect)
314 if (theCompound.IsNull())
316 myDrawer->SetWireAspect(theAspect);
317 StdPrs_WFShape::Add(thePresentation,TopoDS_Shape(theCompound),myDrawer);
320 void ISession2D_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSelection*/,
321 const Standard_Integer /*aMode*/)