|
|
|||
File indexing completed on 2026-09-13 09:16:38
0001 // Created on: 1992-08-19 0002 // Created by: Modelistation 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 _Hatch_Hatcher_HeaderFile 0018 #define _Hatch_Hatcher_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 0023 #include <Hatch_Line.hxx> 0024 #include <NCollection_Sequence.hxx> 0025 #include <Hatch_LineForm.hxx> 0026 #include <Standard_Integer.hxx> 0027 class gp_Lin2d; 0028 class gp_Dir2d; 0029 class gp_Pnt2d; 0030 0031 //! The Hatcher is an algorithm to compute cross 0032 //! hatchings in a 2d plane. It is mainly dedicated to 0033 //! display purpose. 0034 //! 0035 //! Computing cross hatchings is a 3 steps process : 0036 //! 0037 //! 1. The users stores in the Hatcher a set of 2d 0038 //! lines to be trimmed. Methods in the "Lines" 0039 //! category. 0040 //! 0041 //! 2. The user trims the lines with a boundary. The 0042 //! inside of a boundary is on the left side. Methods 0043 //! in the "Trimming" category. 0044 //! 0045 //! 3. The user reads back the trimmed lines. Methods 0046 //! in the "Results" category. 0047 //! 0048 //! The result is a set of parameter intervals on the 0049 //! line. The first parameter of an Interval may be 0050 //! RealFirst() and the last may be RealLast(). 0051 //! 0052 //! A line can be a line parallel to the axis (X or Y 0053 //! line or a 2D line. 0054 //! 0055 //! The Hatcher has two modes : 0056 //! 0057 //! * The "Oriented" mode, where the orientation of 0058 //! the trimming curves is considered. The hatch are 0059 //! kept on the left of the trimming curve. In this 0060 //! mode infinite hatch can be computed. 0061 //! 0062 //! * The "UnOriented" mode, where the hatch are 0063 //! always finite. 0064 class Hatch_Hatcher 0065 { 0066 public: 0067 DEFINE_STANDARD_ALLOC 0068 0069 //! Returns an empty hatcher. <Tol> is the tolerance 0070 //! for intersections. 0071 Standard_EXPORT Hatch_Hatcher(const double Tol, const bool Oriented = true); 0072 0073 void Tolerance(const double Tol); 0074 0075 double Tolerance() const; 0076 0077 //! Add a line <L> to be trimmed. <T> the type is 0078 //! only kept from information. It is not used in the 0079 //! computation. 0080 Standard_EXPORT void AddLine(const gp_Lin2d& L, const Hatch_LineForm T = Hatch_ANYLINE); 0081 0082 //! Add an infinite line on direction <D> at distance 0083 //! <Dist> from the origin to be trimmed. <Dist> may 0084 //! be negative. 0085 //! 0086 //! If O is the origin of the 2D plane, and V the 0087 //! vector perpendicular to D (in the direct direction). 0088 //! 0089 //! A point P is on the line if : 0090 //! OP dot V = Dist 0091 //! The parameter of P on the line is 0092 //! OP dot D 0093 Standard_EXPORT void AddLine(const gp_Dir2d& D, const double Dist); 0094 0095 //! Add an infinite line parallel to the Y-axis at 0096 //! abciss <X>. 0097 Standard_EXPORT void AddXLine(const double X); 0098 0099 //! Add an infinite line parallel to the X-axis at 0100 //! ordinate <Y>. 0101 Standard_EXPORT void AddYLine(const double Y); 0102 0103 //! Trims the lines at intersections with <L>. 0104 Standard_EXPORT void Trim(const gp_Lin2d& L, const int Index = 0); 0105 0106 //! Trims the lines at intersections with <L> in the 0107 //! parameter range <Start>, <End> 0108 Standard_EXPORT void Trim(const gp_Lin2d& L, 0109 const double Start, 0110 const double End, 0111 const int Index = 0); 0112 0113 //! Trims the line at intersection with the oriented 0114 //! segment P1,P2. 0115 Standard_EXPORT void Trim(const gp_Pnt2d& P1, const gp_Pnt2d& P2, const int Index = 0); 0116 0117 //! Returns the total number of intervals on all the 0118 //! lines. 0119 Standard_EXPORT int NbIntervals() const; 0120 0121 //! Returns the number of lines. 0122 Standard_EXPORT int NbLines() const; 0123 0124 //! Returns the line of index <I>. 0125 Standard_EXPORT const gp_Lin2d& Line(const int I) const; 0126 0127 //! Returns the type of the line of index <I>. 0128 Standard_EXPORT Hatch_LineForm LineForm(const int I) const; 0129 0130 //! Returns True if the line of index <I> has a 0131 //! constant X value. 0132 bool IsXLine(const int I) const; 0133 0134 //! Returns True if the line of index <I> has a 0135 //! constant Y value. 0136 bool IsYLine(const int I) const; 0137 0138 //! Returns the X or Y coordinate of the line of index 0139 //! <I> if it is a X or a Y line. 0140 Standard_EXPORT double Coordinate(const int I) const; 0141 0142 //! Returns the number of intervals on line of index <I>. 0143 Standard_EXPORT int NbIntervals(const int I) const; 0144 0145 //! Returns the first parameter of interval <J> on 0146 //! line <I>. 0147 Standard_EXPORT double Start(const int I, const int J) const; 0148 0149 //! Returns the first Index and Par2 of interval <J> on 0150 //! line <I>. 0151 Standard_EXPORT void StartIndex(const int I, const int J, int& Index, double& Par2) const; 0152 0153 //! Returns the last parameter of interval <J> on 0154 //! line <I>. 0155 Standard_EXPORT double End(const int I, const int J) const; 0156 0157 //! Returns the last Index and Par2 of interval <J> on 0158 //! line <I>. 0159 Standard_EXPORT void EndIndex(const int I, const int J, int& Index, double& Par2) const; 0160 0161 private: 0162 double myToler; 0163 NCollection_Sequence<Hatch_Line> myLines; 0164 bool myOrient; 0165 }; 0166 0167 #include <Hatch_Hatcher.lxx> 0168 0169 #endif // _Hatch_Hatcher_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|