0032279: Draw Harness - protect incmesh from hanging on syntax error
[occt.git] / src / Prs3d / Prs3d.hxx
1 // Created on: 1992-08-26
2 // Created by: Jean Louis FRENKEL
3 // Copyright (c) 1992-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 #ifndef _Prs3d_HeaderFile
18 #define _Prs3d_HeaderFile
19
20 #include <Bnd_Box.hxx>
21 #include <Graphic3d_ArrayOfPrimitives.hxx>
22 #include <Standard_DefineAlloc.hxx>
23 #include <Prs3d_Drawer.hxx>
24 #include <Prs3d_NListOfSequenceOfPnt.hxx>
25 #include <Prs3d_Presentation.hxx>
26
27 class Poly_Triangulation;
28
29 //! The Prs3d package provides the following services
30 //! -   a presentation object (the context for all
31 //! modifications to the display, its presentation will be
32 //! displayed in every view of an active viewer)
33 //! -   an attribute manager governing how objects such
34 //! as color, width, and type of line are displayed;
35 //! these are generic objects, whereas those in
36 //! StdPrs are specific geometries and topologies.
37 //! -   generic   algorithms providing default settings for
38 //! objects such as points, curves, surfaces and shapes
39 //! -   a root object which provides the abstract
40 //! framework for the DsgPrs definitions at work in
41 //! display of dimensions, relations and trihedra.
42 class Prs3d 
43 {
44 public:
45
46   DEFINE_STANDARD_ALLOC
47   
48   //! draws an arrow at a given location, with respect
49   //! to a given direction.
50   Standard_EXPORT static Standard_Boolean MatchSegment (const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Real aDistance, const gp_Pnt& p1, const gp_Pnt& p2, Standard_Real& dist);
51
52   //! Computes the absolute deflection value based on relative deflection Prs3d_Drawer::DeviationCoefficient().
53   //! @param theBndMin [in] bounding box min corner
54   //! @param theBndMax [in] bounding box max corner
55   //! @param theDeviationCoefficient [in] relative deflection coefficient from Prs3d_Drawer::DeviationCoefficient()
56   //! @return absolute deflection coefficient based on bounding box dimensions
57   static Standard_Real GetDeflection (const Graphic3d_Vec3d& theBndMin,
58                                       const Graphic3d_Vec3d& theBndMax,
59                                       const Standard_Real theDeviationCoefficient)
60   {
61     const Graphic3d_Vec3d aDiag = theBndMax - theBndMin;
62     return Max (aDiag.maxComp() * theDeviationCoefficient * 4.0, Precision::Confusion());
63   }
64
65   //! Computes the absolute deflection value based on relative deflection Prs3d_Drawer::DeviationCoefficient().
66   //! @param theBndBox [in] bounding box
67   //! @param theDeviationCoefficient [in] relative deflection coefficient from Prs3d_Drawer::DeviationCoefficient()
68   //! @param theMaximalChordialDeviation [in] absolute deflection coefficient from Prs3d_Drawer::MaximalChordialDeviation()
69   //! @return absolute deflection coefficient based on bounding box dimensions or theMaximalChordialDeviation if bounding box is Void or Infinite
70   static Standard_Real GetDeflection (const Bnd_Box& theBndBox,
71                                       const Standard_Real theDeviationCoefficient,
72                                       const Standard_Real theMaximalChordialDeviation)
73   {
74     if (theBndBox.IsVoid())
75     {
76       return theMaximalChordialDeviation;
77     }
78
79     Bnd_Box aBndBox = theBndBox;
80     if (theBndBox.IsOpen())
81     {
82       if (!theBndBox.HasFinitePart())
83       {
84         return theMaximalChordialDeviation;
85       }
86       aBndBox = theBndBox.FinitePart();
87     }
88
89     Graphic3d_Vec3d aVecMin, aVecMax;
90     aBndBox.Get (aVecMin.x(), aVecMin.y(), aVecMin.z(), aVecMax.x(), aVecMax.y(), aVecMax.z());
91     return GetDeflection (aVecMin, aVecMax, theDeviationCoefficient);
92   }
93
94   //! Assembles array of primitives for sequence of polylines.
95   //! @param thePoints [in] the polylines sequence
96   //! @return array of primitives
97   Standard_EXPORT static Handle(Graphic3d_ArrayOfPrimitives) PrimitivesFromPolylines (const Prs3d_NListOfSequenceOfPnt& thePoints);
98
99   //! Add primitives into new group in presentation and clear the list of polylines.
100   Standard_EXPORT static void AddPrimitivesGroup (const Handle(Prs3d_Presentation)& thePrs,
101                                                   const Handle(Prs3d_LineAspect)&   theAspect,
102                                                   Prs3d_NListOfSequenceOfPnt&       thePolylines);
103
104   //! Add triangulation free edges into sequence of line segments.
105   //! @param theSegments [out] sequence of line segments to fill
106   //! @param thePolyTri   [in] triangulation to process
107   //! @param theLocation  [in] transformation to apply
108   Standard_EXPORT static void AddFreeEdges (TColgp_SequenceOfPnt& theSegments,
109                                             const Handle(Poly_Triangulation)& thePolyTri,
110                                             const gp_Trsf& theLocation);
111
112 };
113
114 #endif // _Prs3d_HeaderFile