1 // Created on: 1991-07-04
2 // Created by: Christophe MARION
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Adaptor3d_HCurve.hxx>
19 #include <BRep_Tool.hxx>
20 #include <BRepAdaptor_Curve.hxx>
21 #include <BRepAdaptor_Surface.hxx>
22 #include <BRepMesh_IncrementalMesh.hxx>
23 #include <BRepTools.hxx>
24 #include <DBRep_DrawableShape.hxx>
25 #include <DBRep_Edge.hxx>
26 #include <DBRep_Face.hxx>
27 #include <DBRep_HideData.hxx>
28 #include <DBRep_IsoBuilder.hxx>
29 #include <DBRep_ListIteratorOfListOfEdge.hxx>
30 #include <DBRep_ListIteratorOfListOfFace.hxx>
31 #include <DBRep_ListIteratorOfListOfHideData.hxx>
32 #include <Draw_Appli.hxx>
33 #include <Draw_Color.hxx>
34 #include <Draw_Display.hxx>
35 #include <Draw_Drawable3D.hxx>
36 #include <Geom_BSplineCurve.hxx>
37 #include <Geom_BSplineSurface.hxx>
38 #include <GeomAdaptor_HSurface.hxx>
39 #include <GeomAdaptor_Surface.hxx>
40 #include <gp_Lin2d.hxx>
41 #include <gp_Trsf.hxx>
42 #include <HLRBRep.hxx>
43 #include <Poly_Connect.hxx>
44 #include <Poly_Polygon3D.hxx>
45 #include <Poly_PolygonOnTriangulation.hxx>
46 #include <Poly_Triangulation.hxx>
47 #include <Precision.hxx>
48 #include <Standard_DomainError.hxx>
49 #include <Standard_Type.hxx>
50 #include <TColgp_HArray1OfPnt.hxx>
51 #include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
52 #include <TColStd_DataMapOfIntegerInteger.hxx>
53 #include <TColStd_HArray1OfInteger.hxx>
55 #include <TopExp_Explorer.hxx>
57 #include <TopoDS_Edge.hxx>
58 #include <TopoDS_Face.hxx>
59 #include <TopoDS_Shape.hxx>
60 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
61 #include <TopTools_ListOfShape.hxx>
63 static Standard_Real IsoRatio = 1.001;
65 static Standard_Integer MaxPlotCount = 5; // To avoid huge recursive calls in
66 static Standard_Integer PlotCount = 0; // PlotEdge and PlotIso for cases of "bad"
67 // curves and surfaces
68 // Set PlotCount = 0 before first call of
69 // PlotEdge or PlotIso
70 static TopoDS_Shape pickshape;
71 static Standard_Real upick,vpick;
73 extern Draw_Viewer dout;
76 //=======================================================================
77 //function : DBRep_DrawableShape
78 //purpose : constructor
79 //=======================================================================
81 DBRep_DrawableShape::DBRep_DrawableShape
82 (const TopoDS_Shape& aShape,
83 const Draw_Color& FreeCol,
84 const Draw_Color& ConnCol,
85 const Draw_Color& EdgeCol,
86 const Draw_Color& IsosCol,
87 const Standard_Real size,
88 const Standard_Integer nbisos,
89 const Standard_Integer discret) :
97 myDispOr(Standard_False),
98 mytriangulations(Standard_False),
99 mypolygons(Standard_False),
100 myHLR(Standard_False),
101 myRg1(Standard_False),
102 myRgN(Standard_False),
103 myHid(Standard_False)
108 //=======================================================================
111 //=======================================================================
113 void DBRep_DrawableShape::Set(const TopoDS_Shape& aShape)
120 if (myShape.IsNull())
123 //==============================================================
125 //==============================================================
127 TopExp_Explorer ExpFace;
130 for (ExpFace.Init (myShape,TopAbs_FACE);
133 TopoDS_Face TopologicalFace = TopoDS::Face (ExpFace.Current());
135 const Handle(Geom_Surface)& S =
136 BRep_Tool::Surface(TopologicalFace,l);
138 TopologicalFace.Orientation (TopAbs_FORWARD) ;
139 DBRep_IsoBuilder IsoBuild (TopologicalFace, mySize, myNbIsos) ;
140 myFaces.Append(new DBRep_Face (TopologicalFace,
141 IsoBuild.NbDomains(),
143 IsoBuild.LoadIsos (myFaces.Last()) ;
145 else myFaces.Append(new DBRep_Face(TopologicalFace,0, myEdgeCol));
147 else myFaces.Append(new DBRep_Face(TopologicalFace,0, myEdgeCol));
150 //==============================================================
152 //==============================================================
154 TopTools_IndexedDataMapOfShapeListOfShape edgemap;
155 TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_FACE,edgemap);
156 Standard_Integer iedge;
158 for (iedge = 1; iedge <= edgemap.Extent(); iedge++) {
160 const TopoDS_Edge& theEdge = TopoDS::Edge(edgemap.FindKey(iedge));
162 // skip degenerated edges
163 if (BRep_Tool::Degenerated(theEdge)) continue;
165 // compute the number of faces
166 Standard_Integer nbf = edgemap(iedge).Extent();
168 Draw_Color EdgeColor;
173 EdgeColor = myEdgeCol; // isolated edge
177 EdgeColor = myFreeCol; // edge in only one face
181 EdgeColor = myConnCol; // edge shared by at least two faces
184 myEdges.Append(new DBRep_Edge (theEdge,EdgeColor));
189 //=======================================================================
190 //function : ChangeNbIsos
191 //purpose : Changes the number of isoparametric curves in a shape.
192 //=======================================================================
194 void DBRep_DrawableShape::ChangeNbIsos (const Standard_Integer NbIsos)
198 TopExp_Explorer ExpFace;
201 for (ExpFace.Init (myShape, TopAbs_FACE);
204 TopoDS_Face TopologicalFace = TopoDS::Face (ExpFace.Current());
205 const Handle(Geom_Surface)& S =
206 BRep_Tool::Surface(TopologicalFace,l);
209 TopologicalFace.Orientation (TopAbs_FORWARD) ;
210 DBRep_IsoBuilder IsoBuild (TopologicalFace, mySize, myNbIsos) ;
213 (TopologicalFace, IsoBuild.NbDomains(), myIsosCol)) ;
214 IsoBuild.LoadIsos (myFaces.Last()) ;
216 else myFaces.Append(new DBRep_Face(TopologicalFace,0, myEdgeCol));
218 else myFaces.Append(new DBRep_Face(TopologicalFace,0, myEdgeCol));
222 //=======================================================================
224 // Purpose : Returns the number of isoparametric curves in a shape.
225 //=======================================================================
227 Standard_Integer DBRep_DrawableShape::NbIsos () const
232 //=======================================================================
233 // Function : Discret
235 //=======================================================================
237 Standard_Integer DBRep_DrawableShape::Discret () const
242 Standard_EXPORT Draw_Color DBRep_ColorOrientation (const TopAbs_Orientation Or);
245 static void PlotIso (Draw_Display& dis,
246 Handle(DBRep_Face)& F,
247 BRepAdaptor_Surface& S,
252 Standard_Boolean& halt)
259 if (T == GeomAbs_IsoU) {
261 S.D0(U, V + Step/2., Pm);
262 S.D0(U, V + Step, Pr);
265 S.D0(U + Step/2., V, Pm);
266 S.D0(U + Step, V, Pr);
269 if (PlotCount > MaxPlotCount) {
271 if (dis.HasPicked()) {
272 pickshape = F->Face();
273 upick = (T == GeomAbs_IsoU) ? U : U + Step;
274 vpick = (T == GeomAbs_IsoU) ? V + Step : V;
275 halt = Standard_True;
280 if (Pm.Distance(Pl) + Pm.Distance(Pr) <= IsoRatio*Pl.Distance(Pr)) {
282 if (dis.HasPicked()) {
283 pickshape = F->Face();
284 upick = (T == GeomAbs_IsoU) ? U : U + Step;
285 vpick = (T == GeomAbs_IsoU) ? V + Step : V;
286 halt = Standard_True;
289 if (T == GeomAbs_IsoU) {
290 PlotIso (dis, F, S, T, U, V, Step/2, halt);
291 Standard_Real aLocalV = V + Step/2 ;
292 PlotIso (dis, F, S, T, U, aLocalV , Step/2, halt);
294 PlotIso (dis, F, S, T, U, V, Step/2, halt);
295 Standard_Real aLocalU = U + Step/2 ;
296 PlotIso (dis, F, S, T, aLocalU , V, Step/2, halt);
301 static void PlotEdge (Draw_Display& dis,
302 Handle(DBRep_Edge)& E,
303 const Adaptor3d_Curve& C,
306 Standard_Boolean& halt)
314 C.D0(f + step/2., Pm);
317 if (PlotCount > MaxPlotCount) {
319 if (dis.HasPicked()) {
320 pickshape = E->Edge();
323 halt = Standard_True;
329 if (Pm.Distance(Pl) + Pm.Distance(Pr) <= IsoRatio*Pl.Distance(Pr)) {
331 if (dis.HasPicked()) {
332 pickshape = E->Edge();
335 halt = Standard_True;
338 PlotEdge (dis, E, C, f, step/2, halt);
339 Standard_Real aLocalF = f + step/2 ;
340 PlotEdge (dis, E, C, aLocalF , step/2, halt);
344 //=======================================================================
347 //=======================================================================
349 void DBRep_DrawableShape::DrawOn(Draw_Display& dis) const
351 Standard_Boolean halt = Standard_False;
353 if (myShape.IsNull()) {
354 dis.SetColor(myConnCol);
355 dis.DrawString(gp_Pnt(0,0,0),"Null Shape");
361 DBRep_DrawableShape* p = (DBRep_DrawableShape*) this;
362 p->DisplayHiddenLines(dis);
367 Standard_Real Par,T1,T2;
368 Standard_Real U1,U2,V1,V2,stepU=0.,stepV=0.;
371 Standard_Integer i,j;
374 Handle(Poly_Triangulation) Tr;
375 TopLoc_Location aTempLoc;
378 DBRep_ListIteratorOfListOfFace itf(myFaces);
380 while (itf.More() && !halt) {
382 const Handle(DBRep_Face)& F = itf.Value();
383 dis.SetColor(F->Color());
385 Handle(Geom_Surface) aSurf = BRep_Tool::Surface(F->Face(), aTempLoc);
387 if (!aSurf.IsNull()) {
389 Standard_Boolean restriction = Standard_False;
390 if(aSurf->IsUPeriodic() || aSurf->IsVPeriodic()) {
391 Standard_Real SU1 = 0., SU2 = 0., SV1 = 0., SV2 = 0.;
392 Standard_Real FU1 = 0., FU2 = 0., FV1 = 0., FV2 = 0.;
393 aSurf->Bounds(SU1,SU2,SV1,SV2);
394 BRepTools::UVBounds (F->Face(),FU1,FU2,FV1,FV2);
395 if(aSurf->IsUPeriodic()) {
396 if(FU1 < SU1 || FU1 > SU2)
397 restriction = Standard_True;
398 if(!restriction && (FU2 < SU1 || FU2 > SU2))
399 restriction = Standard_True;
401 if(!restriction && aSurf->IsVPeriodic()) {
402 if(FV1 < SV1 || FV1 > SV2)
403 restriction = Standard_True;
404 if(!restriction && (FV2 < SV1 || FV2 > SV2))
405 restriction = Standard_True;
407 Standard_Boolean zeroS = (fabs(SU2-SU1) <= 1.e-9 || fabs(SV2-SV1) <= 1.e-9);
408 Standard_Boolean zeroF = (fabs(FU2-FU1) <= 1.e-9 || fabs(FV2-FV1) <= 1.e-9);
409 if(restriction && (zeroS || zeroF))
410 restriction = Standard_False;
411 if(restriction && (FU1 >= FU2 || FV1 >= FV2))
412 restriction = Standard_False;
413 if(restriction && (fabs(FU2-FU1) > 4.1e+100 || fabs(FV2-FV1) > 4.1e+100))
414 restriction = Standard_False;
417 BRepAdaptor_Surface S(F->Face(),restriction);
419 //BRepAdaptor_Surface S(F->Face(),Standard_False);
421 GeomAbs_SurfaceType SurfType = S.GetType();
423 // If the type of the surface is GeomAbs_SurfaceOfExtrusion or GeomAbs_SurfaceOfRevolution
425 GeomAbs_CurveType CurvType;
427 GeomAbs_CurveType CurvType = GeomAbs_OtherCurve;
430 Standard_Integer N = F->NbIsos();
432 Standard_Integer Intrv, nbIntv;
433 Standard_Integer nbUIntv = S.NbUIntervals(GeomAbs_CN);
434 Standard_Integer nbVIntv = S.NbVIntervals(GeomAbs_CN);
435 TColStd_Array1OfReal TI(1,Max(nbUIntv, nbVIntv)+1);
437 for (i = 1; i <= N; i++) {
439 F->GetIso(i,T,Par,T1,T2);
440 if (T == GeomAbs_IsoU) {
441 S.VIntervals(TI, GeomAbs_CN);
450 S.UIntervals(TI, GeomAbs_CN);
462 for (Intrv = 1; Intrv <= nbIntv; Intrv++) {
464 if (TI(Intrv) <= T1 && TI(Intrv + 1) <= T1)
466 if (TI(Intrv) >= T2 && TI(Intrv + 1) >= T2)
468 if (T == GeomAbs_IsoU) {
469 V1 = Max(T1, TI(Intrv));
470 V2 = Min(T2, TI(Intrv + 1));
471 stepV = (V2 - V1) / myDiscret;
474 U1 = Max(T1, TI(Intrv));
475 U2 = Min(T2, TI(Intrv + 1));
476 stepU = (U2 - U1) / myDiscret;
480 //-------------GeomAbs_Plane---------------
483 //----GeomAbs_Cylinder GeomAbs_Cone------
484 case GeomAbs_Cylinder :
486 if (T == GeomAbs_IsoV) {
487 for (j = 1; j < myDiscret; j++) {
492 if (dis.HasPicked()) {
493 pickshape = F->Face();
496 halt = Standard_True;
501 //---GeomAbs_Sphere GeomAbs_Torus--------
502 //GeomAbs_BezierSurface GeomAbs_BezierSurface
503 case GeomAbs_Sphere :
505 case GeomAbs_OffsetSurface :
506 case GeomAbs_OtherSurface :
507 for (j = 1; j < myDiscret; j++) {
512 if (dis.HasPicked()) {
513 pickshape = F->Face();
516 halt = Standard_True;
520 //-------------GeomAbs_BSplineSurface------
521 case GeomAbs_BezierSurface :
522 case GeomAbs_BSplineSurface :
523 for (j = 1; j <= myDiscret/2; j++) {
524 Handle(DBRep_Face) aLocalFace = F;
528 PlotIso (dis, aLocalFace , S, T, U1, V1, (T == GeomAbs_IsoV) ? stepU*2. : stepV*2., halt);
533 //-------------GeomAbs_SurfaceOfExtrusion--
534 //-------------GeomAbs_SurfaceOfRevolution-
535 case GeomAbs_SurfaceOfExtrusion :
536 case GeomAbs_SurfaceOfRevolution :
537 if ((T == GeomAbs_IsoV && SurfType == GeomAbs_SurfaceOfRevolution) ||
538 (T == GeomAbs_IsoU && SurfType == GeomAbs_SurfaceOfExtrusion)) {
539 if (SurfType == GeomAbs_SurfaceOfExtrusion) break;
540 for (j = 1; j < myDiscret; j++) {
545 if (dis.HasPicked()) {
546 pickshape = F->Face();
549 halt = Standard_True;
553 CurvType = (S.BasisCurve())->GetType();
557 case GeomAbs_Circle :
558 case GeomAbs_Ellipse :
559 for (j = 1; j < myDiscret; j++) {
564 if (dis.HasPicked()) {
565 pickshape = F->Face();
568 halt = Standard_True;
572 case GeomAbs_Parabola :
573 case GeomAbs_Hyperbola :
574 case GeomAbs_BezierCurve :
575 case GeomAbs_BSplineCurve :
576 case GeomAbs_OtherCurve :
577 for (j = 1; j <= myDiscret/2; j++) {
578 Handle(DBRep_Face) aLocalFace = F;
582 PlotIso (dis, aLocalFace, S, T, U1, V1,
583 (T == GeomAbs_IsoV) ? stepU*2. : stepV*2., halt);
594 if (dis.HasPicked()) {
595 pickshape = F->Face();
598 halt = Standard_True;
603 //=====================================
604 // trace des eventuelles triangulations.
605 //=====================================
607 if (aSurf.IsNull() || mytriangulations) {
608 Tr = BRep_Tool::Triangulation(F->Face(), loc);
610 Display(Tr, loc.Transformation(), dis);
618 DBRep_ListIteratorOfListOfEdge ite(myEdges);
619 while (ite.More() && !halt) {
621 const Handle(DBRep_Edge)& E = ite.Value();
624 dis.SetColor(DBRep_ColorOrientation(E->Edge().Orientation()));
626 dis.SetColor(E->Color());
628 // display geometrical curve if exists.
629 Standard_Boolean isgeom = BRep_Tool::IsGeometric(E->Edge());
630 Standard_Real aCheckU1, aCheckU2;
633 // check the range (to report bad edges)
634 BRep_Tool::Range(E->Edge(), aCheckU1, aCheckU2);
635 if (aCheckU2 < aCheckU1) {
637 cout << "DBRep_DrawableShape : Bad parameters on edge."<<endl;
638 BRepTools::Dump(E->Edge(),cout);
643 if (BRep_Tool::Degenerated(E->Edge())) {
648 BRepAdaptor_Curve C(E->Edge());
650 Standard_Real f = C.FirstParameter();
651 Standard_Real l = C.LastParameter();
652 if (Precision::IsNegativeInfinite(f)) {
653 if (Precision::IsPositiveInfinite(l)) {
661 else if (Precision::IsPositiveInfinite(l)) {
665 Handle(Adaptor3d_HCurve) HC = C.Trim(f, l, Precision::Confusion());
666 GeomAbs_CurveType CurvType = HC->GetType();
668 Standard_Integer intrv, nbintv = HC->NbIntervals(GeomAbs_CN);
669 TColStd_Array1OfReal TI(1,nbintv+1);
670 HC->Intervals(TI,GeomAbs_CN);
672 HC->D0(HC->FirstParameter(), P);
675 for (intrv = 1; intrv <= nbintv; intrv++) {
676 Standard_Real t = TI(intrv);
677 Standard_Real step = (TI(intrv+1) - t) / myDiscret;
682 case GeomAbs_Circle :
683 case GeomAbs_Ellipse :
684 for (j = 1; j < myDiscret; j++) {
688 if (dis.HasPicked()) {
689 pickshape = E->Edge();
692 halt = Standard_True;
696 case GeomAbs_Parabola :
697 case GeomAbs_Hyperbola :
698 case GeomAbs_BezierCurve :
699 case GeomAbs_BSplineCurve :
700 case GeomAbs_OtherCurve :
701 for (j = 1; j <= myDiscret/2; j++) {
702 Handle(DBRep_Edge) aLocaLEdge(E);
704 PlotEdge (dis, aLocaLEdge , HC->Curve(), t, step*2., halt);
711 C.D0(HC->LastParameter(),P);
713 if (dis.HasPicked()) {
714 pickshape = E->Edge();
717 halt = Standard_True;
721 // display an arrow at the end
726 dis.Project(aPnt,p1);
728 dis.Project(aPnt,p2);
730 if (v.Magnitude() > gp::Resolution()) {
731 Standard_Real L = 20 / dis.Zoom();
732 Standard_Real H = 10 / dis.Zoom();
734 p2.SetCoord(p1.X() - L*d.X() - H*d.Y(), p1.Y() - L*d.Y() + H*d.X());
736 p2.SetCoord(p1.X() - L*d.X() + H*d.Y(), p1.Y() - L*d.Y() - H*d.X());
747 //======================================
748 // trace des representations polygonales:
749 //======================================
751 if (!isgeom || mypolygons) {
754 Handle(Poly_Polygon3D) Polyg = BRep_Tool::Polygon3D(E->Edge(), loc);
755 if (!Polyg.IsNull()) {
756 const TColgp_Array1OfPnt& Points = Polyg->Nodes();
758 for (po = Points.Lower()+1; po <= Points.Upper(); po++) {
759 dis.Draw((Points.Value(po-1)).Transformed(loc),
760 (Points.Value(po)).Transformed(loc));
761 if (dis.HasPicked()) {
762 pickshape = E->Edge();
765 halt = Standard_True;
771 // Polygone sur triangulation:
772 Handle(Poly_Triangulation) PolyTr;
773 Handle(Poly_PolygonOnTriangulation) Poly;
774 BRep_Tool::PolygonOnTriangulation(E->Edge(), Poly, PolyTr, loc);
775 if (!Poly.IsNull()) {
776 const TColStd_Array1OfInteger& Indices = Poly->Nodes();
777 const TColgp_Array1OfPnt& Nodes = PolyTr->Nodes();
778 for (i=Indices.Lower()+1; i<=Indices.Upper(); i++) {
779 dis.Draw(Nodes(Indices(i-1)).Transformed(loc),
780 Nodes(Indices(i)).Transformed(loc));
781 if (dis.HasPicked()) {
782 pickshape = E->Edge();
785 halt = Standard_True;
801 dis.SetColor(myConnCol);
803 for (exv.Init(myShape,TopAbs_VERTEX,TopAbs_EDGE);
808 dis.SetColor(DBRep_ColorOrientation(exv.Current().Orientation()));
809 dis.DrawMarker(BRep_Tool::Pnt(TopoDS::Vertex(exv.Current())),
811 if (dis.HasPicked()) {
812 pickshape = exv.Current();
815 halt = Standard_True;
822 //=======================================================================
823 //function : DisplayHiddenLines
825 //=======================================================================
827 void DBRep_DrawableShape::DisplayHiddenLines(Draw_Display& dis)
829 Standard_Integer id = dis.ViewId();
831 // get the projection
834 Standard_Real focal = -1;
835 if (!strcmp(dout.GetType(id),"PERS")) focal = dout.Focal(id);
836 Standard_Real Ang,Def;
837 HLRBRep::PolyHLRAngleAndDeflection(myAng,Ang,Def);
838 BRepMesh_IncrementalMesh MESH(myShape, Def, Standard_True, Ang);
839 Standard_Boolean recompute = Standard_True;
840 // find if the view must be recomputed
841 DBRep_ListIteratorOfListOfHideData it(myHidData);
844 if (it.Value().ViewId() == id) {
846 // but did we rotate it
847 Standard_Real ang = it.Value().Angle();
848 recompute = !it.Value().IsSame(T,focal) || myAng != ang;
850 myHidData.Remove(it);
852 it.Value().DrawOn(dis,myRg1,myRgN,myHid,
853 myConnCol,myIsosCol);
854 if (dis.HasPicked()) {
855 pickshape = it.Value().LastPick();
864 // recompute the hidden lines and display them
866 DBRep_HideData theData;
867 myHidData.Append(theData);
868 myHidData.Last().Set(id,T,focal,myShape,myAng);
869 myHidData.Last().DrawOn(dis,myRg1,myRgN,myHid,
870 myConnCol,myIsosCol);
871 if (dis.HasPicked()) {
872 pickshape = myHidData.Last().LastPick();
879 //=======================================================================
882 //=======================================================================
884 TopoDS_Shape DBRep_DrawableShape::Shape()const
890 //=======================================================================
893 //=======================================================================
895 Handle(Draw_Drawable3D) DBRep_DrawableShape::Copy()const
897 Handle(DBRep_DrawableShape) D =
898 new DBRep_DrawableShape(myShape,
909 //=======================================================================
910 //function : DisplayOrientation
912 //=======================================================================
914 void DBRep_DrawableShape::DisplayOrientation(const Standard_Boolean D)
919 //=======================================================================
920 //function : DisplayTriangulation
922 //=======================================================================
924 void DBRep_DrawableShape::DisplayTriangulation(const Standard_Boolean D)
926 mytriangulations = D;
929 //=======================================================================
930 //function : DisplayPolygons
932 //=======================================================================
934 void DBRep_DrawableShape::DisplayPolygons(const Standard_Boolean D)
939 //=======================================================================
940 //function : DisplayHLR
942 //=======================================================================
944 void DBRep_DrawableShape::DisplayHLR(const Standard_Boolean withHLR,
945 const Standard_Boolean withRg1,
946 const Standard_Boolean withRgN,
947 const Standard_Boolean withHid,
948 const Standard_Real ang)
957 //=======================================================================
958 //function : DisplayTriangulation
960 //=======================================================================
962 Standard_Boolean DBRep_DrawableShape::DisplayTriangulation() const
964 return mytriangulations;
967 //=======================================================================
968 //function : DisplayPolygons
970 //=======================================================================
972 Standard_Boolean DBRep_DrawableShape::DisplayPolygons()const
977 //=======================================================================
978 //function : GetDisplayHLR
980 //=======================================================================
982 void DBRep_DrawableShape::GetDisplayHLR(Standard_Boolean& withHLR,
983 Standard_Boolean& withRg1,
984 Standard_Boolean& withRgN,
985 Standard_Boolean& withHid,
986 Standard_Real& ang) const
995 //=======================================================================
998 //=======================================================================
1000 void DBRep_DrawableShape::Dump(Standard_OStream& S)const
1002 BRepTools::Dump(myShape,S);
1006 //=======================================================================
1009 //=======================================================================
1011 void DBRep_DrawableShape::Whatis(Draw_Interpretor& s)const
1013 if (!myShape.IsNull()) {
1015 switch (myShape.ShapeType()) {
1016 case TopAbs_COMPOUND :
1019 case TopAbs_COMPSOLID :
1037 case TopAbs_VERTEX :
1047 switch (myShape.Orientation()) {
1048 case TopAbs_FORWARD :
1051 case TopAbs_REVERSED :
1054 case TopAbs_INTERNAL :
1057 case TopAbs_EXTERNAL :
1062 if (myShape.Free()) s <<" Free";
1063 if (myShape.Modified()) s <<" Modified";
1064 if (myShape.Orientable()) s <<" Orientable";
1065 if (myShape.Closed()) s <<" Closed";
1066 if (myShape.Infinite()) s <<" Infinite";
1067 if (myShape.Convex()) s <<" Convex";
1072 //=======================================================================
1073 //function : LastPick
1075 //=======================================================================
1077 void DBRep_DrawableShape::LastPick(TopoDS_Shape& s,
1078 Standard_Real& u, Standard_Real& v)
1087 //=======================================================================
1088 //function : Display
1090 //=======================================================================
1092 void DBRep_DrawableShape::Display(const Handle(Poly_Triangulation)& T,
1094 Draw_Display& dis) const
1096 // Build the connect tool
1099 Standard_Integer i,j, nFree, nbTriangles = T->NbTriangles();
1100 Standard_Integer t[3];
1102 // count the free edges
1104 for (i = 1; i <= nbTriangles; i++) {
1105 pc.Triangles(i,t[0],t[1],t[2]);
1106 for (j = 0; j < 3; j++)
1107 if (t[j] == 0) nFree++;
1110 // allocate the arrays
1111 TColStd_Array1OfInteger Free(1,2*nFree);
1113 // array is replaced on map because it is impossible
1114 // to calculate number of internal edges in advance
1115 // due to "internal edges"
1116 TColStd_DataMapOfIntegerInteger Internal;
1118 Standard_Integer fr = 1, in = 1;
1119 const Poly_Array1OfTriangle& triangles = T->Triangles();
1120 Standard_Integer n[3];
1121 for (i = 1; i <= nbTriangles; i++) {
1122 pc.Triangles(i,t[0],t[1],t[2]);
1123 triangles(i).Get(n[0],n[1],n[2]);
1124 for (j = 0; j < 3; j++) {
1125 Standard_Integer k = (j+1) % 3;
1131 // internal edge if this triangle has a lower index than the adjacent
1132 else if (i < t[j]) {
1133 Internal.Bind(in, n[j]);
1134 Internal.Bind(in+1, n[k]);
1140 // Display the edges
1141 const TColgp_Array1OfPnt& Nodes = T->Nodes();
1142 // cout<<"nb nodes = "<<Nodes.Length()<<endl;
1145 Standard_Integer nn;
1146 dis.SetColor(Draw_rouge);
1147 nn = Free.Length() / 2;
1148 for (i = 1; i <= nn; i++) {
1149 dis.Draw(Nodes(Free(2*i-1)).Transformed(tr),
1150 Nodes(Free(2*i)).Transformed(tr));
1155 dis.SetColor(Draw_bleu);
1156 TColStd_DataMapIteratorOfDataMapOfIntegerInteger aIt(Internal);
1157 for (; aIt.More(); aIt.Next()) {
1158 Standard_Integer n1 = aIt.Value();
1159 //alvays pair is put
1161 Standard_Integer n2 = aIt.Value();
1162 dis.Draw(Nodes(n1).Transformed(tr),
1163 Nodes(n2).Transformed(tr));