Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:59:08

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 <gp_Pnt.hxx>
0024 #include <NCollection_Sequence.hxx>
0025 #include <NCollection_HSequence.hxx>
0026 #include <NCollection_List.hxx>
0027 #include <Prs3d_Presentation.hxx>
0028 
0029 class Poly_Triangulation;
0030 
0031 //! The Prs3d package provides the following services
0032 //! -   a presentation object (the context for all
0033 //! modifications to the display, its presentation will be
0034 //! displayed in every view of an active viewer)
0035 //! -   an attribute manager governing how objects such
0036 //! as color, width, and type of line are displayed;
0037 //! these are generic objects, whereas those in
0038 //! StdPrs are specific geometries and topologies.
0039 //! -   generic algorithms providing default settings for
0040 //! objects such as points, curves, surfaces and shapes
0041 //! -   a root object which provides the abstract
0042 //! framework for the DsgPrs definitions at work in
0043 //! display of dimensions, relations and trihedra.
0044 class Prs3d
0045 {
0046 public:
0047   DEFINE_STANDARD_ALLOC
0048 
0049   //! draws an arrow at a given location, with respect
0050   //! to a given direction.
0051   Standard_EXPORT static bool MatchSegment(const double  X,
0052                                            const double  Y,
0053                                            const double  Z,
0054                                            const double  aDistance,
0055                                            const gp_Pnt& p1,
0056                                            const gp_Pnt& p2,
0057                                            double&       dist);
0058 
0059   //! Computes the absolute deflection value based on relative deflection
0060   //! Prs3d_Drawer::DeviationCoefficient().
0061   //! @param[in] theBndMin  bounding box min corner
0062   //! @param[in] theBndMax  bounding box max corner
0063   //! @param[in] theDeviationCoefficient  relative deflection coefficient from
0064   //! Prs3d_Drawer::DeviationCoefficient()
0065   //! @return absolute deflection coefficient based on bounding box dimensions
0066   static double GetDeflection(const NCollection_Vec3<double>& theBndMin,
0067                               const NCollection_Vec3<double>& theBndMax,
0068                               const double                    theDeviationCoefficient)
0069   {
0070     const NCollection_Vec3<double> aDiag = theBndMax - theBndMin;
0071     return (std::max)(aDiag.maxComp() * theDeviationCoefficient * 4.0, Precision::Confusion());
0072   }
0073 
0074   //! Computes the absolute deflection value based on relative deflection
0075   //! Prs3d_Drawer::DeviationCoefficient().
0076   //! @param[in] theBndBox  bounding box
0077   //! @param[in] theDeviationCoefficient  relative deflection coefficient from
0078   //! Prs3d_Drawer::DeviationCoefficient()
0079   //! @param[in] theMaximalChordialDeviation  absolute deflection coefficient from
0080   //! Prs3d_Drawer::MaximalChordialDeviation()
0081   //! @return absolute deflection coefficient based on bounding box dimensions or
0082   //! theMaximalChordialDeviation if bounding box is Void or Infinite
0083   static double GetDeflection(const Bnd_Box& theBndBox,
0084                               const double   theDeviationCoefficient,
0085                               const double   theMaximalChordialDeviation)
0086   {
0087     if (theBndBox.IsVoid())
0088     {
0089       return theMaximalChordialDeviation;
0090     }
0091 
0092     Bnd_Box aBndBox = theBndBox;
0093     if (theBndBox.IsOpen())
0094     {
0095       if (!theBndBox.HasFinitePart())
0096       {
0097         return theMaximalChordialDeviation;
0098       }
0099       aBndBox = theBndBox.FinitePart();
0100     }
0101 
0102     NCollection_Vec3<double> aVecMin, aVecMax;
0103     aBndBox.Get(aVecMin.x(), aVecMin.y(), aVecMin.z(), aVecMax.x(), aVecMax.y(), aVecMax.z());
0104     return GetDeflection(aVecMin, aVecMax, theDeviationCoefficient);
0105   }
0106 
0107   //! Assembles array of primitives for sequence of polylines.
0108   //! @param[in] thePoints  the polylines sequence
0109   //! @return array of primitives
0110   Standard_EXPORT static occ::handle<Graphic3d_ArrayOfPrimitives> PrimitivesFromPolylines(
0111     const NCollection_List<occ::handle<NCollection_HSequence<gp_Pnt>>>& thePoints);
0112 
0113   //! Add primitives into new group in presentation and clear the list of polylines.
0114   Standard_EXPORT static void AddPrimitivesGroup(
0115     const occ::handle<Prs3d_Presentation>&                        thePrs,
0116     const occ::handle<Prs3d_LineAspect>&                          theAspect,
0117     NCollection_List<occ::handle<NCollection_HSequence<gp_Pnt>>>& thePolylines);
0118 
0119   //! Add triangulation free edges into sequence of line segments.
0120   //! @param[out] theSegments  sequence of line segments to fill
0121   //! @param[in] thePolyTri    triangulation to process
0122   //! @param[in] theLocation   transformation to apply
0123   Standard_EXPORT static void AddFreeEdges(NCollection_Sequence<gp_Pnt>&          theSegments,
0124                                            const occ::handle<Poly_Triangulation>& thePolyTri,
0125                                            const gp_Trsf&                         theLocation);
0126 };
0127 
0128 #endif // _Prs3d_HeaderFile