42cf5bc1 |
1 | // Created on: 1999-04-26 |
2 | // Created by: Andrey BETENEV |
3 | // Copyright (c) 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 _ShapeFix_ComposeShell_HeaderFile |
18 | #define _ShapeFix_ComposeShell_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <TopLoc_Location.hxx> |
24 | #include <TopoDS_Face.hxx> |
25 | #include <TopAbs_Orientation.hxx> |
26 | #include <TopoDS_Shape.hxx> |
27 | #include <Standard_Integer.hxx> |
28 | #include <Standard_Real.hxx> |
29 | #include <Standard_Boolean.hxx> |
30 | #include <ShapeFix_Root.hxx> |
31 | #include <ShapeExtend_Status.hxx> |
32 | #include <ShapeFix_SequenceOfWireSegment.hxx> |
33 | #include <TColStd_SequenceOfInteger.hxx> |
34 | #include <TColStd_SequenceOfReal.hxx> |
35 | #include <TopTools_SequenceOfShape.hxx> |
36 | class ShapeExtend_CompositeSurface; |
37 | class ShapeAnalysis_TransferParameters; |
42cf5bc1 |
38 | class ShapeExtend_WireData; |
39 | class gp_Lin2d; |
40 | class ShapeFix_WireSegment; |
41 | class Geom_Surface; |
42 | |
9fd2d2c3 |
43 | // resolve name collisions with X11 headers |
44 | #ifdef Status |
45 | #undef Status |
46 | #endif |
42cf5bc1 |
47 | |
48 | class ShapeFix_ComposeShell; |
49 | DEFINE_STANDARD_HANDLE(ShapeFix_ComposeShell, ShapeFix_Root) |
50 | |
51 | //! This class is intended to create a shell from the composite |
52 | //! surface (grid of surfaces) and set of wires. |
53 | //! It may be either division of the supporting surface of the |
54 | //! face, or creating a shape corresponding to face on composite |
55 | //! surface which is missing in CAS.CADE but exists in some other |
56 | //! systems. |
57 | //! |
58 | //! It splits (if necessary) original face to several ones by |
59 | //! splitting lines which are joint lines on a supplied grid of |
60 | //! surfaces (U- and V- isolines of the composite surface). |
61 | //! There are two modes of work, which differ in the way of |
62 | //! handling faces on periodic surfaces: |
63 | //! |
64 | //! - if ClosedMode is False (default), when splitting itself is |
65 | //! done as if surface were not periodic. The periodicity of the |
66 | //! underlying surface is taken into account by duplicating splitting |
67 | //! lines in the periodic direction, as necessary to split all |
68 | //! the wires (whole parametrical range of a face) |
69 | //! In this mode, some regularization procedures are performed |
70 | //! (indexation of splitted segments by patch numbers), and it is |
71 | //! expected to be more reliable and robust in case of bad shapes |
72 | //! |
73 | //! - if ClosedMode is True, when everything on a periodic surfaces |
74 | //! is considered as modulo period. This allows to deal with wires |
75 | //! which are closed in 3d but not in 2d, with wires which may be |
76 | //! shifted on several periods in 2d etc. However, this mode is |
77 | //! less reliable since some regularizations do not work for it. |
78 | //! |
79 | //! The work is made basing on pcurves of the edges. These pcurves |
80 | //! should already exist (for example, in the case of division of |
81 | //! existing face), then they are taken as is. The existing pcurves |
82 | //! should be assigned to one surface (face) for all edges, |
83 | //! this surface (face) will be used only for accessing pcurves, |
84 | //! and it may have any geometry. |
85 | //! |
86 | //! All the modifications are recorded in the context tool |
87 | //! (ShapeBuild_ReShape). |
88 | class ShapeFix_ComposeShell : public ShapeFix_Root |
89 | { |
90 | |
91 | public: |
92 | |
93 | |
94 | //! Creates empty tool. |
95 | Standard_EXPORT ShapeFix_ComposeShell(); |
96 | |
97 | //! Initializes with composite surface, face and precision. |
98 | //! Here face defines both set of wires and way of getting |
99 | //! pcurves. Precision is used (together with tolerance of edges) |
100 | //! for handling subtle cases, such as tangential intersections. |
101 | Standard_EXPORT void Init (const Handle(ShapeExtend_CompositeSurface)& Grid, const TopLoc_Location& L, const TopoDS_Face& Face, const Standard_Real Prec); |
102 | |
103 | //! Returns (modifiable) flag for special 'closed' |
104 | //! mode which forces ComposeShell to consider |
105 | //! all pcurves on closed surface as modulo period. |
106 | //! This can reduce reliability, but allows to deal |
107 | //! with wires closed in 3d but open in 2d (missing seam) |
108 | //! Default is False |
109 | Standard_EXPORT Standard_Boolean& ClosedMode(); |
110 | |
111 | //! Performs the work on already loaded data. |
112 | Standard_EXPORT virtual Standard_Boolean Perform(); |
113 | |
114 | //! Splits edges in the original shape by grid. |
115 | //! This is a part of Perform() which does not produce any |
116 | //! resulting shape; the only result is filled context |
117 | //! where splittings are recorded. |
118 | //! |
119 | //! NOTE: If edge is splitted, it is replaced by wire, and |
120 | //! order of edges in the wire corresponds to FORWARD orientation |
121 | //! of the edge. |
122 | Standard_EXPORT void SplitEdges(); |
123 | |
124 | //! Returns resulting shell or face (or Null shape if not done) |
125 | Standard_EXPORT const TopoDS_Shape& Result() const; |
126 | |
127 | //! Queries status of last call to Perform() |
128 | //! OK : nothing done (some kind of error) |
129 | //! DONE1: splitting is done, at least one new face created |
130 | //! DONE2: splitting is done, several new faces obtained |
131 | //! FAIL1: misoriented wire encountered (handled) |
132 | //! FAIL2: recoverable parity error |
133 | //! FAIL3: edge with no pcurve on supporting face |
134 | //! FAIL4: unrecoverable algorithm error (parity check) |
135 | Standard_EXPORT Standard_Boolean Status (const ShapeExtend_Status status) const; |
136 | |
137 | //! Creates new faces from the set of (closed) wires. Each wire |
138 | //! is put on corresponding patch in the composite surface, |
139 | //! and all pcurves on the initial (pseudo)face are reassigned to |
140 | //! that surface. If several wires are one inside another, single |
141 | //! face is created. |
142 | Standard_EXPORT void DispatchWires (TopTools_SequenceOfShape& faces, ShapeFix_SequenceOfWireSegment& wires) const; |
143 | |
144 | //! Sets tool for transfer parameters from 3d to 2d and vice versa. |
145 | Standard_EXPORT void SetTransferParamTool (const Handle(ShapeAnalysis_TransferParameters)& TransferParam); |
146 | |
147 | //! Gets tool for transfer parameters from 3d to 2d and vice versa. |
148 | Standard_EXPORT Handle(ShapeAnalysis_TransferParameters) GetTransferParamTool() const; |
149 | |
150 | |
151 | |
152 | |
92efcf78 |
153 | DEFINE_STANDARD_RTTIEXT(ShapeFix_ComposeShell,ShapeFix_Root) |
42cf5bc1 |
154 | |
155 | protected: |
156 | |
157 | |
158 | //! Fill sequence of wire segments by wires from myFace |
159 | //! (pre-loaded). It performs reorder so that edges in segments |
160 | //! are well-ordered. The context is applied to all wires |
161 | //! before using them. |
162 | Standard_EXPORT void LoadWires (ShapeFix_SequenceOfWireSegment& seqw) const; |
163 | |
164 | //! Analyze tangencies and compute orientation code for wire segment |
165 | //! between two intersections: tells if segment is on left or right side |
166 | //! of cutting line, or tangent to it (by several points recomputed to 3d, |
167 | //! distance is compared with tolerance of corresponding edge). |
168 | Standard_EXPORT Standard_Integer ComputeCode (const Handle(ShapeExtend_WireData)& wire, const gp_Lin2d& line, const Standard_Integer begInd, const Standard_Integer endInd, const Standard_Real begPar, const Standard_Real endPar, const Standard_Boolean IsInternal = Standard_False); |
169 | |
170 | //! Splits edges in the wire by given indices of edges and |
171 | //! parameters on them. Returns resulting wire and vertices |
172 | //! corresponding to splitting parameters. If two consequtive |
173 | //! splitting points are too near one to another (with tolerance |
174 | //! of edge), edge is divided in single point. In the same way, |
175 | //! splitting which is too near to end of edge, is not applied |
176 | //! (end vertex is returned instead). |
177 | //! |
178 | //! NOTE: If edge is splitted, it is replaced by wire, and |
179 | //! order of edges in the wire corresponds to FORWARD orientation |
180 | //! of the edge. |
181 | Standard_EXPORT ShapeFix_WireSegment SplitWire (ShapeFix_WireSegment& wire, TColStd_SequenceOfInteger& indexes, const TColStd_SequenceOfReal& values, TopTools_SequenceOfShape& vertices, const TColStd_SequenceOfInteger& segcodes, const Standard_Boolean cutbyu, const Standard_Integer cutindex); |
182 | |
183 | //! Split edges in the wire by cutting line. |
184 | //! Wires with FORWARD or REVERSED orientation are considered |
185 | //! as closed. |
186 | //! |
187 | //! All modifications (splitting) are recorded in context, |
188 | //! except splitting of wires marked as EXTERNAL |
189 | //! (they are supposed to be former cutting lines). |
190 | //! |
191 | //! Method fills sequences of parameters of intersection points |
192 | //! of cutting line with all edges, their types, and corresponding |
193 | //! vertices (including ones created during splitting edges). |
194 | Standard_EXPORT Standard_Boolean SplitByLine (ShapeFix_WireSegment& wire, const gp_Lin2d& line, const Standard_Boolean cutbyu, const Standard_Integer cutindex, TColStd_SequenceOfReal& SplitLinePar, TColStd_SequenceOfInteger& SplitLineCode, TopTools_SequenceOfShape& SplitLineVertex); |
195 | |
196 | //! Split edges in the sequence of wires by cutting line. |
197 | //! Wires with FORWARD or REVERSED orientation are considered |
198 | //! as closed. |
199 | //! |
200 | //! Parts of cutting line which get inside the face (defined by |
201 | //! parity check of intersections with all wires) are added |
202 | //! into that sequence (with orientation EXTERNAL). Each part |
203 | //! is represented by one-edge wire segment with no 3d curve. |
204 | //! They share common vertices with all wires they intersect. |
205 | //! |
206 | //! All modifications (splitting) are recorded in context, |
207 | //! except splitting of wires marked as EXTERNAL |
208 | //! (they are supposed to be former cutting lines). |
209 | Standard_EXPORT void SplitByLine (ShapeFix_SequenceOfWireSegment& seqw, const gp_Lin2d& line, const Standard_Boolean cutbyu, const Standard_Integer cutindex); |
210 | |
211 | //! Split initial set of (closed) wires by grid of lines corresponding |
212 | //! to joints between patches on the composite surface. |
213 | //! Parts of joint lines which get inside the face are also added |
214 | //! into the sequence as wires with orientation EXTERNAL. |
215 | //! They share common vertices with all wires they intersect. |
216 | //! All modifications (splitting) are recorded in context, |
217 | //! except splitting of joint edge itself and wires marked as |
218 | //! EXTERNAL (they supposed to be another joint edges). |
219 | Standard_EXPORT void SplitByGrid (ShapeFix_SequenceOfWireSegment& seqw); |
220 | |
221 | //! Break wires into open wire segments by common vertices |
222 | //! (splitting points), so that each segment is either closed and |
223 | //! not touching others, or touches others at ends (have common |
224 | //! vertices). |
225 | //! After that, each wire segment lies on its own patch of grid. |
226 | Standard_EXPORT void BreakWires (ShapeFix_SequenceOfWireSegment& seqw); |
227 | |
228 | //! Collect set of wire segments (already splitted) into closed |
229 | //! wires. This is done by traversing all the segments in allowed |
230 | //! directions, starting only from the REVERSED and FORWARD and |
231 | //! taking EXTERNAL as necessary in fork points. Forks are detected |
232 | //! by common vertices. In fork point, most left way is seleccted |
233 | //! among all possible ways. |
234 | Standard_EXPORT void CollectWires (ShapeFix_SequenceOfWireSegment& wires, ShapeFix_SequenceOfWireSegment& seqw); |
235 | |
236 | //! Creates new faces on one path of grid. It dispatches given loops |
237 | //! (wires) into one or several faces depending on their mutual |
238 | //! position. |
239 | Standard_EXPORT void MakeFacesOnPatch (TopTools_SequenceOfShape& faces, const Handle(Geom_Surface)& surf, TopTools_SequenceOfShape& loops) const; |
240 | |
241 | TopAbs_Orientation myOrient; |
242 | TopoDS_Shape myResult; |
243 | Standard_Integer myStatus; |
244 | |
245 | |
246 | private: |
247 | |
248 | |
249 | Handle(ShapeExtend_CompositeSurface) myGrid; |
250 | TopLoc_Location myLoc; |
251 | TopoDS_Face myFace; |
252 | Standard_Real myUResolution; |
253 | Standard_Real myVResolution; |
254 | Handle(ShapeAnalysis_TransferParameters) myTransferParamTool; |
255 | Standard_Boolean myInvertEdgeStatus; |
256 | Standard_Boolean myClosedMode; |
257 | Standard_Boolean myUClosed; |
258 | Standard_Boolean myVClosed; |
259 | Standard_Real myUPeriod; |
260 | Standard_Real myVPeriod; |
261 | |
262 | |
263 | }; |
264 | |
265 | |
266 | |
267 | |
268 | |
269 | |
270 | |
271 | #endif // _ShapeFix_ComposeShell_HeaderFile |