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.
17 #include <DBRep_DrawableShape.ixx>
20 #include <Draw_Appli.hxx>
22 #include <DBRep_Face.hxx>
23 #include <DBRep_Edge.hxx>
24 #include <DBRep_IsoBuilder.hxx>
25 #include <DBRep_ListIteratorOfListOfFace.hxx>
26 #include <DBRep_ListIteratorOfListOfEdge.hxx>
27 #include <DBRep_ListIteratorOfListOfHideData.hxx>
28 #include <DBRep_HideData.hxx>
31 #include <TopoDS_Face.hxx>
32 #include <TopoDS_Edge.hxx>
34 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
35 #include <TopTools_ListOfShape.hxx>
38 #include <TopExp_Explorer.hxx>
40 #include <BRep_Tool.hxx>
42 #include <BRepTools.hxx>
44 #include <BRepMesh_IncrementalMesh.hxx>
46 #include <BRepAdaptor_Surface.hxx>
47 #include <BRepAdaptor_Curve.hxx>
49 #include <HLRBRep.hxx>
51 #include <gp_Lin2d.hxx>
52 #include <gp_Trsf.hxx>
54 #include <Poly_Polygon3D.hxx>
55 #include <Poly_Triangulation.hxx>
56 #include <Poly_PolygonOnTriangulation.hxx>
57 #include <Poly_Connect.hxx>
58 #include <TColgp_HArray1OfPnt.hxx>
59 #include <TColStd_HArray1OfInteger.hxx>
61 #include <Precision.hxx>
62 #include <Geom_BSplineSurface.hxx>
63 #include <Geom_BSplineCurve.hxx>
64 #include <Adaptor3d_HCurve.hxx>
65 #include <GeomAdaptor_HSurface.hxx>
66 #include <GeomAdaptor_Surface.hxx>
67 #include <TColStd_DataMapOfIntegerInteger.hxx>
68 #include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
70 static Standard_Real IsoRatio = 1.001;
72 static Standard_Integer MaxPlotCount = 5; // To avoid huge recursive calls in
73 static Standard_Integer PlotCount = 0; // PlotEdge and PlotIso for cases of "bad"
74 // curves and surfaces
75 // Set PlotCount = 0 before first call of
76 // PlotEdge or PlotIso
77 static TopoDS_Shape pickshape;
78 static Standard_Real upick,vpick;
80 extern Draw_Viewer dout;
83 //=======================================================================
84 //function : DBRep_DrawableShape
85 //purpose : constructor
86 //=======================================================================
88 DBRep_DrawableShape::DBRep_DrawableShape
89 (const TopoDS_Shape& aShape,
90 const Draw_Color& FreeCol,
91 const Draw_Color& ConnCol,
92 const Draw_Color& EdgeCol,
93 const Draw_Color& IsosCol,
94 const Standard_Real size,
95 const Standard_Integer nbisos,
96 const Standard_Integer discret) :
104 myDispOr(Standard_False),
105 mytriangulations(Standard_False),
106 mypolygons(Standard_False),
107 myHLR(Standard_False),
108 myRg1(Standard_False),
109 myRgN(Standard_False),
110 myHid(Standard_False)
115 //=======================================================================
118 //=======================================================================
120 void DBRep_DrawableShape::Set(const TopoDS_Shape& aShape)
127 if (myShape.IsNull())
130 //==============================================================
132 //==============================================================
134 TopExp_Explorer ExpFace;
137 for (ExpFace.Init (myShape,TopAbs_FACE);
140 TopoDS_Face TopologicalFace = TopoDS::Face (ExpFace.Current());
142 const Handle(Geom_Surface)& S =
143 BRep_Tool::Surface(TopologicalFace,l);
145 TopologicalFace.Orientation (TopAbs_FORWARD) ;
146 DBRep_IsoBuilder IsoBuild (TopologicalFace, mySize, myNbIsos) ;
147 myFaces.Append(new DBRep_Face (TopologicalFace,
148 IsoBuild.NbDomains(),
150 IsoBuild.LoadIsos (myFaces.Last()) ;
152 else myFaces.Append(new DBRep_Face(TopologicalFace,0, myEdgeCol));
154 else myFaces.Append(new DBRep_Face(TopologicalFace,0, myEdgeCol));
157 //==============================================================
159 //==============================================================
161 TopTools_IndexedDataMapOfShapeListOfShape edgemap;
162 TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_FACE,edgemap);
163 Standard_Integer iedge;
165 for (iedge = 1; iedge <= edgemap.Extent(); iedge++) {
167 const TopoDS_Edge& theEdge = TopoDS::Edge(edgemap.FindKey(iedge));
169 // skip degenerated edges
170 if (BRep_Tool::Degenerated(theEdge)) continue;
172 // compute the number of faces
173 Standard_Integer nbf = edgemap(iedge).Extent();
175 Draw_Color EdgeColor;
180 EdgeColor = myEdgeCol; // isolated edge
184 EdgeColor = myFreeCol; // edge in only one face
188 EdgeColor = myConnCol; // edge shared by at least two faces
191 myEdges.Append(new DBRep_Edge (theEdge,EdgeColor));
196 //=======================================================================
197 //function : ChangeNbIsos
198 //purpose : Changes the number of isoparametric curves in a shape.
199 //=======================================================================
201 void DBRep_DrawableShape::ChangeNbIsos (const Standard_Integer NbIsos)
205 TopExp_Explorer ExpFace;
208 for (ExpFace.Init (myShape, TopAbs_FACE);
211 TopoDS_Face TopologicalFace = TopoDS::Face (ExpFace.Current());
212 const Handle(Geom_Surface)& S =
213 BRep_Tool::Surface(TopologicalFace,l);
216 TopologicalFace.Orientation (TopAbs_FORWARD) ;
217 DBRep_IsoBuilder IsoBuild (TopologicalFace, mySize, myNbIsos) ;
220 (TopologicalFace, IsoBuild.NbDomains(), myIsosCol)) ;
221 IsoBuild.LoadIsos (myFaces.Last()) ;
223 else myFaces.Append(new DBRep_Face(TopologicalFace,0, myEdgeCol));
225 else myFaces.Append(new DBRep_Face(TopologicalFace,0, myEdgeCol));
229 //=======================================================================
231 // Purpose : Returns the number of isoparametric curves in a shape.
232 //=======================================================================
234 Standard_Integer DBRep_DrawableShape::NbIsos () const
239 //=======================================================================
240 // Function : Discret
242 //=======================================================================
244 Standard_Integer DBRep_DrawableShape::Discret () const
249 Standard_EXPORT Draw_Color DBRep_ColorOrientation (const TopAbs_Orientation Or);
252 static void PlotIso (Draw_Display& dis,
253 Handle(DBRep_Face)& F,
254 BRepAdaptor_Surface& S,
259 Standard_Boolean& halt)
266 if (T == GeomAbs_IsoU) {
268 S.D0(U, V + Step/2., Pm);
269 S.D0(U, V + Step, Pr);
272 S.D0(U + Step/2., V, Pm);
273 S.D0(U + Step, V, Pr);
276 if (PlotCount > MaxPlotCount) {
278 if (dis.HasPicked()) {
279 pickshape = F->Face();
280 upick = (T == GeomAbs_IsoU) ? U : U + Step;
281 vpick = (T == GeomAbs_IsoU) ? V + Step : V;
282 halt = Standard_True;
287 if (Pm.Distance(Pl) + Pm.Distance(Pr) <= IsoRatio*Pl.Distance(Pr)) {
289 if (dis.HasPicked()) {
290 pickshape = F->Face();
291 upick = (T == GeomAbs_IsoU) ? U : U + Step;
292 vpick = (T == GeomAbs_IsoU) ? V + Step : V;
293 halt = Standard_True;
296 if (T == GeomAbs_IsoU) {
297 PlotIso (dis, F, S, T, U, V, Step/2, halt);
298 Standard_Real aLocalV = V + Step/2 ;
299 PlotIso (dis, F, S, T, U, aLocalV , Step/2, halt);
301 PlotIso (dis, F, S, T, U, V, Step/2, halt);
302 Standard_Real aLocalU = U + Step/2 ;
303 PlotIso (dis, F, S, T, aLocalU , V, Step/2, halt);
308 static void PlotEdge (Draw_Display& dis,
309 Handle(DBRep_Edge)& E,
310 const Adaptor3d_Curve& C,
313 Standard_Boolean& halt)
321 C.D0(f + step/2., Pm);
324 if (PlotCount > MaxPlotCount) {
326 if (dis.HasPicked()) {
327 pickshape = E->Edge();
330 halt = Standard_True;
336 if (Pm.Distance(Pl) + Pm.Distance(Pr) <= IsoRatio*Pl.Distance(Pr)) {
338 if (dis.HasPicked()) {
339 pickshape = E->Edge();
342 halt = Standard_True;
345 PlotEdge (dis, E, C, f, step/2, halt);
346 Standard_Real aLocalF = f + step/2 ;
347 PlotEdge (dis, E, C, aLocalF , step/2, halt);
351 //=======================================================================
354 //=======================================================================
356 void DBRep_DrawableShape::DrawOn(Draw_Display& dis) const
358 Standard_Boolean halt = Standard_False;
360 if (myShape.IsNull()) {
361 dis.SetColor(myConnCol);
362 dis.DrawString(gp_Pnt(0,0,0),"Null Shape");
368 DBRep_DrawableShape* p = (DBRep_DrawableShape*) this;
369 p->DisplayHiddenLines(dis);
374 Standard_Real Par,T1,T2;
375 Standard_Real U1,U2,V1,V2,stepU=0.,stepV=0.;
378 Standard_Integer i,j;
381 Handle(Poly_Triangulation) Tr;
385 DBRep_ListIteratorOfListOfFace itf(myFaces);
387 while (itf.More() && !halt) {
389 const Handle(DBRep_Face)& F = itf.Value();
390 dis.SetColor(F->Color());
392 const Handle(Geom_Surface)& S = BRep_Tool::Surface(F->Face(),l);
396 Standard_Boolean restriction = Standard_False;
397 if(S->IsUPeriodic() || S->IsVPeriodic()) {
398 Standard_Real SU1 = 0., SU2 = 0., SV1 = 0., SV2 = 0.;
399 Standard_Real FU1 = 0., FU2 = 0., FV1 = 0., FV2 = 0.;
400 S->Bounds(SU1,SU2,SV1,SV2);
401 BRepTools::UVBounds (F->Face(),FU1,FU2,FV1,FV2);
402 if(S->IsUPeriodic()) {
403 if(FU1 < SU1 || FU1 > SU2)
404 restriction = Standard_True;
405 if(!restriction && (FU2 < SU1 || FU2 > SU2))
406 restriction = Standard_True;
408 if(!restriction && S->IsVPeriodic()) {
409 if(FV1 < SV1 || FV1 > SV2)
410 restriction = Standard_True;
411 if(!restriction && (FV2 < SV1 || FV2 > SV2))
412 restriction = Standard_True;
414 Standard_Boolean zeroS = (fabs(SU2-SU1) <= 1.e-9 || fabs(SV2-SV1) <= 1.e-9);
415 Standard_Boolean zeroF = (fabs(FU2-FU1) <= 1.e-9 || fabs(FV2-FV1) <= 1.e-9);
416 if(restriction && (zeroS || zeroF))
417 restriction = Standard_False;
418 if(restriction && (FU1 >= FU2 || FV1 >= FV2))
419 restriction = Standard_False;
420 if(restriction && (fabs(FU2-FU1) > 4.1e+100 || fabs(FV2-FV1) > 4.1e+100))
421 restriction = Standard_False;
424 BRepAdaptor_Surface S(F->Face(),restriction);
426 //BRepAdaptor_Surface S(F->Face(),Standard_False);
428 GeomAbs_SurfaceType SurfType = S.GetType();
430 // If the type of the surface is GeomAbs_SurfaceOfExtrusion or GeomAbs_SurfaceOfRevolution
432 GeomAbs_CurveType CurvType;
434 GeomAbs_CurveType CurvType = GeomAbs_OtherCurve;
437 Standard_Integer N = F->NbIsos();
439 Standard_Integer Intrv, nbIntv;
440 Standard_Integer nbUIntv = S.NbUIntervals(GeomAbs_CN);
441 Standard_Integer nbVIntv = S.NbVIntervals(GeomAbs_CN);
442 TColStd_Array1OfReal TI(1,Max(nbUIntv, nbVIntv)+1);
444 for (i = 1; i <= N; i++) {
446 F->GetIso(i,T,Par,T1,T2);
447 if (T == GeomAbs_IsoU) {
448 S.VIntervals(TI, GeomAbs_CN);
457 S.UIntervals(TI, GeomAbs_CN);
469 for (Intrv = 1; Intrv <= nbIntv; Intrv++) {
471 if (TI(Intrv) <= T1 && TI(Intrv + 1) <= T1)
473 if (TI(Intrv) >= T2 && TI(Intrv + 1) >= T2)
475 if (T == GeomAbs_IsoU) {
476 V1 = Max(T1, TI(Intrv));
477 V2 = Min(T2, TI(Intrv + 1));
478 stepV = (V2 - V1) / myDiscret;
481 U1 = Max(T1, TI(Intrv));
482 U2 = Min(T2, TI(Intrv + 1));
483 stepU = (U2 - U1) / myDiscret;
487 //-------------GeomAbs_Plane---------------
490 //----GeomAbs_Cylinder GeomAbs_Cone------
491 case GeomAbs_Cylinder :
493 if (T == GeomAbs_IsoV) {
494 for (j = 1; j < myDiscret; j++) {
499 if (dis.HasPicked()) {
500 pickshape = F->Face();
503 halt = Standard_True;
508 //---GeomAbs_Sphere GeomAbs_Torus--------
509 //GeomAbs_BezierSurface GeomAbs_BezierSurface
510 case GeomAbs_Sphere :
512 case GeomAbs_OffsetSurface :
513 case GeomAbs_OtherSurface :
514 for (j = 1; j < myDiscret; j++) {
519 if (dis.HasPicked()) {
520 pickshape = F->Face();
523 halt = Standard_True;
527 //-------------GeomAbs_BSplineSurface------
528 case GeomAbs_BezierSurface :
529 case GeomAbs_BSplineSurface :
530 for (j = 1; j <= myDiscret/2; j++) {
531 Handle(DBRep_Face) aLocalFace = F;
535 PlotIso (dis, aLocalFace , S, T, U1, V1, (T == GeomAbs_IsoV) ? stepU*2. : stepV*2., halt);
540 //-------------GeomAbs_SurfaceOfExtrusion--
541 //-------------GeomAbs_SurfaceOfRevolution-
542 case GeomAbs_SurfaceOfExtrusion :
543 case GeomAbs_SurfaceOfRevolution :
544 if ((T == GeomAbs_IsoV && SurfType == GeomAbs_SurfaceOfRevolution) ||
545 (T == GeomAbs_IsoU && SurfType == GeomAbs_SurfaceOfExtrusion)) {
546 if (SurfType == GeomAbs_SurfaceOfExtrusion) break;
547 for (j = 1; j < myDiscret; j++) {
552 if (dis.HasPicked()) {
553 pickshape = F->Face();
556 halt = Standard_True;
560 CurvType = (S.BasisCurve())->GetType();
564 case GeomAbs_Circle :
565 case GeomAbs_Ellipse :
566 for (j = 1; j < myDiscret; j++) {
571 if (dis.HasPicked()) {
572 pickshape = F->Face();
575 halt = Standard_True;
579 case GeomAbs_Parabola :
580 case GeomAbs_Hyperbola :
581 case GeomAbs_BezierCurve :
582 case GeomAbs_BSplineCurve :
583 case GeomAbs_OtherCurve :
584 for (j = 1; j <= myDiscret/2; j++) {
585 Handle(DBRep_Face) aLocalFace = F;
589 PlotIso (dis, aLocalFace, S, T, U1, V1,
590 (T == GeomAbs_IsoV) ? stepU*2. : stepV*2., halt);
601 if (dis.HasPicked()) {
602 pickshape = F->Face();
605 halt = Standard_True;
610 //=====================================
611 // trace des eventuelles triangulations.
612 //=====================================
614 if (S.IsNull() || mytriangulations) {
615 Tr = BRep_Tool::Triangulation(F->Face(), loc);
617 Display(Tr, loc.Transformation(), dis);
625 DBRep_ListIteratorOfListOfEdge ite(myEdges);
626 while (ite.More() && !halt) {
628 const Handle(DBRep_Edge)& E = ite.Value();
631 dis.SetColor(DBRep_ColorOrientation(E->Edge().Orientation()));
633 dis.SetColor(E->Color());
635 // display geometrical curve if exists.
636 Standard_Boolean isgeom = BRep_Tool::IsGeometric(E->Edge());
640 // check the range (to report bad edges)
641 BRep_Tool::Range(E->Edge(),U1,U2);
644 cout << "DBRep_DrawableShape : Bad parameters on edge."<<endl;
645 BRepTools::Dump(E->Edge(),cout);
650 if (BRep_Tool::Degenerated(E->Edge())) {
655 BRepAdaptor_Curve C(E->Edge());
657 Standard_Real f = C.FirstParameter();
658 Standard_Real l = C.LastParameter();
659 if (Precision::IsNegativeInfinite(f)) {
660 if (Precision::IsPositiveInfinite(l)) {
668 else if (Precision::IsPositiveInfinite(l)) {
672 Handle(Adaptor3d_HCurve) HC = C.Trim(f, l, Precision::Confusion());
673 GeomAbs_CurveType CurvType = HC->GetType();
675 Standard_Integer intrv, nbintv = HC->NbIntervals(GeomAbs_CN);
676 TColStd_Array1OfReal TI(1,nbintv+1);
677 HC->Intervals(TI,GeomAbs_CN);
679 HC->D0(HC->FirstParameter(), P);
682 for (intrv = 1; intrv <= nbintv; intrv++) {
683 Standard_Real t = TI(intrv);
684 Standard_Real step = (TI(intrv+1) - t) / myDiscret;
689 case GeomAbs_Circle :
690 case GeomAbs_Ellipse :
691 for (j = 1; j < myDiscret; j++) {
695 if (dis.HasPicked()) {
696 pickshape = E->Edge();
699 halt = Standard_True;
703 case GeomAbs_Parabola :
704 case GeomAbs_Hyperbola :
705 case GeomAbs_BezierCurve :
706 case GeomAbs_BSplineCurve :
707 case GeomAbs_OtherCurve :
708 for (j = 1; j <= myDiscret/2; j++) {
709 Handle(DBRep_Edge) aLocaLEdge(E);
711 PlotEdge (dis, aLocaLEdge , HC->Curve(), t, step*2., halt);
718 C.D0(HC->LastParameter(),P);
720 if (dis.HasPicked()) {
721 pickshape = E->Edge();
724 halt = Standard_True;
728 // display an arrow at the end
737 if (v.Magnitude() > gp::Resolution()) {
738 Standard_Real L = 20 / dis.Zoom();
739 Standard_Real H = 10 / dis.Zoom();
741 p2.SetCoord(p1.X() - L*d.X() - H*d.Y(), p1.Y() - L*d.Y() + H*d.X());
743 p2.SetCoord(p1.X() - L*d.X() + H*d.Y(), p1.Y() - L*d.Y() - H*d.X());
754 //======================================
755 // trace des representations polygonales:
756 //======================================
758 if (!isgeom || mypolygons) {
761 Handle(Poly_Polygon3D) Polyg = BRep_Tool::Polygon3D(E->Edge(), loc);
762 if (!Polyg.IsNull()) {
763 const TColgp_Array1OfPnt& Points = Polyg->Nodes();
765 for (po = Points.Lower()+1; po <= Points.Upper(); po++) {
766 dis.Draw((Points.Value(po-1)).Transformed(loc),
767 (Points.Value(po)).Transformed(loc));
768 if (dis.HasPicked()) {
769 pickshape = E->Edge();
772 halt = Standard_True;
778 // Polygone sur triangulation:
779 Handle(Poly_Triangulation) Tr;
780 Handle(Poly_PolygonOnTriangulation) Poly;
781 BRep_Tool::PolygonOnTriangulation(E->Edge(), Poly, Tr, loc);
782 if (!Poly.IsNull()) {
783 const TColStd_Array1OfInteger& Indices = Poly->Nodes();
784 const TColgp_Array1OfPnt& Nodes = Tr->Nodes();
785 for (i=Indices.Lower()+1; i<=Indices.Upper(); i++) {
786 dis.Draw(Nodes(Indices(i-1)).Transformed(loc),
787 Nodes(Indices(i)).Transformed(loc));
788 if (dis.HasPicked()) {
789 pickshape = E->Edge();
792 halt = Standard_True;
808 dis.SetColor(myConnCol);
810 for (exv.Init(myShape,TopAbs_VERTEX,TopAbs_EDGE);
815 dis.SetColor(DBRep_ColorOrientation(exv.Current().Orientation()));
816 dis.DrawMarker(BRep_Tool::Pnt(TopoDS::Vertex(exv.Current())),
818 if (dis.HasPicked()) {
819 pickshape = exv.Current();
822 halt = Standard_True;
829 //=======================================================================
830 //function : DisplayHiddenLines
832 //=======================================================================
834 void DBRep_DrawableShape::DisplayHiddenLines(Draw_Display& dis)
836 Standard_Integer id = dis.ViewId();
838 // get the projection
841 Standard_Real focal = -1;
842 if (!strcmp(dout.GetType(id),"PERS")) focal = dout.Focal(id);
843 Standard_Real Ang,Def;
844 HLRBRep::PolyHLRAngleAndDeflection(myAng,Ang,Def);
845 BRepMesh_IncrementalMesh MESH(myShape, Def, Standard_True, Ang);
846 Standard_Boolean recompute = Standard_True;
847 // find if the view must be recomputed
848 DBRep_ListIteratorOfListOfHideData it(myHidData);
851 if (it.Value().ViewId() == id) {
853 // but did we rotate it
854 Standard_Real ang = it.Value().Angle();
855 recompute = !it.Value().IsSame(T,focal) || myAng != ang;
857 myHidData.Remove(it);
859 it.Value().DrawOn(dis,myRg1,myRgN,myHid,
860 myConnCol,myIsosCol);
861 if (dis.HasPicked()) {
862 pickshape = it.Value().LastPick();
871 // recompute the hidden lines and display them
873 DBRep_HideData theData;
874 myHidData.Append(theData);
875 myHidData.Last().Set(id,T,focal,myShape,myAng);
876 myHidData.Last().DrawOn(dis,myRg1,myRgN,myHid,
877 myConnCol,myIsosCol);
878 if (dis.HasPicked()) {
879 pickshape = myHidData.Last().LastPick();
886 //=======================================================================
889 //=======================================================================
891 TopoDS_Shape DBRep_DrawableShape::Shape()const
897 //=======================================================================
900 //=======================================================================
902 Handle(Draw_Drawable3D) DBRep_DrawableShape::Copy()const
904 Handle(DBRep_DrawableShape) D =
905 new DBRep_DrawableShape(myShape,
916 //=======================================================================
917 //function : DisplayOrientation
919 //=======================================================================
921 void DBRep_DrawableShape::DisplayOrientation(const Standard_Boolean D)
926 //=======================================================================
927 //function : DisplayTriangulation
929 //=======================================================================
931 void DBRep_DrawableShape::DisplayTriangulation(const Standard_Boolean D)
933 mytriangulations = D;
936 //=======================================================================
937 //function : DisplayPolygons
939 //=======================================================================
941 void DBRep_DrawableShape::DisplayPolygons(const Standard_Boolean D)
946 //=======================================================================
947 //function : DisplayHLR
949 //=======================================================================
951 void DBRep_DrawableShape::DisplayHLR(const Standard_Boolean withHLR,
952 const Standard_Boolean withRg1,
953 const Standard_Boolean withRgN,
954 const Standard_Boolean withHid,
955 const Standard_Real ang)
964 //=======================================================================
965 //function : DisplayTriangulation
967 //=======================================================================
969 Standard_Boolean DBRep_DrawableShape::DisplayTriangulation() const
971 return mytriangulations;
974 //=======================================================================
975 //function : DisplayPolygons
977 //=======================================================================
979 Standard_Boolean DBRep_DrawableShape::DisplayPolygons()const
984 //=======================================================================
985 //function : GetDisplayHLR
987 //=======================================================================
989 void DBRep_DrawableShape::GetDisplayHLR(Standard_Boolean& withHLR,
990 Standard_Boolean& withRg1,
991 Standard_Boolean& withRgN,
992 Standard_Boolean& withHid,
993 Standard_Real& ang) const
1002 //=======================================================================
1005 //=======================================================================
1007 void DBRep_DrawableShape::Dump(Standard_OStream& S)const
1009 BRepTools::Dump(myShape,S);
1013 //=======================================================================
1016 //=======================================================================
1018 void DBRep_DrawableShape::Whatis(Draw_Interpretor& s)const
1020 if (!myShape.IsNull()) {
1022 switch (myShape.ShapeType()) {
1023 case TopAbs_COMPOUND :
1026 case TopAbs_COMPSOLID :
1044 case TopAbs_VERTEX :
1054 switch (myShape.Orientation()) {
1055 case TopAbs_FORWARD :
1058 case TopAbs_REVERSED :
1061 case TopAbs_INTERNAL :
1064 case TopAbs_EXTERNAL :
1069 if (myShape.Free()) s <<" Free";
1070 if (myShape.Modified()) s <<" Modified";
1071 if (myShape.Orientable()) s <<" Orientable";
1072 if (myShape.Closed()) s <<" Closed";
1073 if (myShape.Infinite()) s <<" Infinite";
1074 if (myShape.Convex()) s <<" Convex";
1079 //=======================================================================
1080 //function : LastPick
1082 //=======================================================================
1084 void DBRep_DrawableShape::LastPick(TopoDS_Shape& s,
1085 Standard_Real& u, Standard_Real& v)
1094 //=======================================================================
1095 //function : Display
1097 //=======================================================================
1099 void DBRep_DrawableShape::Display(const Handle(Poly_Triangulation)& T,
1101 Draw_Display& dis) const
1103 // Build the connect tool
1106 Standard_Integer i,j, nFree, nbTriangles = T->NbTriangles();
1107 Standard_Integer t[3];
1109 // count the free edges
1111 for (i = 1; i <= nbTriangles; i++) {
1112 pc.Triangles(i,t[0],t[1],t[2]);
1113 for (j = 0; j < 3; j++)
1114 if (t[j] == 0) nFree++;
1117 // allocate the arrays
1118 TColStd_Array1OfInteger Free(1,2*nFree);
1120 // array is replaced on map because it is impossible
1121 // to calculate number of internal edges in advance
1122 // due to "internal edges"
1123 TColStd_DataMapOfIntegerInteger Internal;
1125 Standard_Integer fr = 1, in = 1;
1126 const Poly_Array1OfTriangle& triangles = T->Triangles();
1127 Standard_Integer n[3];
1128 for (i = 1; i <= nbTriangles; i++) {
1129 pc.Triangles(i,t[0],t[1],t[2]);
1130 triangles(i).Get(n[0],n[1],n[2]);
1131 for (j = 0; j < 3; j++) {
1132 Standard_Integer k = (j+1) % 3;
1138 // internal edge if this triangle has a lower index than the adjacent
1139 else if (i < t[j]) {
1140 Internal.Bind(in, n[j]);
1141 Internal.Bind(in+1, n[k]);
1147 // Display the edges
1148 const TColgp_Array1OfPnt& Nodes = T->Nodes();
1149 // cout<<"nb nodes = "<<Nodes.Length()<<endl;
1152 Standard_Integer nn;
1153 dis.SetColor(Draw_rouge);
1154 nn = Free.Length() / 2;
1155 for (i = 1; i <= nn; i++) {
1156 dis.Draw(Nodes(Free(2*i-1)).Transformed(tr),
1157 Nodes(Free(2*i)).Transformed(tr));
1162 dis.SetColor(Draw_bleu);
1163 TColStd_DataMapIteratorOfDataMapOfIntegerInteger aIt(Internal);
1164 for (; aIt.More(); aIt.Next()) {
1165 Standard_Integer n1 = aIt.Value();
1166 //alvays pair is put
1168 Standard_Integer n2 = aIt.Value();
1169 dis.Draw(Nodes(n1).Transformed(tr),
1170 Nodes(n2).Transformed(tr));