Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:39

0001 // Created on: 1992-08-26
0002 // Created by: Jean Louis FRENKEL
0003 // Copyright (c) 1992-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Prs3d_HeaderFile
0018 #define _Prs3d_HeaderFile
0019 
0020 #include <Graphic3d_ArrayOfPrimitives.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Prs3d_Drawer.hxx>
0023 #include <Prs3d_NListOfSequenceOfPnt.hxx>
0024 #include <Prs3d_Presentation.hxx>
0025 
0026 class Poly_Triangulation;
0027 
0028 //! The Prs3d package provides the following services
0029 //! -   a presentation object (the context for all
0030 //! modifications to the display, its presentation will be
0031 //! displayed in every view of an active viewer)
0032 //! -   an attribute manager governing how objects such
0033 //! as color, width, and type of line are displayed;
0034 //! these are generic objects, whereas those in
0035 //! StdPrs are specific geometries and topologies.
0036 //! -   generic   algorithms providing default settings for
0037 //! objects such as points, curves, surfaces and shapes
0038 //! -   a root object which provides the abstract
0039 //! framework for the DsgPrs definitions at work in
0040 //! display of dimensions, relations and trihedra.
0041 class Prs3d 
0042 {
0043 public:
0044 
0045   DEFINE_STANDARD_ALLOC
0046   
0047   //! draws an arrow at a given location, with respect
0048   //! to a given direction.
0049   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);
0050 
0051   //! Computes the absolute deflection value based on relative deflection Prs3d_Drawer::DeviationCoefficient().
0052   //! @param theBndMin [in] bounding box min corner
0053   //! @param theBndMax [in] bounding box max corner
0054   //! @param theDeviationCoefficient [in] relative deflection coefficient from Prs3d_Drawer::DeviationCoefficient()
0055   //! @return absolute deflection coefficient based on bounding box dimensions
0056   static Standard_Real GetDeflection (const Graphic3d_Vec3d& theBndMin,
0057                                       const Graphic3d_Vec3d& theBndMax,
0058                                       const Standard_Real theDeviationCoefficient)
0059   {
0060     const Graphic3d_Vec3d aDiag = theBndMax - theBndMin;
0061     return Max (aDiag.maxComp() * theDeviationCoefficient * 4.0, Precision::Confusion());
0062   }
0063 
0064   //! Computes the absolute deflection value based on relative deflection Prs3d_Drawer::DeviationCoefficient().
0065   //! @param theBndBox [in] bounding box
0066   //! @param theDeviationCoefficient [in] relative deflection coefficient from Prs3d_Drawer::DeviationCoefficient()
0067   //! @param theMaximalChordialDeviation [in] absolute deflection coefficient from Prs3d_Drawer::MaximalChordialDeviation()
0068   //! @return absolute deflection coefficient based on bounding box dimensions or theMaximalChordialDeviation if bounding box is Void or Infinite
0069   static Standard_Real GetDeflection (const Bnd_Box& theBndBox,
0070                                       const Standard_Real theDeviationCoefficient,
0071                                       const Standard_Real theMaximalChordialDeviation)
0072   {
0073     if (theBndBox.IsVoid())
0074     {
0075       return theMaximalChordialDeviation;
0076     }
0077 
0078     Bnd_Box aBndBox = theBndBox;
0079     if (theBndBox.IsOpen())
0080     {
0081       if (!theBndBox.HasFinitePart())
0082       {
0083         return theMaximalChordialDeviation;
0084       }
0085       aBndBox = theBndBox.FinitePart();
0086     }
0087 
0088     Graphic3d_Vec3d aVecMin, aVecMax;
0089     aBndBox.Get (aVecMin.x(), aVecMin.y(), aVecMin.z(), aVecMax.x(), aVecMax.y(), aVecMax.z());
0090     return GetDeflection (aVecMin, aVecMax, theDeviationCoefficient);
0091   }
0092 
0093   //! Assembles array of primitives for sequence of polylines.
0094   //! @param thePoints [in] the polylines sequence
0095   //! @return array of primitives
0096   Standard_EXPORT static Handle(Graphic3d_ArrayOfPrimitives) PrimitivesFromPolylines (const Prs3d_NListOfSequenceOfPnt& thePoints);
0097 
0098   //! Add primitives into new group in presentation and clear the list of polylines.
0099   Standard_EXPORT static void AddPrimitivesGroup (const Handle(Prs3d_Presentation)& thePrs,
0100                                                   const Handle(Prs3d_LineAspect)&   theAspect,
0101                                                   Prs3d_NListOfSequenceOfPnt&       thePolylines);
0102 
0103   //! Add triangulation free edges into sequence of line segments.
0104   //! @param theSegments [out] sequence of line segments to fill
0105   //! @param thePolyTri   [in] triangulation to process
0106   //! @param theLocation  [in] transformation to apply
0107   Standard_EXPORT static void AddFreeEdges (TColgp_SequenceOfPnt& theSegments,
0108                                             const Handle(Poly_Triangulation)& thePolyTri,
0109                                             const gp_Trsf& theLocation);
0110 
0111 };
0112 
0113 #endif // _Prs3d_HeaderFile