|
|
|||
Warning, file /include/opencascade/ShapeFix_Wire.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // Created on: 1998-06-03 0002 // Created by: data exchange team 0003 // Copyright (c) 1998-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 _ShapeFix_Wire_HeaderFile 0018 #define _ShapeFix_Wire_HeaderFile 0019 0020 #include <Standard.hxx> 0021 0022 #include <Message_ProgressRange.hxx> 0023 #include <Standard_Integer.hxx> 0024 #include <Standard_Real.hxx> 0025 #include <ShapeFix_Root.hxx> 0026 #include <TopoDS_Wire.hxx> 0027 #include <ShapeExtend_Status.hxx> 0028 #include <ShapeAnalysis_Surface.hxx> 0029 0030 class ShapeFix_Edge; 0031 class ShapeAnalysis_Wire; 0032 class TopoDS_Wire; 0033 class TopoDS_Face; 0034 class ShapeExtend_WireData; 0035 class Geom_Surface; 0036 class TopLoc_Location; 0037 class ShapeAnalysis_WireOrder; 0038 0039 //! This class provides a set of tools for repairing a wire. 0040 //! 0041 //! These are methods Fix...(), organised in two levels: 0042 //! 0043 //! Level 1: Advanced - each method in this level fixes one separate problem, 0044 //! usually dealing with either single edge or connection of the 0045 //! two adjacent edges. These methods should be used carefully and 0046 //! called in right sequence, because some of them depend on others. 0047 //! 0048 //! Level 2: Public (API) - methods which group several methods of level 1 0049 //! and call them in a proper sequence in order to make some 0050 //! consistent set of fixes for a whole wire. It is possible to 0051 //! control calls to methods of the advanced level from methods of 0052 //! the public level by use of flags Fix..Mode() (see below). 0053 //! 0054 //! Fixes can be made in three ways: 0055 //! 1. Increasing tolerance of an edge or a vertex 0056 //! 2. Changing topology (adding/removing/replacing edge in the wire 0057 //! and/or replacing the vertex in the edge) 0058 //! 3. Changing geometry (shifting vertex or adjusting ends of edge 0059 //! curve to vertices, or recomputing curves of the edge) 0060 //! 0061 //! When fix can be made in more than one way (e.g., either 0062 //! by increasing tolerance or shifting a vertex), it is chosen 0063 //! according to the flags: 0064 //! ModifyTopologyMode - allows modification of the topology. 0065 //! This flag can be set when fixing a wire on 0066 //! the separate (free) face, and should be 0067 //! unset for face which is part of shell. 0068 //! ModifyGeometryMode - allows modification of the geometry. 0069 //! 0070 //! The order of descriptions of Fix() methods in this CDL 0071 //! approximately corresponds to the optimal order of calls. 0072 //! 0073 //! NOTE: most of fixing methods expect edges in the 0074 //! ShapeExtend_WireData to be ordered, so it is necessary to make 0075 //! call to FixReorder() before any other fixes 0076 //! 0077 //! ShapeFix_Wire should be initialized prior to any fix by the 0078 //! following data: 0079 //! a) Wire (ether TopoDS_Wire or ShapeExtend_Wire) 0080 //! b) Face or surface 0081 //! c) Precision 0082 //! d) Maximal tail angle and width 0083 //! This can be done either by calling corresponding methods 0084 //! (LoadWire, SetFace or SetSurface, SetPrecision, SetMaxTailAngle 0085 //! and SetMaxTailWidth), or 0086 //! by loading already filled ShapeAnalisis_Wire with method Load 0087 class ShapeFix_Wire : public ShapeFix_Root 0088 { 0089 0090 public: 0091 //! Empty Constructor, creates clear object with default flags 0092 Standard_EXPORT ShapeFix_Wire(); 0093 0094 //! Create new object with default flags and prepare it for use 0095 //! (Loads analyzer with all the data for the wire and face) 0096 Standard_EXPORT ShapeFix_Wire(const TopoDS_Wire& wire, 0097 const TopoDS_Face& face, 0098 const double prec); 0099 0100 //! Sets all modes to default 0101 Standard_EXPORT void ClearModes(); 0102 0103 //! Clears all statuses 0104 Standard_EXPORT void ClearStatuses(); 0105 0106 //! Load analyzer with all the data for the wire and face 0107 //! and drops all fixing statuses 0108 Standard_EXPORT void Init(const TopoDS_Wire& wire, const TopoDS_Face& face, const double prec); 0109 0110 //! Load analyzer with all the data already prepared 0111 //! and drops all fixing statuses 0112 //! If analyzer contains face, there is no need to set it 0113 //! by SetFace or SetSurface 0114 Standard_EXPORT void Init(const occ::handle<ShapeAnalysis_Wire>& saw); 0115 0116 //! Load data for the wire, and drops all fixing statuses 0117 Standard_EXPORT void Load(const TopoDS_Wire& wire); 0118 0119 //! Load data for the wire, and drops all fixing statuses 0120 Standard_EXPORT void Load(const occ::handle<ShapeExtend_WireData>& sbwd); 0121 0122 //! Set working face for the wire 0123 void SetFace(const TopoDS_Face& face); 0124 0125 //! Set working face for the wire and surface analysis object 0126 void SetFace(const TopoDS_Face& theFace, 0127 const occ::handle<ShapeAnalysis_Surface>& theSurfaceAnalysis); 0128 0129 //! Set surface analysis for the wire 0130 void SetSurface(const occ::handle<ShapeAnalysis_Surface>& theSurfaceAnalysis); 0131 0132 //! Set surface for the wire 0133 void SetSurface(const occ::handle<Geom_Surface>& surf); 0134 0135 //! Set surface for the wire 0136 void SetSurface(const occ::handle<Geom_Surface>& surf, const TopLoc_Location& loc); 0137 0138 //! Set working precision (to root and to analyzer) 0139 Standard_EXPORT void SetPrecision(const double prec) override; 0140 0141 //! Sets the maximal allowed angle of the tails in radians. 0142 Standard_EXPORT void SetMaxTailAngle(const double theMaxTailAngle); 0143 0144 //! Sets the maximal allowed width of the tails. 0145 Standard_EXPORT void SetMaxTailWidth(const double theMaxTailWidth); 0146 0147 //! Tells if the wire is loaded 0148 bool IsLoaded() const; 0149 0150 //! Tells if the wire and face are loaded 0151 bool IsReady() const; 0152 0153 //! returns number of edges in the working wire 0154 Standard_EXPORT int NbEdges() const; 0155 0156 //! Makes the resulting Wire (by basic Brep_Builder) 0157 TopoDS_Wire Wire() const; 0158 0159 //! Makes the resulting Wire (by BRepAPI_MakeWire) 0160 TopoDS_Wire WireAPIMake() const; 0161 0162 //! returns field Analyzer (working tool) 0163 occ::handle<ShapeAnalysis_Wire> Analyzer() const; 0164 0165 //! returns working wire 0166 const occ::handle<ShapeExtend_WireData>& WireData() const; 0167 0168 //! returns working face (Analyzer.Face()) 0169 const TopoDS_Face& Face() const; 0170 0171 //! Returns (modifiable) the flag which defines whether it is 0172 //! allowed to modify topology of the wire during fixing 0173 //! (adding/removing edges etc.) 0174 bool& ModifyTopologyMode(); 0175 0176 //! Returns (modifiable) the flag which defines whether the Fix..() 0177 //! methods are allowed to modify geometry of the edges and vertices 0178 bool& ModifyGeometryMode(); 0179 0180 //! Returns (modifiable) the flag which defines whether the Fix..() 0181 //! methods are allowed to modify RemoveLoop of the edges 0182 int& ModifyRemoveLoopMode(); 0183 0184 //! Returns (modifiable) the flag which defines whether the wire 0185 //! is to be closed (by calling methods like FixDegenerated() 0186 //! and FixConnected() for last and first edges). 0187 bool& ClosedWireMode(); 0188 0189 //! Returns (modifiable) the flag which defines whether the 2d (True) 0190 //! representation of the wire is preferable over 3d one (in the 0191 //! case of ambiguity in FixEdgeCurves). 0192 bool& PreferencePCurveMode(); 0193 0194 //! Returns (modifiable) the flag which defines whether tool 0195 //! tries to fix gaps first by changing curves ranges (i.e. 0196 //! using intersection, extrema, projections) or not. 0197 bool& FixGapsByRangesMode(); 0198 0199 int& FixReorderMode(); 0200 0201 int& FixSmallMode(); 0202 0203 int& FixConnectedMode(); 0204 0205 int& FixEdgeCurvesMode(); 0206 0207 int& FixDegeneratedMode(); 0208 0209 int& FixSelfIntersectionMode(); 0210 0211 int& FixLackingMode(); 0212 0213 int& FixGaps3dMode(); 0214 0215 //! Returns (modifiable) the flag for corresponding Fix..() method 0216 //! which defines whether this method will be called from the 0217 //! method APIFix(): 0218 //! -1 default 0219 //! 1 method will be called 0220 //! 0 method will not be called 0221 int& FixGaps2dMode(); 0222 0223 int& FixReversed2dMode(); 0224 0225 int& FixRemovePCurveMode(); 0226 0227 int& FixAddPCurveMode(); 0228 0229 int& FixRemoveCurve3dMode(); 0230 0231 int& FixAddCurve3dMode(); 0232 0233 int& FixSeamMode(); 0234 0235 int& FixShiftedMode(); 0236 0237 int& FixSameParameterMode(); 0238 0239 int& FixVertexToleranceMode(); 0240 0241 int& FixNotchedEdgesMode(); 0242 0243 int& FixSelfIntersectingEdgeMode(); 0244 0245 int& FixIntersectingEdgesMode(); 0246 0247 //! Returns (modifiable) the flag for corresponding Fix..() method 0248 //! which defines whether this method will be called from the 0249 //! corresponding Fix..() method of the public level: 0250 //! -1 default 0251 //! 1 method will be called 0252 //! 0 method will not be called 0253 int& FixNonAdjacentIntersectingEdgesMode(); 0254 0255 int& FixTailMode(); 0256 0257 //! This method performs all the available fixes. 0258 //! If some fix is turned on or off explicitly by the Fix..Mode() flag, 0259 //! this fix is either called or not depending on that flag. 0260 //! Else (i.e. if flag is default) fix is called depending on the 0261 //! situation: some fixes are not called or are limited if order of 0262 //! edges in the wire is not OK, or depending on modes 0263 //! 0264 //! The order of the fixes and default behaviour of Perform() are: 0265 //! FixReorder 0266 //! FixSmall (with lockvtx true if ! TopoMode or if wire is not ordered) 0267 //! FixConnected (if wire is ordered) 0268 //! FixEdgeCurves (without FixShifted if wire is not ordered) 0269 //! FixDegenerated (if wire is ordered) 0270 //! FixSelfIntersection (if wire is ordered and ClosedMode is True) 0271 //! FixLacking (if wire is ordered) 0272 Standard_EXPORT bool Perform(const Message_ProgressRange& theProgress = Message_ProgressRange()); 0273 0274 //! Performs an analysis and reorders edges in the wire using class WireOrder. 0275 //! Flag <theModeBoth> determines the use of miscible mode if necessary. 0276 Standard_EXPORT bool FixReorder(bool theModeBoth = false); 0277 0278 //! Applies FixSmall(num) to all edges in the wire 0279 Standard_EXPORT int FixSmall(const bool lockvtx, const double precsmall = 0.0); 0280 0281 //! Applies FixConnected(num) to all edges in the wire 0282 //! Connection between first and last edges is treated only if 0283 //! flag ClosedMode is True 0284 //! If <prec> is -1 then MaxTolerance() is taken. 0285 Standard_EXPORT bool FixConnected(const double prec = -1.0); 0286 0287 //! Groups the fixes dealing with 3d and pcurves of the edges. 0288 //! The order of the fixes and the default behaviour are: 0289 //! ShapeFix_Edge::FixReversed2d 0290 //! ShapeFix_Edge::FixRemovePCurve (only if forced) 0291 //! ShapeFix_Edge::FixAddPCurve 0292 //! ShapeFix_Edge::FixRemoveCurve3d (only if forced) 0293 //! ShapeFix_Edge::FixAddCurve3d 0294 //! FixSeam, 0295 //! FixShifted, 0296 //! ShapeFix_Edge::FixSameParameter 0297 Standard_EXPORT bool FixEdgeCurves(); 0298 0299 //! Applies FixDegenerated(num) to all edges in the wire 0300 //! Connection between first and last edges is treated only if 0301 //! flag ClosedMode is True 0302 Standard_EXPORT bool FixDegenerated(); 0303 0304 //! Applies FixSelfIntersectingEdge(num) and 0305 //! FixIntersectingEdges(num) to all edges in the wire and 0306 //! FixIntersectingEdges(num1, num2) for all pairs num1 and num2 0307 //! such that num2 >= num1 + 2 0308 //! and removes wrong edges if any 0309 Standard_EXPORT bool FixSelfIntersection(); 0310 0311 //! Applies FixLacking(num) to all edges in the wire 0312 //! Connection between first and last edges is treated only if 0313 //! flag ClosedMode is True 0314 //! If <force> is False (default), test for connectness is done with 0315 //! precision of vertex between edges, else it is done with minimal 0316 //! value of vertex tolerance and Analyzer.Precision(). 0317 //! Hence, <force> will lead to inserting lacking edges in replacement 0318 //! of vertices which have big tolerances. 0319 Standard_EXPORT bool FixLacking(const bool force = false); 0320 0321 //! Fixes a wire to be well closed 0322 //! It performs FixConnected, FixDegenerated and FixLacking between 0323 //! last and first edges (independingly on flag ClosedMode and modes 0324 //! for these fixings) 0325 //! If <prec> is -1 then MaxTolerance() is taken. 0326 Standard_EXPORT bool FixClosed(const double prec = -1.0); 0327 0328 //! Fixes gaps between ends of 3d curves on adjacent edges 0329 //! myPrecision is used to detect the gaps. 0330 Standard_EXPORT bool FixGaps3d(); 0331 0332 //! Fixes gaps between ends of pcurves on adjacent edges 0333 //! myPrecision is used to detect the gaps. 0334 Standard_EXPORT bool FixGaps2d(); 0335 0336 //! Reorder edges in the wire as determined by WireOrder 0337 //! that should be filled and computed before 0338 Standard_EXPORT bool FixReorder(const ShapeAnalysis_WireOrder& wi); 0339 0340 //! Fixes Null Length Edge to be removed 0341 //! If an Edge has Null Length (regarding preci, or <precsmall> 0342 //! - what is smaller), it should be removed 0343 //! It can be with no problem if its two vertices are the same 0344 //! Else, if lockvtx is False, it is removed and its end vertex 0345 //! is put on the preceding edge 0346 //! But if lockvtx is True, this edge must be kept ... 0347 Standard_EXPORT bool FixSmall(const int num, const bool lockvtx, const double precsmall); 0348 0349 //! Fixes connected edges (preceding and current) 0350 //! Forces Vertices (end of preceding-begin of current) to be 0351 //! the same one 0352 //! Tests with starting preci or, if given greater, <prec> 0353 //! If <prec> is -1 then MaxTolerance() is taken. 0354 //! If <theUpdateWire> is true, synchronizes wire data with context replacements. 0355 Standard_EXPORT bool FixConnected(const int num, 0356 const double prec, 0357 const bool theUpdateWire = true); 0358 0359 //! Fixes a seam edge 0360 //! A Seam edge has two pcurves, one for forward. one for reversed 0361 //! The forward pcurve must be set as first 0362 //! 0363 //! NOTE that correct order of pcurves in the seam edge depends on 0364 //! its orientation (i.e., on orientation of the wire, method of 0365 //! exploration of edges etc.). 0366 //! Since wire represented by the ShapeExtend_WireData is always forward 0367 //! (orientation is accounted by edges), it will work correct if: 0368 //! 1. Wire created from ShapeExtend_WireData with methods 0369 //! ShapeExtend_WireData::Wire..() is added into the FORWARD face 0370 //! (orientation can be applied later) 0371 //! 2. Wire is extracted from the face with orientation not composed 0372 //! with orientation of the face 0373 Standard_EXPORT bool FixSeam(const int num); 0374 0375 //! Fixes edges which have pcurves shifted by whole parameter 0376 //! range on the closed surface (the case may occur if pcurve 0377 //! of edge was computed by projecting 3d curve, which goes 0378 //! along the seam). 0379 //! It compares each two consequent edges and tries to connect them 0380 //! if distance between ends is near to range of the surface. 0381 //! It also can detect and fix the case if all pcurves are connected, 0382 //! but lie out of parametric bounds of the surface. 0383 //! In addition to FixShifted from ShapeFix_Wire, more 0384 //! sophisticated check of degenerate points is performed, 0385 //! and special cases like sphere given by two meridians 0386 //! are treated. 0387 Standard_EXPORT bool FixShifted(); 0388 0389 //! Fixes Degenerated Edge 0390 //! Checks an <num-th> edge or a point between <num>th-1 and <num>th 0391 //! edges for a singularity on a supporting surface. 0392 //! If singularity is detected, either adds new degenerated edge 0393 //! (before <num>th), or makes <num>th edge to be degenerated. 0394 Standard_EXPORT bool FixDegenerated(const int num); 0395 0396 //! Fixes Lacking Edge 0397 //! Test if two adjucent edges are disconnected in 2d (while 0398 //! connected in 3d), and in that case either increase tolerance 0399 //! of the vertex or add a new edge (straight in 2d space), in 0400 //! order to close wire in 2d. 0401 //! Returns True if edge was added or tolerance was increased. 0402 Standard_EXPORT bool FixLacking(const int num, const bool force = false); 0403 0404 Standard_EXPORT bool FixNotchedEdges(); 0405 0406 //! Fixes gap between ends of 3d curves on num-1 and num-th edges. 0407 //! myPrecision is used to detect the gap. 0408 //! If convert is True, converts curves to bsplines to bend. 0409 Standard_EXPORT bool FixGap3d(const int num, const bool convert = false); 0410 0411 //! Fixes gap between ends of pcurves on num-1 and num-th edges. 0412 //! myPrecision is used to detect the gap. 0413 //! If convert is True, converts pcurves to bsplines to bend. 0414 Standard_EXPORT bool FixGap2d(const int num, const bool convert = false); 0415 0416 Standard_EXPORT bool FixTails(); 0417 0418 bool StatusReorder(const ShapeExtend_Status status) const; 0419 0420 bool StatusSmall(const ShapeExtend_Status status) const; 0421 0422 bool StatusConnected(const ShapeExtend_Status status) const; 0423 0424 bool StatusEdgeCurves(const ShapeExtend_Status status) const; 0425 0426 bool StatusDegenerated(const ShapeExtend_Status status) const; 0427 0428 bool StatusSelfIntersection(const ShapeExtend_Status status) const; 0429 0430 bool StatusLacking(const ShapeExtend_Status status) const; 0431 0432 bool StatusClosed(const ShapeExtend_Status status) const; 0433 0434 bool StatusGaps3d(const ShapeExtend_Status status) const; 0435 0436 bool StatusGaps2d(const ShapeExtend_Status status) const; 0437 0438 bool StatusNotches(const ShapeExtend_Status status) const; 0439 0440 //! Querying the status of performed API fixing procedures 0441 //! Each Status..() methods gives information about the last call to 0442 //! the corresponding Fix..() method of API level: 0443 //! OK : no problems detected; nothing done 0444 //! DONE: some problem(s) was(were) detected and successfully fixed 0445 //! FAIL: some problem(s) cannot be fixed 0446 bool StatusRemovedSegment() const; 0447 0448 bool StatusFixTails(const ShapeExtend_Status status) const; 0449 0450 //! Queries the status of last call to methods Fix... of 0451 //! advanced level 0452 //! For details see corresponding methods; universal statuses are: 0453 //! OK : problem not detected; nothing done 0454 //! DONE: problem was detected and successfully fixed 0455 //! FAIL: problem cannot be fixed 0456 bool LastFixStatus(const ShapeExtend_Status status) const; 0457 0458 //! Returns tool for fixing wires. 0459 occ::handle<ShapeFix_Edge> FixEdgeTool() const; 0460 0461 DEFINE_STANDARD_RTTIEXT(ShapeFix_Wire, ShapeFix_Root) 0462 0463 protected: 0464 //! Updates WireData if some replacements are made 0465 //! This is necessary for wires (unlike other shape types) 0466 //! since one edge can present in wire several times 0467 Standard_EXPORT void UpdateWire(); 0468 0469 occ::handle<ShapeFix_Edge> myFixEdge; 0470 occ::handle<ShapeAnalysis_Wire> myAnalyzer; 0471 bool myGeomMode; 0472 bool myTopoMode; 0473 bool myClosedMode; 0474 bool myPreference2d; 0475 bool myFixGapsByRanges; 0476 int myFixReversed2dMode; 0477 int myFixRemovePCurveMode; 0478 int myFixAddPCurveMode; 0479 int myFixRemoveCurve3dMode; 0480 int myFixAddCurve3dMode; 0481 int myFixSeamMode; 0482 int myFixShiftedMode; 0483 int myFixSameParameterMode; 0484 int myFixVertexToleranceMode; 0485 int myFixNotchedEdgesMode; 0486 int myFixSelfIntersectingEdgeMode; 0487 int myFixIntersectingEdgesMode; 0488 int myFixNonAdjacentIntersectingEdgesMode; 0489 int myFixTailMode; 0490 int myRemoveLoopMode; 0491 int myFixReorderMode; 0492 int myFixSmallMode; 0493 int myFixConnectedMode; 0494 int myFixEdgeCurvesMode; 0495 int myFixDegeneratedMode; 0496 int myFixSelfIntersectionMode; 0497 int myFixLackingMode; 0498 int myFixGaps3dMode; 0499 int myFixGaps2dMode; 0500 int myLastFixStatus; 0501 int myStatusReorder; 0502 int myStatusSmall; 0503 int myStatusConnected; 0504 int myStatusEdgeCurves; 0505 int myStatusDegenerated; 0506 int myStatusClosed; 0507 int myStatusSelfIntersection; 0508 int myStatusLacking; 0509 int myStatusGaps3d; 0510 int myStatusGaps2d; 0511 bool myStatusRemovedSegment; 0512 int myStatusNotches; 0513 int myStatusFixTails; 0514 double myMaxTailAngleSine; 0515 double myMaxTailWidth; 0516 0517 private: 0518 //! Detect and fix self-intersecting pcurve of edge <num>. 0519 //! Fix is made by one of two methods: 0520 //! - cut out the self-intersection loop on pcurve (thus 0521 //! producing C0 pcurve). This also increases tolerance of edge 0522 //! in order to satisfy SameParameter requirement. 0523 //! - increase tolerance of the vertex of edge nearest to the 0524 //! self-intersection point so that it comprises that point. 0525 //! The first method is considered only if ModifyGeometryMode 0526 //! is True. In that case, the method which requires less 0527 //! increasing of tolerance is selected. 0528 Standard_EXPORT bool FixSelfIntersectingEdge(const int num); 0529 0530 //! Test if two consequent edges are intersecting and fix it 0531 //! by increasing of tolerance of vertex between edges, 0532 //! shifting this vertex to the point of intersection, 0533 //! cutting edges to the intersection point. 0534 //! It also can give signal to remove edge if it whole is cut by 0535 //! intersection (if flag ModifyTopologyMode is set). 0536 Standard_EXPORT bool FixIntersectingEdges(const int num); 0537 0538 //! Tests if two edges <num1> and <num2> are intersecting and 0539 //! fix intersection by increasing of tolerance of vertex 0540 //! nearest to the point of intersection. 0541 Standard_EXPORT bool FixIntersectingEdges(const int num1, const int num2); 0542 0543 Standard_EXPORT void FixDummySeam(const int num); 0544 }; 0545 0546 #include <ShapeFix_Wire.lxx> 0547 0548 #endif // _ShapeFix_Wire_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|