|
||||
File indexing completed on 2025-01-18 10:03:50
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_SequenceOfLine.hxx> 0024 #include <Hatch_LineForm.hxx> 0025 #include <Standard_Integer.hxx> 0026 class gp_Lin2d; 0027 class gp_Dir2d; 0028 class gp_Pnt2d; 0029 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 0068 DEFINE_STANDARD_ALLOC 0069 0070 0071 //! Returns a empty hatcher. <Tol> is the tolerance 0072 //! for intersections. 0073 Standard_EXPORT Hatch_Hatcher(const Standard_Real Tol, const Standard_Boolean Oriented = Standard_True); 0074 0075 void Tolerance (const Standard_Real Tol); 0076 0077 Standard_Real Tolerance() const; 0078 0079 //! Add a line <L> to be trimmed. <T> the type is 0080 //! only kept from information. It is not used in the 0081 //! computation. 0082 Standard_EXPORT void AddLine (const gp_Lin2d& L, const Hatch_LineForm T = Hatch_ANYLINE); 0083 0084 //! Add an infinite line on direction <D> at distance 0085 //! <Dist> from the origin to be trimmed. <Dist> may 0086 //! be negative. 0087 //! 0088 //! If O is the origin of the 2D plane, and V the 0089 //! vector perpendicular to D (in the direct direction). 0090 //! 0091 //! A point P is on the line if : 0092 //! OP dot V = Dist 0093 //! The parameter of P on the line is 0094 //! OP dot D 0095 Standard_EXPORT void AddLine (const gp_Dir2d& D, const Standard_Real Dist); 0096 0097 //! Add an infinite line parallel to the Y-axis at 0098 //! abciss <X>. 0099 Standard_EXPORT void AddXLine (const Standard_Real X); 0100 0101 //! Add an infinite line parallel to the X-axis at 0102 //! ordinate <Y>. 0103 Standard_EXPORT void AddYLine (const Standard_Real Y); 0104 0105 //! Trims the lines at intersections with <L>. 0106 Standard_EXPORT void Trim (const gp_Lin2d& L, const Standard_Integer Index = 0); 0107 0108 //! Trims the lines at intersections with <L> in the 0109 //! parameter range <Start>, <End> 0110 Standard_EXPORT void Trim (const gp_Lin2d& L, const Standard_Real Start, const Standard_Real End, const Standard_Integer Index = 0); 0111 0112 //! Trims the line at intersection with the oriented 0113 //! segment P1,P2. 0114 Standard_EXPORT void Trim (const gp_Pnt2d& P1, const gp_Pnt2d& P2, const Standard_Integer Index = 0); 0115 0116 //! Returns the total number of intervals on all the 0117 //! lines. 0118 Standard_EXPORT Standard_Integer NbIntervals() const; 0119 0120 //! Returns the number of lines. 0121 Standard_EXPORT Standard_Integer NbLines() const; 0122 0123 //! Returns the line of index <I>. 0124 Standard_EXPORT const gp_Lin2d& Line (const Standard_Integer I) const; 0125 0126 //! Returns the type of the line of index <I>. 0127 Standard_EXPORT Hatch_LineForm LineForm (const Standard_Integer I) const; 0128 0129 //! Returns True if the line of index <I> has a 0130 //! constant X value. 0131 Standard_Boolean IsXLine (const Standard_Integer I) const; 0132 0133 //! Returns True if the line of index <I> has a 0134 //! constant Y value. 0135 Standard_Boolean IsYLine (const Standard_Integer I) const; 0136 0137 //! Returns the X or Y coordinate of the line of index 0138 //! <I> if it is a X or a Y line. 0139 Standard_EXPORT Standard_Real Coordinate (const Standard_Integer I) const; 0140 0141 //! Returns the number of intervals on line of index <I>. 0142 Standard_EXPORT Standard_Integer NbIntervals (const Standard_Integer I) const; 0143 0144 //! Returns the first parameter of interval <J> on 0145 //! line <I>. 0146 Standard_EXPORT Standard_Real Start (const Standard_Integer I, const Standard_Integer J) const; 0147 0148 //! Returns the first Index and Par2 of interval <J> on 0149 //! line <I>. 0150 Standard_EXPORT void StartIndex (const Standard_Integer I, const Standard_Integer J, Standard_Integer& Index, Standard_Real& Par2) const; 0151 0152 //! Returns the last parameter of interval <J> on 0153 //! line <I>. 0154 Standard_EXPORT Standard_Real End (const Standard_Integer I, const Standard_Integer J) const; 0155 0156 //! Returns the last Index and Par2 of interval <J> on 0157 //! line <I>. 0158 Standard_EXPORT void EndIndex (const Standard_Integer I, const Standard_Integer J, Standard_Integer& Index, Standard_Real& Par2) const; 0159 0160 0161 0162 0163 protected: 0164 0165 0166 0167 0168 0169 private: 0170 0171 0172 0173 Standard_Real myToler; 0174 Hatch_SequenceOfLine myLines; 0175 Standard_Boolean myOrient; 0176 0177 0178 }; 0179 0180 0181 #include <Hatch_Hatcher.lxx> 0182 0183 0184 0185 0186 0187 #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 |