]> OCCT Git - occt-copy.git/commitdiff
Version Open CASCADE 670 with fixes
authorgka <gka@opencascade.com>
Fri, 10 Oct 2014 11:19:04 +0000 (15:19 +0400)
committergka <gka@opencascade.com>
Fri, 10 Oct 2014 11:48:10 +0000 (15:48 +0400)
65 files changed:
dox/LICENSE.md [deleted file]
src/Adaptor2d/Adaptor2d_Curve2d.cdl
src/Adaptor2d/Adaptor2d_Curve2d.cxx
src/BOPAlgo/BOPAlgo_PaveFiller.cxx
src/BOPAlgo/BOPAlgo_WireSplitter_1.cxx
src/BOPTest/BOPTest_PartitionCommands.cxx
src/BOPTools/BOPTools_AlgoTools2D.cxx
src/BRepAlgoAPI/BRepAlgoAPI_Check.cdl
src/BRepAlgoAPI/BRepAlgoAPI_Check.cxx
src/BRepClass3d/BRepClass3d_SClassifier.cxx
src/BRepClass3d/BRepClass3d_SolidExplorer.cxx
src/BRepExtrema/BRepExtrema.cdl
src/BRepExtrema/BRepExtrema_DistShapeShape.cxx
src/BRepExtrema/BRepExtrema_DistShapeShape.hxx
src/BRepExtrema/BRepExtrema_DistanceSS.cxx
src/BRepExtrema/BRepExtrema_DistanceSS.hxx
src/BRepExtrema/BRepExtrema_ExtCC.cxx
src/BRepExtrema/BRepExtrema_ExtCC.hxx
src/BRepExtrema/BRepExtrema_ExtCF.cxx
src/BRepExtrema/BRepExtrema_ExtCF.hxx
src/BRepExtrema/BRepExtrema_ExtFF.cxx
src/BRepExtrema/BRepExtrema_ExtFF.hxx
src/BRepExtrema/BRepExtrema_ExtPC.cxx
src/BRepExtrema/BRepExtrema_ExtPC.hxx
src/BRepExtrema/BRepExtrema_ExtPF.cxx
src/BRepExtrema/BRepExtrema_ExtPF.hxx
src/BRepExtrema/BRepExtrema_Poly.cxx
src/BRepExtrema/BRepExtrema_Poly.hxx
src/BRepExtrema/BRepExtrema_SeqOfSolution.hxx
src/BRepExtrema/BRepExtrema_SolutionElem.hxx
src/BRepExtrema/BRepExtrema_SupportType.hxx
src/BRepFeat/BRepFeat.cxx
src/BRepFill/BRepFill_MultiLine.cxx
src/BRepFill/BRepFill_TrimSurfaceTool.cxx
src/BRepIntCurveSurface/BRepIntCurveSurface.cdl
src/BRepIntCurveSurface/BRepIntCurveSurface_Inter.cdl
src/BRepIntCurveSurface/BRepIntCurveSurface_Inter.cxx
src/BRepTest/BRepTest_OtherCommands.cxx
src/Extrema/Extrema_ExtCS.cxx
src/Extrema/Extrema_ExtPExtS.cxx
src/Extrema/Extrema_GenExtCS.cxx
src/Geom2dAdaptor/Geom2dAdaptor_Curve.cdl
src/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx
src/Geom2dInt/Geom2dInt_CurveTool.cdl
src/Geom2dInt/Geom2dInt_CurveTool.gxx
src/GeomAdaptor/GeomAdaptor_Curve.cxx
src/IntPatch/IntPatch_PrmPrmIntersection.cxx
src/IntPatch/IntPatch_RstInt.cdl
src/IntPatch/IntPatch_RstInt.cxx
src/IntPatch/IntPatch_WLine.cdl
src/IntPatch/IntPatch_WLine.cxx
src/IntPolyh/IntPolyh_MaillageAffinage.cxx
src/IntTools/IntTools_FaceFace.cxx
src/IntTools/IntTools_LineConstructor.cxx
src/IntWalk/IntWalk_PWalking.cdl
src/IntWalk/IntWalk_PWalking_1.gxx
src/LocOpe/LocOpe_CurveShapeIntersector.cxx
src/LocOpe/LocOpe_SplitShape.cxx
src/LocOpe/LocOpe_WiresOnShape.cxx
src/NCollection/NCollection_Vec2.hxx
src/NCollection/NCollection_Vec3.hxx
src/NCollection/NCollection_Vec4.hxx
src/ProjLib/ProjLib_ProjectedCurve.cxx
src/ShapeAnalysis/ShapeAnalysis_Edge.cxx
src/ShapeAnalysis/ShapeAnalysis_FreeBounds.cxx

diff --git a/dox/LICENSE.md b/dox/LICENSE.md
deleted file mode 100755 (executable)
index bc82745..0000000
+++ /dev/null
@@ -1,521 +0,0 @@
-License {#occt_public_license}
-=======
-
-Open CASCADE Technology is available under GNU Lesser General Public License 
-(LGPL) version 2.1 with additional exception.
-
-@section license_lgpl_21 GNU LESSER GENERAL PUBLIC LICENSE
-
-    Version 2.1, February 1999
-
-    Copyright (C) 1991, 1999 Free Software Foundation, Inc.
-    51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-    Everyone is permitted to copy and distribute verbatim copies
-    of this license document, but changing it is not allowed.
-
-    [This is the first released version of the Lesser GPL.  It also counts
-    as the successor of the GNU Library Public License, version 2, hence
-    the version number 2.1.]
-
-### Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard.  To achieve this, non-free programs must be
-allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
-### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
--  0. This License Agreement applies to any software library or other
-   program which contains a notice placed by the copyright holder or
-   other authorized party saying it may be distributed under the terms of
-   this Lesser General Public License (also called "this License").
-   Each licensee is addressed as "you".
-
-   A "library" means a collection of software functions and/or data
-   prepared so as to be conveniently linked with application programs
-   (which use some of those functions and data) to form executables.
-
-   The "Library", below, refers to any such software library or work
-   which has been distributed under these terms.  A "work based on the
-   Library" means either the Library or any derivative work under
-   copyright law: that is to say, a work containing the Library or a
-   portion of it, either verbatim or with modifications and/or translated
-   straightforwardly into another language.  (Hereinafter, translation is
-   included without limitation in the term "modification".)
-
-   "Source code" for a work means the preferred form of the work for
-   making modifications to it.  For a library, complete source code means
-   all the source code for all modules it contains, plus any associated
-   interface definition files, plus the scripts used to control compilation
-   and installation of the library.
-
-   Activities other than copying, distribution and modification are not
-   covered by this License; they are outside its scope.  The act of
-   running a program using the Library is not restricted, and output from
-   such a program is covered only if its contents constitute a work based
-   on the Library (independent of the use of the Library in a tool for
-   writing it).  Whether that is true depends on what the Library does
-   and what the program that uses the Library does.
-  
-1. You may copy and distribute verbatim copies of the Library's
-   complete source code as you receive it, in any medium, provided that
-   you conspicuously and appropriately publish on each copy an
-   appropriate copyright notice and disclaimer of warranty; keep intact
-   all the notices that refer to this License and to the absence of any
-   warranty; and distribute a copy of this License along with the
-   Library.
-
-   You may charge a fee for the physical act of transferring a copy,
-   and you may at your option offer warranty protection in exchange for a
-   fee.
-
-2. You may modify your copy or copies of the Library or any portion
-   of it, thus forming a work based on the Library, and copy and
-   distribute such modifications or work under the terms of Section 1
-   above, provided that you also meet all of these conditions:
-
-   1. The modified work must itself be a software library.
-
-   2. You must cause the files modified to carry prominent notices
-      stating that you changed the files and the date of any change.
-
-   3. You must cause the whole of the work to be licensed at no
-      charge to all third parties under the terms of this License.
-
-   4. If a facility in the modified Library refers to a function or a
-      table of data to be supplied by an application program that uses
-      the facility, other than as an argument passed when the facility
-      is invoked, then you must make a good faith effort to ensure that,
-      in the event an application does not supply such function or
-      table, the facility still operates, and performs whatever part of
-      its purpose remains meaningful.
-
-      (For example, a function in a library to compute square roots has
-      a purpose that is entirely well-defined independent of the
-      application.  Therefore, Subsection 2d requires that any
-      application-supplied function or table used by this function must
-      be optional: if the application does not supply it, the square
-      root function must still compute square roots.)
-
-   These requirements apply to the modified work as a whole.  If
-   identifiable sections of that work are not derived from the Library,
-   and can be reasonably considered independent and separate works in
-   themselves, then this License, and its terms, do not apply to those
-   sections when you distribute them as separate works.  But when you
-   distribute the same sections as part of a whole which is a work based
-   on the Library, the distribution of the whole must be on the terms of
-   this License, whose permissions for other licensees extend to the
-   entire whole, and thus to each and every part regardless of who wrote
-   it.
-
-   Thus, it is not the intent of this section to claim rights or contest
-   your rights to work written entirely by you; rather, the intent is to
-   exercise the right to control the distribution of derivative or
-   collective works based on the Library.
-
-   In addition, mere aggregation of another work not based on the Library
-   with the Library (or with a work based on the Library) on a volume of
-   a storage or distribution medium does not bring the other work under
-   the scope of this License.
-
-3. You may opt to apply the terms of the ordinary GNU General Public
-   License instead of this License to a given copy of the Library.  To do
-   this, you must alter all the notices that refer to this License, so
-   that they refer to the ordinary GNU General Public License, version 2,
-   instead of to this License.  (If a newer version than version 2 of the
-   ordinary GNU General Public License has appeared, then you can specify
-   that version instead if you wish.)  Do not make any other change in
-   these notices.
-
-   Once this change is made in a given copy, it is irreversible for
-   that copy, so the ordinary GNU General Public License applies to all
-   subsequent copies and derivative works made from that copy.
-
-   This option is useful when you wish to copy part of the code of
-   the Library into a program that is not a library.
-
-4. You may copy and distribute the Library (or a portion or
-   derivative of it, under Section 2) in object code or executable form
-   under the terms of Sections 1 and 2 above provided that you accompany
-   it with the complete corresponding machine-readable source code, which
-   must be distributed under the terms of Sections 1 and 2 above on a
-   medium customarily used for software interchange.
-
-   If distribution of object code is made by offering access to copy
-   from a designated place, then offering equivalent access to copy the
-   source code from the same place satisfies the requirement to
-   distribute the source code, even though third parties are not
-   compelled to copy the source along with the object code.
-
-5. A program that contains no derivative of any portion of the
-   Library, but is designed to work with the Library by being compiled or
-   linked with it, is called a "work that uses the Library".  Such a
-   work, in isolation, is not a derivative work of the Library, and
-   therefore falls outside the scope of this License.
-
-   However, linking a "work that uses the Library" with the Library
-   creates an executable that is a derivative of the Library (because it
-   contains portions of the Library), rather than a "work that uses the
-   library".  The executable is therefore covered by this License.
-   Section 6 states terms for distribution of such executables.
-
-   When a "work that uses the Library" uses material from a header file
-   that is part of the Library, the object code for the work may be a
-   derivative work of the Library even though the source code is not.
-   Whether this is true is especially significant if the work can be
-   linked without the Library, or if the work is itself a library.  The
-   threshold for this to be true is not precisely defined by law.
-
-   If such an object file uses only numerical parameters, data
-   structure layouts and accessors, and small macros and small inline
-   functions (ten lines or less in length), then the use of the object
-   file is unrestricted, regardless of whether it is legally a derivative
-   work.  (Executables containing this object code plus portions of the
-   Library will still fall under Section 6.)
-
-   Otherwise, if the work is a derivative of the Library, you may
-   distribute the object code for the work under the terms of Section 6.
-   Any executables containing that work also fall under Section 6,
-   whether or not they are linked directly with the Library itself.
-
-6. As an exception to the Sections above, you may also combine or
-   link a "work that uses the Library" with the Library to produce a
-   work containing portions of the Library, and distribute that work
-   under terms of your choice, provided that the terms permit
-   modification of the work for the customer's own use and reverse
-   engineering for debugging such modifications.
-
-   You must give prominent notice with each copy of the work that the
-   Library is used in it and that the Library and its use are covered by
-   this License.  You must supply a copy of this License.  If the work
-   during execution displays copyright notices, you must include the
-   copyright notice for the Library among them, as well as a reference
-   directing the user to the copy of this License.  Also, you must do one
-   of these things:
-
-   1. Accompany the work with the complete corresponding
-      machine-readable source code for the Library including whatever
-      changes were used in the work (which must be distributed under
-      Sections 1 and 2 above); and, if the work is an executable linked
-      with the Library, with the complete machine-readable "work that
-      uses the Library", as object code and/or source code, so that the
-      user can modify the Library and then relink to produce a modified
-      executable containing the modified Library.  (It is understood
-      that the user who changes the contents of definitions files in the
-      Library will not necessarily be able to recompile the application
-      to use the modified definitions.)
-
-   2. Use a suitable shared library mechanism for linking with the
-      Library.  A suitable mechanism is one that (1) uses at run time a
-      copy of the library already present on the user's computer system,
-      rather than copying library functions into the executable, and (2)
-      will operate properly with a modified version of the library, if
-      the user installs one, as long as the modified version is
-      interface-compatible with the version that the work was made with.
-
-   3. Accompany the work with a written offer, valid for at
-      least three years, to give the same user the materials
-      specified in Subsection 6a, above, for a charge no more
-      than the cost of performing this distribution.
-
-   4. If distribution of the work is made by offering access to copy
-      from a designated place, offer equivalent access to copy the above
-      specified materials from the same place.
-
-   5. Verify that the user has already received a copy of these
-      materials or that you have already sent this user a copy.
-
-   For an executable, the required form of the "work that uses the
-   Library" must include any data and utility programs needed for
-   reproducing the executable from it.  However, as a special exception,
-   the materials to be distributed need not include anything that is
-   normally distributed (in either source or binary form) with the major
-   components (compiler, kernel, and so on) of the operating system on
-   which the executable runs, unless that component itself accompanies
-   the executable.
-
-   It may happen that this requirement contradicts the license
-   restrictions of other proprietary libraries that do not normally
-   accompany the operating system.  Such a contradiction means you cannot
-   use both them and the Library together in an executable that you
-   distribute.
-
-7. You may place library facilities that are a work based on the
-   Library side-by-side in a single library together with other library
-   facilities not covered by this License, and distribute such a combined
-   library, provided that the separate distribution of the work based on
-   the Library and of the other library facilities is otherwise
-   permitted, and provided that you do these two things:
-
-   1. Accompany the combined library with a copy of the same work
-      based on the Library, uncombined with any other library
-      facilities.  This must be distributed under the terms of the
-      Sections above.
-
-   2. Give prominent notice with the combined library of the fact
-      that part of it is a work based on the Library, and explaining
-      where to find the accompanying uncombined form of the same work.
-
-8. You may not copy, modify, sublicense, link with, or distribute
-   the Library except as expressly provided under this License.  Any
-   attempt otherwise to copy, modify, sublicense, link with, or
-   distribute the Library is void, and will automatically terminate your
-   rights under this License.  However, parties who have received copies,
-   or rights, from you under this License will not have their licenses
-   terminated so long as such parties remain in full compliance.
-
-9. You are not required to accept this License, since you have not
-   signed it.  However, nothing else grants you permission to modify or
-   distribute the Library or its derivative works.  These actions are
-   prohibited by law if you do not accept this License.  Therefore, by
-   modifying or distributing the Library (or any work based on the
-   Library), you indicate your acceptance of this License to do so, and
-   all its terms and conditions for copying, distributing or modifying
-   the Library or works based on it.
-
-10. Each time you redistribute the Library (or any work based on the
-   Library), the recipient automatically receives a license from the
-   original licensor to copy, distribute, link with or modify the Library
-   subject to these terms and conditions.  You may not impose any further
-   restrictions on the recipients' exercise of the rights granted herein.
-   You are not responsible for enforcing compliance by third parties with
-   this License.
-
-11. If, as a consequence of a court judgment or allegation of patent
-   infringement or for any other reason (not limited to patent issues),
-   conditions are imposed on you (whether by court order, agreement or
-   otherwise) that contradict the conditions of this License, they do not
-   excuse you from the conditions of this License.  If you cannot
-   distribute so as to satisfy simultaneously your obligations under this
-   License and any other pertinent obligations, then as a consequence you
-   may not distribute the Library at all.  For example, if a patent
-   license would not permit royalty-free redistribution of the Library by
-   all those who receive copies directly or indirectly through you, then
-   the only way you could satisfy both it and this License would be to
-   refrain entirely from distribution of the Library.
-
-   If any portion of this section is held invalid or unenforceable under any
-   particular circumstance, the balance of the section is intended to apply,
-   and the section as a whole is intended to apply in other circumstances.
-
-   It is not the purpose of this section to induce you to infringe any
-   patents or other property right claims or to contest validity of any
-   such claims; this section has the sole purpose of protecting the
-   integrity of the free software distribution system which is
-   implemented by public license practices.  Many people have made
-   generous contributions to the wide range of software distributed
-   through that system in reliance on consistent application of that
-   system; it is up to the author/donor to decide if he or she is willing
-   to distribute software through any other system and a licensee cannot
-   impose that choice.
-
-   This section is intended to make thoroughly clear what is believed to
-   be a consequence of the rest of this License.
-
-12. If the distribution and/or use of the Library is restricted in
-   certain countries either by patents or by copyrighted interfaces, the
-   original copyright holder who places the Library under this License may add
-   an explicit geographical distribution limitation excluding those countries,
-   so that distribution is permitted only in or among countries not thus
-   excluded.  In such case, this License incorporates the limitation as if
-   written in the body of this License.
-
-13. The Free Software Foundation may publish revised and/or new
-   versions of the Lesser General Public License from time to time.
-   Such new versions will be similar in spirit to the present version,
-   but may differ in detail to address new problems or concerns.
-
-   Each version is given a distinguishing version number.  If the Library
-   specifies a version number of this License which applies to it and
-   "any later version", you have the option of following the terms and
-   conditions either of that version or of any later version published by
-   the Free Software Foundation.  If the Library does not specify a
-   license version number, you may choose any version ever published by
-   the Free Software Foundation.
-
-14. If you wish to incorporate parts of the Library into other free
-   programs whose distribution conditions are incompatible with these,
-   write to the author to ask for permission.  For software which is
-   copyrighted by the Free Software Foundation, write to the Free
-   Software Foundation; we sometimes make exceptions for this.  Our
-   decision will be guided by the two goals of preserving the free status
-   of all derivatives of our free software and of promoting the sharing
-   and reuse of software generally.
-
-   **NO** **WARRANTY**
-
-15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-   WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-   EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-   OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-   PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-   LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-   THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-   WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-   AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-   FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-   CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-   LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-   RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-   FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-   SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-   DAMAGES.
-
-### END OF TERMS AND CONDITIONS
-
-### How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.  It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary.  Here is a sample; alter the names:
-
-    Yoyodyne, Inc., hereby disclaims all copyright interest in the
-    library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
-    <signature of Ty Coon>, 1 April 1990
-    Ty Coon, President of Vice
-
-That's all there is to it!
-
-@section occt_lgpl_exception OPEN CASCADE EXCEPTION
-
-### Open CASCADE Exception (version 1.0) to GNU LGPL version 2.1.
-
-The object code (i.e. not a source) form of a "work that uses the Library"
-can incorporate material from a header file that is part of the Library.
-As a special exception to the GNU Lesser General Public License version 2.1,
-you may distribute such object code incorporating material from header files
-provided with the Open CASCADE Technology libraries (including code of CDL
-generic classes) under terms of your choice, provided that you give
-prominent notice in supporting documentation to this code that it makes use
-of or is based on facilities provided by the Open CASCADE Technology software.
index 4d4bddf16469894614f16ddac9a3bb9f7bdcf547..97c5e69690235256722c838c32235b2612a1ea2f 100644 (file)
@@ -218,7 +218,8 @@ is
        NoSuchObject from Standard
      is virtual;     
           
-     
+     NbSamples(me) returns Integer from Standard is virtual;
+
      Bezier(me) returns BezierCurve from Geom2d
      raises 
        NoSuchObject from Standard
index 0192f4049fcb71948599991404e61e9bb3d7cbee..b88c46b3a82e3d0f385b294cbd11022ccf229675 100644 (file)
@@ -373,5 +373,12 @@ Handle(Geom2d_BSplineCurve) Adaptor2d_Curve2d::BSpline() const
   return Handle(Geom2d_BSplineCurve)();
 }
 
-
+//=======================================================================
+//function : NbSamples
+//purpose  : 
+//=======================================================================
+Standard_Integer Adaptor2d_Curve2d::NbSamples() const
+{
+  return 20;  
+}
 
index 2e179785731cde0a3a900cca7ac90dfc1d09eb48..cfa6b2d4608d24912883f6ab891055151305ea18 100644 (file)
     return; 
   }
   // 12
+
   PerformEF();
   if (myErrorStatus) {
     return; 
index 7584d5a729839addc748a939c190cac42105faa9..25ce4298d4e3489e4ae2fefb79d5e91928174bf5 100644 (file)
@@ -87,9 +87,9 @@ static
 static 
   void Path (const GeomAdaptor_Surface& aGAS,
              const TopoDS_Face& myFace,
-             const TopoDS_Vertex& aVa,
-             const TopoDS_Edge& aEOuta,
-             BOPAlgo_EdgeInfo& anEdgeInfo,
+             const TopoDS_Vertex& aVFirst,
+             const TopoDS_Edge& aEFirst,
+             BOPAlgo_EdgeInfo& aEIFirst,
              BOPCol_SequenceOfShape& aLS,
              BOPCol_SequenceOfShape& aVertVa,
              BOPCol_SequenceOfPnt2d& aCoordVa,
@@ -326,245 +326,239 @@ static
 //=======================================================================
 void Path (const GeomAdaptor_Surface& aGAS,
            const TopoDS_Face& myFace,
-           const TopoDS_Vertex& aVa,
-           const TopoDS_Edge& aEOuta,
-           BOPAlgo_EdgeInfo& anEdgeInfo,
+           const TopoDS_Vertex& aVFirst,
+           const TopoDS_Edge& aEFirst,
+           BOPAlgo_EdgeInfo& aEIFirst,
            BOPCol_SequenceOfShape& aLS,
            BOPCol_SequenceOfShape& aVertVa,
            BOPCol_SequenceOfPnt2d& aCoordVa,
            BOPTools_ConnexityBlock& aCB,
            BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo& mySmartMap)
-     
 {
   Standard_Integer i, j, aNb, aNbj;
-  Standard_Real aTol, anAngleIn, anAngleOut, anAngle, aMinAngle;
-  Standard_Real aTol2D, aTol2D2;
-  Standard_Real aTol2, aD2, aTwoPI;
+  Standard_Real anAngleIn, anAngleOut, anAngle, aMinAngle;
+  Standard_Real aTol2D, aTol2D2, aD2, aTwoPI;
   Standard_Boolean anIsSameV2d, anIsSameV, anIsFound, anIsOut, anIsNotPassed;
-  TopoDS_Vertex aVb;
-  TopoDS_Edge aEOutb;
+  Standard_Boolean bIsClosed, bRecomputeAngle;
+  TopoDS_Vertex aVa, aVb;
+  TopoDS_Edge aEOuta;
   BOPAlgo_ListIteratorOfListOfEdgeInfo anIt;
+  BOPCol_SequenceOfReal aRecomputedAngles;
+  //
+  aVa = aVFirst;
+  aEOuta = aEFirst;
+  BOPAlgo_EdgeInfo* anEdgeInfo = &aEIFirst;
   //
   aTwoPI = M_PI + M_PI;
-  aTol=1.e-7;
   //
   // append block
   //
-  // Do not escape through edge from which you enter 
-  aNb=aLS.Length();
-  if (aNb==1) {
-    const TopoDS_Shape& anEPrev=aLS(aNb);
-    if (anEPrev.IsSame(aEOuta)) {
-      return;
+  for (;;) {
+    // Do not escape through edge from which you enter 
+    aNb=aLS.Length();
+    if (aNb==1) {
+      const TopoDS_Shape& anEPrev=aLS(aNb);
+      if (anEPrev.IsSame(aEOuta)) {
+        return;
+      }
     }
-  }
-  //
-  anEdgeInfo.SetPassed(Standard_True);
-  aLS.Append(aEOuta);
-  aVertVa.Append(aVa);
-  
-  TopoDS_Vertex pVa=aVa;
-  pVa.Orientation(TopAbs_FORWARD);
-  gp_Pnt2d aPa=Coord2d(pVa, aEOuta, myFace);
-  aCoordVa.Append(aPa);
-  
-  GetNextVertex (pVa, aEOuta, aVb);
-
-  gp_Pnt2d aPb=Coord2d(aVb, aEOuta, myFace);
-
-  const BOPAlgo_ListOfEdgeInfo& aLEInfoVb=mySmartMap.FindFromKey(aVb);
-  //
-  aTol=2.*Tolerance2D(aVb, aGAS);
-  aTol2=10.*aTol*aTol;
-
-  TopoDS_Vertex aV1, aV2;
-  TopExp::Vertices(aEOuta, aV1, aV2);
-  Standard_Boolean bIsClosedEdge = aV1.IsNull() || aV2.IsNull() || aV1.IsSame(aV2);
-  Standard_Boolean bIsDegenerated = BRep_Tool::Degenerated(aEOuta);
-  Standard_Boolean bIsSeam = BRep_Tool::IsClosed(aEOuta, myFace);
-
-  anIt.Initialize(aLEInfoVb);
-  for (; anIt.More(); anIt.Next()) {
-    const BOPAlgo_EdgeInfo& anEI = anIt.Value();
-    const TopoDS_Edge& aE = anEI.Edge();
-    bIsDegenerated = bIsDegenerated || BRep_Tool::Degenerated(aE);
-    bIsSeam = bIsSeam || BRep_Tool::IsClosed(aE, myFace);
-    aV1.Nullify();
-    aV2.Nullify();
-    TopExp::Vertices(aE, aV1, aV2);
-    bIsClosedEdge = bIsClosedEdge || aV1.IsNull() || aV2.IsNull() || aV1.IsSame(aV2);
-  }
-  //
-  aNb=aLS.Length();
-  if (aNb>0) {
     //
-    BOPCol_ListOfShape aBuf;
+    anEdgeInfo->SetPassed(Standard_True);
+    aLS.Append(aEOuta);
+    aVertVa.Append(aVa);
+    
+    TopoDS_Vertex pVa=aVa;
+    pVa.Orientation(TopAbs_FORWARD);
+    gp_Pnt2d aPa=Coord2d(pVa, aEOuta, myFace);
+    aCoordVa.Append(aPa);
+    
+    GetNextVertex (pVa, aEOuta, aVb);
+    
+    gp_Pnt2d aPb=Coord2d(aVb, aEOuta, myFace);
+    
+    const BOPAlgo_ListOfEdgeInfo& aLEInfo=mySmartMap.FindFromKey(aVb);
     //
-    for (i=aNb; i>0; --i) {
-      const TopoDS_Shape& aVPrev=aVertVa(i);
-      const gp_Pnt2d& aPaPrev=aCoordVa(i);
-      const TopoDS_Shape& aEPrev=aLS(i);
-
-      aBuf.Append(aEPrev);
-
-      anIsSameV=aVPrev.IsSame(aVb);
-      anIsSameV2d=Standard_False;
-
-      if (anIsSameV) {
-        anIsSameV2d = Standard_True;
+    aTol2D = 2.*Tolerance2D(aVb, aGAS);
+    aTol2D2 = aTol2D * aTol2D;
+    //
+    bIsClosed = BRep_Tool::Degenerated(aEOuta) || 
+      BRep_Tool::IsClosed(aEOuta, myFace) || aVa.IsSame(aVb);
+    if (!bIsClosed) {
+      TopoDS_Vertex aV1, aV2;
+      //
+      anIt.Initialize(aLEInfo);
+      for (; anIt.More() && !bIsClosed; anIt.Next()) {
+        const BOPAlgo_EdgeInfo& anEI = anIt.Value();
+        const TopoDS_Edge& aE = anEI.Edge();
         //
-        aD2=aPaPrev.SquareDistance(aPb);
-        anIsSameV2d =aD2<aTol2;
-        if(anIsSameV2d && 
-           (bIsDegenerated || bIsSeam || bIsClosedEdge)) {
-          Standard_Real udist = fabs(aPaPrev.X() - aPb.X());
-          Standard_Real vdist = fabs(aPaPrev.Y() - aPb.Y());
-          Standard_Real aTolU = 2. * UTolerance2D(aVb, aGAS);
-          Standard_Real aTolV = 2. * VTolerance2D(aVb, aGAS);
-          //
-          if((udist > aTolU) ||
-             (vdist > aTolV)) {
-            anIsSameV2d = Standard_False;
-          }
+        bIsClosed = BRep_Tool::Degenerated(aE) || BRep_Tool::IsClosed(aE, myFace);
+        if (!bIsClosed) {
+          TopExp::Vertices(aE, aV1, aV2);
+          bIsClosed = aV1.IsNull() || aV2.IsNull() || aV1.IsSame(aV2);
         }
-      }//if (anIsSameV) {
+      }
+    }
+    //
+    aNb=aLS.Length();
+    if (aNb>0) {
+      //
+      BOPCol_ListOfShape aBuf;
       //
-      if (anIsSameV && anIsSameV2d) {
-        Standard_Integer iPriz;
-        iPriz=1;
-        if (aBuf.Extent()==2) {
-          if(aBuf.First().IsSame(aBuf.Last())) {
-            iPriz=0;
+      for (i=aNb; i>0; --i) {
+        const TopoDS_Shape& aVPrev=aVertVa(i);
+        const gp_Pnt2d& aPaPrev=aCoordVa(i);
+        const TopoDS_Shape& aEPrev=aLS(i);
+        
+        aBuf.Append(aEPrev);
+        
+        anIsSameV = aVPrev.IsSame(aVb);
+        anIsSameV2d = anIsSameV;
+        if (anIsSameV) {
+          if(bIsClosed) {
+            aD2 = aPaPrev.SquareDistance(aPb);
+            anIsSameV2d = aD2 < aTol2D2;
+            if (anIsSameV2d) {
+              Standard_Real udist = fabs(aPaPrev.X() - aPb.X());
+              Standard_Real vdist = fabs(aPaPrev.Y() - aPb.Y());
+              Standard_Real aTolU = 2.*UTolerance2D(aVb, aGAS);
+              Standard_Real aTolV = 2.*VTolerance2D(aVb, aGAS);
+              //
+              if((udist > aTolU) || (vdist > aTolV)) {
+                anIsSameV2d = Standard_False;
+              }
+            }
           }
-        }
-        if (iPriz) {
-          TopoDS_Wire aW;
-          BOPAlgo_WireSplitter::MakeWire(aBuf, aW);
-          aCB.ChangeLoops().Append(aW);
-        }
+        }//if (anIsSameV) {
         //
-        aNbj=i-1;
-        if (aNbj<1) {
+        if (anIsSameV && anIsSameV2d) {
+          Standard_Integer iPriz;
+          iPriz=1;
+          if (aBuf.Extent()==2) {
+            if(aBuf.First().IsSame(aBuf.Last())) {
+              iPriz=0;
+            }
+          }
+          if (iPriz) {
+            TopoDS_Wire aW;
+            BOPAlgo_WireSplitter::MakeWire(aBuf, aW);
+            aCB.ChangeLoops().Append(aW);
+          }
+          //
+          aNbj=i-1;
+          if (aNbj<1) {
+            //
+            aLS.Clear();
+            aVertVa.Clear();
+            aCoordVa.Clear();
+            //
+            return;
+          }
+          //
+          BOPCol_SequenceOfShape aLSt, aVertVat;
+          BOPCol_SequenceOfPnt2d aCoordVat;
+          //
+          aVb=(*(TopoDS_Vertex *)(&aVertVa(i))); 
+          //
+          for (j=1; j<=aNbj; ++j) {
+            aLSt.Append(aLS(j));
+            aVertVat.Append(aVertVa(j));
+            aCoordVat.Append(aCoordVa(j));
+          }
           //
           aLS.Clear();
           aVertVa.Clear();
           aCoordVa.Clear();
+          
+          aLS=aLSt;
+          aVertVa=aVertVat;
+          aCoordVa=aCoordVat;
           //
-          return;
-        }
-        //
-        BOPCol_SequenceOfShape aLSt, aVertVat;
-        BOPCol_SequenceOfPnt2d aCoordVat;
-        //
-        aVb=(*(TopoDS_Vertex *)(&aVertVa(i))); 
-        //
-        for (j=1; j<=aNbj; ++j) {
-          aLSt.Append(aLS(j));
-          aVertVat.Append(aVertVa(j));
-          aCoordVat.Append(aCoordVa(j));
+          break;
         }
-        //
-        aLS.Clear();
-        aVertVa.Clear();
-        aCoordVa.Clear();
-        
-        aLS=aLSt;
-        aVertVa=aVertVat;
-        aCoordVa=aCoordVat;
-        //
-        break;
       }
     }
-  }
-  //
-  aTol2D=2.*Tolerance2D(aVb, aGAS);
-  aTol2D2=1000.*aTol2D*aTol2D;//100.*aTol2D*aTol2D;
-  //
-  // anAngleIn in Vb from edge aEOuta
-  const BOPAlgo_ListOfEdgeInfo& aLEInfo=mySmartMap.FindFromKey(aVb);
-  //
-  anAngleIn=AngleIn(aEOuta, aLEInfo);
-  BOPCol_SequenceOfReal aRecomputedAngles;
-
-  Standard_Boolean bRecomputeAngle = 
-    RecomputeAngles(aLEInfo, myFace, aPb, aVb, aGAS, aEOuta, 
-                    (bIsDegenerated || bIsSeam || bIsClosedEdge),
-                    aTol2D, aRecomputedAngles);
-
-  //
-  // aEOutb
-  BOPAlgo_EdgeInfo *pEdgeInfo=NULL;
-  //
-  aMinAngle=100.;
-  anIsFound=Standard_False;
-  Standard_Integer aCurIndexE = 0;
-  anIt.Initialize(aLEInfo);
-  for (; anIt.More(); anIt.Next()) {
-    BOPAlgo_EdgeInfo& anEI=anIt.ChangeValue();
-    const TopoDS_Edge& aE=anEI.Edge();
-    anIsOut=!anEI.IsIn();
-    anIsNotPassed=!anEI.Passed();
-    
-    if (anIsOut && anIsNotPassed) {
-      aCurIndexE++;
-      //
-      // Is there one way to go out of the vertex 
-      // we have to use it only.
-      Standard_Integer iCnt;
-      iCnt=NbWaysOut (aLEInfo);
-      //
-      if (!iCnt) {
-        // no way to go . (Error)
-        return ;
-      }
-      //
-      if (iCnt==1) {
-        // the one and only way to go out .
-        pEdgeInfo=&anEI;
-        anIsFound=Standard_True;
-        break;
-      }
-      //
-      if (aE.IsSame(aEOuta)) {
-        anAngle = aTwoPI;
-      } else {
-        // Look for minimal angle and make the choice.
-        gp_Pnt2d aP2Dx;
+    //
+    aRecomputedAngles.Clear();
+    bRecomputeAngle = 
+      RecomputeAngles(aLEInfo, myFace, aPb, aVb, aGAS, aEOuta, 
+                      bIsClosed, aTol2D, aRecomputedAngles);
+    //
+    // aEOutb
+    BOPAlgo_EdgeInfo *pEdgeInfo=NULL;
+    //
+    anAngleIn = AngleIn(aEOuta, aLEInfo);
+    aMinAngle = 100.;
+    anIsFound = Standard_False;
+    Standard_Integer aCurIndexE = 0;
+    anIt.Initialize(aLEInfo);
+    for (; anIt.More(); anIt.Next()) {
+      BOPAlgo_EdgeInfo& anEI=anIt.ChangeValue();
+      const TopoDS_Edge& aE=anEI.Edge();
+      anIsOut=!anEI.IsIn();
+      anIsNotPassed=!anEI.Passed();
+      
+      if (anIsOut && anIsNotPassed) {
+        aCurIndexE++;
         //
-        aP2Dx=Coord2dVf(aE, myFace);
+        // Is there one way to go out of the vertex 
+        // we have to use it only.
+        Standard_Integer iCnt;
+        iCnt=NbWaysOut (aLEInfo);
         //
-        aD2=aP2Dx.SquareDistance(aPb);
-        if (aD2 > aTol2D2){
-          continue;
+        if (!iCnt) {
+          // no way to go . (Error)
+          return;
         }
         //
+        if (iCnt==1) {
+          // the one and only way to go out .
+          pEdgeInfo=&anEI;
+          anIsFound=Standard_True;
+          break;
+        }
         //
-        anAngleOut=anEI.Angle();
-        //
-        if(bRecomputeAngle) {
-          if(aCurIndexE <= aRecomputedAngles.Length()) {
-            anAngleOut = aRecomputedAngles.Value(aCurIndexE);
+        if (aE.IsSame(aEOuta)) {
+          anAngle = aTwoPI;
+        } else {
+          //check 2d distance
+          if (bIsClosed) {
+            gp_Pnt2d aP2Dx;
+            //
+            aP2Dx = Coord2dVf(aE, myFace);
+            //
+            aD2 = aP2Dx.SquareDistance(aPb);
+            if (aD2 > aTol2D2){
+              continue;
+            }
           }
+          //
+          // Look for minimal angle and make the choice.
+          anAngleOut=anEI.Angle();
+          //
+          if(bRecomputeAngle) {
+            if(aCurIndexE <= aRecomputedAngles.Length()) {
+              anAngleOut = aRecomputedAngles.Value(aCurIndexE);
+            }
+          }
+          anAngle=ClockWiseAngle(anAngleIn, anAngleOut);
+        }
+        if (anAngle < aMinAngle) {
+          aMinAngle=anAngle;
+          pEdgeInfo=&anEI;
+          anIsFound=Standard_True;
         }
-        anAngle=ClockWiseAngle(anAngleIn, anAngleOut);
-      }
-      if (anAngle < aMinAngle) {
-        aMinAngle=anAngle;
-        pEdgeInfo=&anEI;
-        anIsFound=Standard_True;
       }
+    } // for (; anIt.More(); anIt.Next()) 
+    //
+    if (!anIsFound) {
+      // no way to go . (Error)
+      return;
     }
-  } // for (; anIt.More(); anIt.Next()) 
-  //
-  if (!anIsFound) {
-    // no way to go . (Error)
-    return;
+    //
+    aVa = aVb;
+    aEOuta = pEdgeInfo->Edge();
+    anEdgeInfo = pEdgeInfo;
   }
-  
-  aEOutb=pEdgeInfo->Edge();
-  //
-  Path (aGAS, myFace, aVb, aEOutb, *pEdgeInfo, aLS, 
-        aVertVa, aCoordVa, aCB, mySmartMap);
 }
 //=======================================================================
 // function:  ClockWiseAngle
index d30aebccbe6878f6f02ac7386866a6e1332e49b6..50a7de733c3ef5cd8512c75bb8f69c015341a722 100644 (file)
@@ -100,17 +100,17 @@ class BOPTime_Chronometer {
 };
 #endif
 
-
-
 static Standard_Integer bfillds  (Draw_Interpretor&, Standard_Integer, const char**); 
 static Standard_Integer bbuild   (Draw_Interpretor&, Standard_Integer, const char**);
 static Standard_Integer bbop     (Draw_Interpretor&, Standard_Integer, const char**);
 static Standard_Integer bclear   (Draw_Interpretor&, Standard_Integer, const char**);
+static Standard_Integer bnsection(Draw_Interpretor&, Standard_Integer, const char**);
+
 //=======================================================================
 //function : PartitionCommands
 //purpose  : 
 //=======================================================================
-  void BOPTest::PartitionCommands(Draw_Interpretor& theCommands)
+void BOPTest::PartitionCommands(Draw_Interpretor& theCommands)
 {
   static Standard_Boolean done = Standard_False;
   if (done) return;
@@ -118,17 +118,20 @@ static Standard_Integer bclear   (Draw_Interpretor&, Standard_Integer, const cha
   // Chapter's name
   const char* g = "Partition commands";
   // Commands  
-  theCommands.Add("bfillds"  , "use bfillds"           , __FILE__, bfillds  , g);
-  theCommands.Add("bbuild"   , " use bbuild r [-s -t]" , __FILE__, bbuild, g);
-  theCommands.Add("bbop"     , "use bbop r op"         , __FILE__, bbop, g);
-  theCommands.Add("bclear"   , "use bclear"            , __FILE__, bclear, g);
+  theCommands.Add("bfillds"  , "use bfillds [-s -t]" , __FILE__, bfillds, g);
+  theCommands.Add("bbuild"   , "use bbuild r [-s -t]", __FILE__, bbuild, g);
+  theCommands.Add("bbop"     , "use bbop r op"       , __FILE__, bbop, g);
+  theCommands.Add("bclear"   , "use bclear"          , __FILE__, bclear, g);
+  theCommands.Add("bnsection", "use bnsection r"     , __FILE__, bnsection, g);
 }
 
 //=======================================================================
 //function : bclear
 //purpose  : 
 //=======================================================================
-Standard_Integer bclear(Draw_Interpretor& di, Standard_Integer n, const char** ) 
+Standard_Integer bclear(Draw_Interpretor& di, 
+                        Standard_Integer n, 
+                        const char** ) 
 {
   if (n!=1) {
     di << " use bclear\n";
@@ -142,17 +145,21 @@ Standard_Integer bclear(Draw_Interpretor& di, Standard_Integer n, const char** )
 //function : bfillds
 //purpose  : 
 //=======================================================================
-Standard_Integer bfillds(Draw_Interpretor& di, Standard_Integer n, const char** ) 
+Standard_Integer bfillds(Draw_Interpretor& di, 
+                         Standard_Integer n, 
+                         const char** a) 
 { 
-  if (n!=1) {
-    di << " Use bfillds\n";
+  if (n>3) {
+    di << " use bfillds [-s -t]\n";
     return 0;
   }
   //
   char buf[32];
-  Standard_Integer aNbS, aNbT, iErr;
+  Standard_Boolean bRunParallel, bShowTime;
+  Standard_Integer i, aNbS, iErr;
   BOPCol_ListIteratorOfListOfShape aIt;
   BOPCol_ListOfShape aLC;
+  BOPTime_Chronometer aChrono;
   
   BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes();
   aNbS=aLS.Extent();
@@ -161,8 +168,18 @@ Standard_Integer bfillds(Draw_Interpretor& di, Standard_Integer n, const char**
     return 0;
   }
   //
+  bShowTime=Standard_False;
+  bRunParallel=Standard_True;
+  for (i=1; i<n; ++i) {
+    if (!strcmp(a[i], "-s")) {
+      bRunParallel=Standard_False;
+    }
+    else if (!strcmp(a[i], "-t")) {
+      bShowTime=Standard_True;
+    }
+  }
+  //
   BOPCol_ListOfShape& aLT=BOPTest_Objects::Tools();
-  aNbT=aLT.Extent();
   //
   aIt.Initialize(aLS);
   for (; aIt.More(); aIt.Next()) {
@@ -179,6 +196,9 @@ Standard_Integer bfillds(Draw_Interpretor& di, Standard_Integer n, const char**
   BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
   //
   aPF.SetArguments(aLC);
+  //aPF.SetRunParallel(bRunParallel);
+  //
+  aChrono.Start();
   //
   aPF.Perform();
   iErr=aPF.ErrorStatus();
@@ -188,13 +208,25 @@ Standard_Integer bfillds(Draw_Interpretor& di, Standard_Integer n, const char**
     return 0;
   }
   //
+  aChrono.Stop();
+  //
+  if (bShowTime) {
+    Standard_Real aTime;
+    //
+    aTime=aChrono.Time();
+    Sprintf(buf, "  Tps: %7.2lf\n", aTime);
+    di << buf;
+  }
+  //
   return 0;
 }
 //=======================================================================
 //function : bbuild
 //purpose  : 
 //=======================================================================
-Standard_Integer bbuild(Draw_Interpretor& di, Standard_Integer n, const char** a) 
+Standard_Integer bbuild(Draw_Interpretor& di,
+                        Standard_Integer n, 
+                        const char** a) 
 { 
   if (n<2) {
     di << " use bbuild r [-s -t]\n";
@@ -213,8 +245,6 @@ Standard_Integer bbuild(Draw_Interpretor& di, Standard_Integer n, const char** a
   
   BOPTime_Chronometer aChrono;
   BOPCol_ListIteratorOfListOfShape aIt;
-  //
-  
   //
   BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
   //
@@ -282,7 +312,9 @@ Standard_Integer bbuild(Draw_Interpretor& di, Standard_Integer n, const char** a
 //function : bbop
 //purpose  : 
 //=======================================================================
-Standard_Integer bbop(Draw_Interpretor& di, Standard_Integer n, const char** a) 
+Standard_Integer bbop(Draw_Interpretor& di, 
+                      Standard_Integer n, 
+                      const char** a) 
 { 
   if (n!=3) {
     di << " use bbop r op\n";
@@ -345,3 +377,103 @@ Standard_Integer bbop(Draw_Interpretor& di, Standard_Integer n, const char** a)
   return 0;
 }
 
+#include <BRep_Builder.hxx>
+#include <BOPCol_IndexedMapOfShape.hxx>
+#include <BOPDS_DS.hxx>
+#include <BOPDS_VectorOfInterfFF.hxx>
+#include <BOPTools.hxx>
+
+//=======================================================================
+//function : nsection
+//purpose  : 
+//=======================================================================
+Standard_Integer bnsection(Draw_Interpretor& di, 
+                           Standard_Integer n, 
+                           const char** a) 
+{ 
+  if (n != 2) {
+    di << "use bnsection r\n";
+    return 0;
+  }
+  //
+  BOPDS_PDS pDS = BOPTest_Objects::PDS();
+  if (!pDS) {
+    di << " prepare PaveFiller first\n";
+    return 0;
+  }
+  //
+  Standard_Integer i, j, k, nE, nF1, nF2, aNbPB, aNbFF;
+  Standard_Boolean bFlag;
+  TopoDS_Compound aRC;
+  BRep_Builder aBB;
+  BOPCol_MapOfShape aME;
+  BOPCol_IndexedMapOfShape aME1, aME2;
+  //
+  aBB.MakeCompound(aRC);
+  BOPDS_VectorOfInterfFF& aFFs = pDS->InterfFF();
+  aNbFF = aFFs.Extent();
+  //
+  for (i = 0; i < aNbFF; ++i) {
+    BOPDS_InterfFF& aFF = aFFs(i);
+    aFF.Indices(nF1, nF2);
+    const BOPDS_FaceInfo& aFI1 = pDS->FaceInfo(nF1);
+    const BOPDS_FaceInfo& aFI2 = pDS->FaceInfo(nF2);
+    //
+    const BOPDS_IndexedMapOfPaveBlock& aMPBIn1 = aFI1.PaveBlocksIn();
+    const BOPDS_IndexedMapOfPaveBlock& aMPBOn1 = aFI1.PaveBlocksOn();
+    const BOPDS_IndexedMapOfPaveBlock& aMPBSc1 = aFI1.PaveBlocksSc();
+    //
+    const BOPDS_IndexedMapOfPaveBlock& aMPBIn2 = aFI2.PaveBlocksIn();
+    const BOPDS_IndexedMapOfPaveBlock& aMPBOn2 = aFI2.PaveBlocksOn();
+    //
+    //1. Section edges
+    aNbPB = aMPBSc1.Extent();
+    for (j = 1; j <= aNbPB; ++j) {
+      const Handle(BOPDS_PaveBlock)& aPB = aMPBSc1(j);
+      nE = aPB->Edge();
+      const TopoDS_Shape& aE = pDS->Shape(nE);
+      if (aME.Add(aE)) {
+        aBB.Add(aRC, aE);
+      }
+    }
+    //2. Common edges
+    BOPDS_IndexedMapOfPaveBlock aMPB[4] = {aMPBOn2, aMPBIn1, aMPBIn2, aMPBOn1};
+    for (k = 0; k < 3; ++k) {
+      aNbPB = aMPB[k].Extent();
+      for (j = 1; j <= aNbPB; ++j) {
+        const Handle(BOPDS_PaveBlock)& aPB = aMPB[k](j);
+        bFlag = (k==0) ? aMPB[3].Contains(aPB) :
+          (aMPB[k-1].Contains(aPB) || aMPB[k+1].Contains(aPB));
+        if (bFlag) {
+          nE = aPB->Edge();
+          const TopoDS_Shape& aE = pDS->Shape(nE);
+          if (aME.Add(aE)) {
+            aBB.Add(aRC, aE);
+          }
+        }
+      }
+    }
+    //3. Shared edges
+    aME1.Clear();
+    aME2.Clear();
+    //
+    const TopoDS_Face& aF1 = (*(TopoDS_Face *)(&pDS->Shape(nF1)));
+    const TopoDS_Face& aF2 = (*(TopoDS_Face *)(&pDS->Shape(nF2)));
+    //
+    BOPTools::MapShapes(aF1, TopAbs_EDGE, aME1);
+    BOPTools::MapShapes(aF2, TopAbs_EDGE, aME2);
+    //
+    aNbPB = aME1.Extent();
+    for (j = 1; j <= aNbPB; ++j) {
+      const TopoDS_Shape& aE = aME1(j);
+      if (aME2.Contains(aE)) {
+        if (aME.Add(aE)) {
+          aBB.Add(aRC, aE);
+        }
+      }
+    }
+  }
+  //
+  DBRep::Set(a[1], aRC);
+  return 0;
+}
index 41234e26f87793bb6196929fcc9c06d1bd071b6e..b37a8ce015ca94251ef59101e767ef3acc828e9c 100644 (file)
 #include <Geom2d_Ellipse.hxx>
 #include <Geom2d_Parabola.hxx>
 #include <Geom2d_Hyperbola.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+
+#include <Geom2dAdaptor.hxx>
 
 #include <Geom_Curve.hxx>
 #include <GeomAdaptor_HCurve.hxx>
 #include <Geom_TrimmedCurve.hxx>
 #include <Geom_Surface.hxx>
+#include <Geom_Plane.hxx>
+
+#include <GeomAdaptor_Surface.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <GeomAdaptor_HCurve.hxx>
+#include <GeomAdaptor_HSurface.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+
+#include <GeomProjLib.hxx>
 
 #include <TopLoc_Location.hxx>
 #include <TopExp.hxx>
 
 #include <BRep_Tool.hxx>
 #include <BRepTools.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
+#include <BRep_TEdge.hxx>
+#include <BRep_CurveRepresentation.hxx>
+#include <BRep_GCurve.hxx>
+
 #include <BRepAdaptor_HSurface.hxx>
+
 #include <BRepAdaptor_Curve.hxx>
-#include <BRep_Builder.hxx>
 #include <BRepAdaptor_Surface.hxx>
 #include <Geom2d_Curve.hxx>
 #include <Geom_Plane.hxx>
 #include <Geom_RectangularTrimmedSurface.hxx>
 #include <BRep_Builder.hxx>
 #include <Geom_Surface.hxx>
+#include <BRepClass_FaceClassifier.hxx>
+
+#include <BRepTools.hxx>
+
 #include <BOPCol_IndexedMapOfShape.hxx>
-#include <BOPTools.hxx>
 
+#include <BOPTools.hxx>
+#include <IntTools_Tools.hxx>
+#include <GeomProjLib.hxx>
+#include <Geom2d_BSplineCurve.hxx>
+#include <TColStd_Array1OfReal.hxx>
+#include <BSplCLib.hxx>
 
 static 
-  Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E);
+  Standard_Boolean CheckEdgeLength (const TopoDS_Edge& );
+
+static
+  Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface(const TopoDS_Edge& , 
+                                                const TopoDS_Face& ,
+                                                Standard_Real& ,
+                                                Standard_Real& ,
+                                                Standard_Boolean& );
+static
+  Handle(Geom2d_Curve) BRep_Tool_CurveOnSurface(const TopoDS_Edge& , 
+                                                const Handle(Geom_Surface)& ,
+                                                const TopLoc_Location& ,
+                                                Standard_Real& ,
+                                                Standard_Real& ,
+                                                Standard_Boolean& );
 
 //=======================================================================
 //function : BuildPCurveForEdgeOnFace
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE,
-                                                   const TopoDS_Face& aF)
+void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE,
+                                                     const TopoDS_Face& aF)
 {
   BRep_Builder aBB;
   Handle(Geom2d_Curve) aC2D;
@@ -91,8 +133,8 @@ static
 //purpose  : 
 //=======================================================================
   Standard_Boolean BOPTools_AlgoTools2D::EdgeTangent(const TopoDS_Edge& anEdge, 
-                                                 const Standard_Real aT,
-                                                 gp_Vec& aTau)
+   const Standard_Real aT,
+   gp_Vec& aTau)
 {
   Standard_Boolean isdgE;
   Standard_Real first, last;
@@ -126,11 +168,11 @@ static
 //function : PointOnOnSurface
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::PointOnSurface (const TopoDS_Edge& aE,
-                                         const TopoDS_Face& aF,
-                                         const Standard_Real aParameter,
-                                         Standard_Real& U,
-                                         Standard_Real& V)
+void BOPTools_AlgoTools2D::PointOnSurface (const TopoDS_Edge& aE,
+                                           const TopoDS_Face& aF,
+                                           const Standard_Real aParameter,
+                                           Standard_Real& U,
+                                           Standard_Real& V)
 {
   gp_Pnt2d aP2D;
   Handle(Geom2d_Curve) aC2D;
@@ -147,10 +189,10 @@ static
 //function : CurveOnSurface
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
-                                         const TopoDS_Face& aF,
-                                         Handle(Geom2d_Curve)& aC2D,
-                                         Standard_Real& aToler)
+void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
+                                           const TopoDS_Face& aF,
+                                           Handle(Geom2d_Curve)& aC2D,
+                                           Standard_Real& aToler)
 {
   Standard_Real aFirst, aLast; 
 
@@ -162,12 +204,12 @@ static
 //function : CurveOnSurface
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
-                                         const TopoDS_Face& aF,
-                                         Handle(Geom2d_Curve)& aC2D,
-                                         Standard_Real& aFirst,
-                                         Standard_Real& aLast,
-                                         Standard_Real& aToler)
+void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE,
+                                           const TopoDS_Face& aF,
+                                           Handle(Geom2d_Curve)& aC2D,
+                                           Standard_Real& aFirst,
+                                           Standard_Real& aLast,
+                                           Standard_Real& aToler)
 {
   Standard_Boolean aHasOld;
   Handle(Geom2d_Curve) C2D;
@@ -188,11 +230,11 @@ static
 //purpose  : 
 //=======================================================================
   Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface (const TopoDS_Edge& aE,
-                                                        const TopoDS_Face& aF,
-                                                        Handle(Geom2d_Curve)& aC2D,
-                                                        Standard_Real& aFirst,
-                                                        Standard_Real& aLast,
-                                                        Standard_Real& aToler)
+   const TopoDS_Face& aF,
+   Handle(Geom2d_Curve)& aC2D,
+   Standard_Real& aFirst,
+   Standard_Real& aLast,
+   Standard_Real& aToler)
 {
   Standard_Boolean aHasOld;
   
@@ -203,7 +245,7 @@ static
     return Standard_False;
   }
 
-  aC2D  =BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast);
+  aC2D=BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast);
   aHasOld=!aC2D.IsNull();
   return aHasOld;
 }
@@ -212,7 +254,7 @@ static
 //purpose  : 
 //=======================================================================
   Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface (const TopoDS_Edge& aE,
-                                                        const TopoDS_Face& aF)
+   const TopoDS_Face& aF)
                                                    
 {
   Standard_Boolean aHasOld;
@@ -224,7 +266,7 @@ static
     return Standard_False;
   }
 
-  aC2D  =BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast);
+  aC2D=BRep_Tool::CurveOnSurface(aE, aF, aFirst, aLast);
   aHasOld=!aC2D.IsNull();
   return aHasOld;
 }
@@ -234,9 +276,9 @@ static
 //purpose  : 
 //=======================================================================
   void BOPTools_AlgoTools2D::AdjustPCurveOnFace (const TopoDS_Face& aF,
-                                             const Handle(Geom_Curve)&   aC3D,
-                                             const Handle(Geom2d_Curve)& aC2D, 
-                                             Handle(Geom2d_Curve)& aC2DA)
+   const Handle(Geom_Curve)&   aC3D,
+   const Handle(Geom2d_Curve)& aC2D, 
+   Handle(Geom2d_Curve)& aC2DA)
 {
   Standard_Real first, last;
 
@@ -250,10 +292,10 @@ static
 //purpose  : 
 //=======================================================================
   void BOPTools_AlgoTools2D::AdjustPCurveOnFace (const TopoDS_Face& aF,
-                                             const Standard_Real aFirst,
-                                             const Standard_Real aLast,
-                                             const Handle(Geom2d_Curve)& aC2D, 
-                                             Handle(Geom2d_Curve)& aC2DA)
+   const Standard_Real aFirst,
+   const Standard_Real aLast,
+   const Handle(Geom2d_Curve)& aC2D, 
+   Handle(Geom2d_Curve)& aC2DA)
 {
   Standard_Boolean mincond, maxcond, decalu, decalv;
   Standard_Integer k, iCnt;
@@ -276,14 +318,14 @@ static
  
   du = 0.;
   if (aBAS.IsUPeriodic()) {
-    aUPeriod=aBAS.UPeriod(); 
+    aUPeriod = aBAS.UPeriod(); 
     mincond = (u2 < UMin-aDelta);
     maxcond = (u2 > UMax+aDelta); 
     
     decalu = mincond || maxcond;
     if (decalu) {
       //du = ( mincond ) ? UPeriod : -UPeriod;
-      //
+    //
       iCnt=1;
       aUP2=aUPeriod+aUPeriod+aDelta;
       aUP1=aUPeriod+aDelta;
@@ -294,7 +336,7 @@ static
           aUx=u2-k*aUPeriod;
           iCnt = k++;
         } while (aUx >= aUP1);
-      }
+  }
       else if (u2 < -aUP2) {
         k=1;
         do {
@@ -326,7 +368,7 @@ static
   if (aBAS.IsVPeriodic()) {
     Standard_Real aVPeriod, aVm, aVr, aVmid, dVm, dVr;
     //
-    aVPeriod=aBAS.VPeriod();
+    aVPeriod = aBAS.VPeriod();
     mincond = (VMin - v2 > aDelta);
     maxcond = (v2 - VMax > aDelta);
     decalv = mincond || maxcond;
@@ -366,7 +408,7 @@ static
 //purpose  : 
 //=======================================================================
   Standard_Real BOPTools_AlgoTools2D::IntermediatePoint (const Standard_Real aFirst,
-                                                     const Standard_Real aLast)
+   const Standard_Real aLast)
 {
   //define parameter division number as 10*e^(-PI) = 0.43213918
   const Standard_Real PAR_T = 0.43213918;
@@ -396,8 +438,8 @@ static
 //purpose  : 
 //=======================================================================
 void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane (const TopoDS_Edge& aE,
-                                                     const TopoDS_Face& aF)
-{ 
+   const TopoDS_Face& aF)
+{
   Standard_Real aTolE;
   TopLoc_Location aLoc;
   Handle(Geom2d_Curve) aC2D;
@@ -409,10 +451,10 @@ void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane (const TopoDS_Edge& aE,
   aGRTS=Handle(Geom_RectangularTrimmedSurface)::DownCast(aS);
   if(!aGRTS.IsNull()){
     aGP=Handle(Geom_Plane)::DownCast(aGRTS->BasisSurface());
-    }    
+  }
   else {
     aGP=Handle(Geom_Plane)::DownCast(aS);
-  }
+}
   //
   if (aGP.IsNull()) {
     return;
@@ -463,20 +505,20 @@ void BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane
     if (!bHasOld) {
       BOPTools_AlgoTools2D::CurveOnSurface(aE, aFace, aC2D, aTolE);
       aBB.UpdateEdge(aE, aC2D, aFace, aTolE);
-    }
   }
 }
+}
 
 //=======================================================================
 //function : Make2D
 //purpose  : 
 //=======================================================================
 void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE,
-                                  const TopoDS_Face& aF,
-                                  Handle(Geom2d_Curve)& aC2D,
-                                 Standard_Real& aFirst,
-                                 Standard_Real& aLast,
-                                 Standard_Real& aToler)
+                                   const TopoDS_Face& aF,
+                                   Handle(Geom2d_Curve)& aC2D,
+                                   Standard_Real& aFirst,
+                                   Standard_Real& aLast,
+                                   Standard_Real& aToler)
 {
   Standard_Boolean aLocIdentity;
   Standard_Real f3d, l3d;
@@ -521,10 +563,10 @@ void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE,
 //function : MakePCurveOnFace
 //purpose  : 
 //=======================================================================
-  void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF,
-                                           const Handle(Geom_Curve)& aC3D,
-                                           Handle(Geom2d_Curve)& aC2D, //->
-                                           Standard_Real& TolReached2d)
+void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF,
+                                             const Handle(Geom_Curve)& aC3D,
+                                             Handle(Geom2d_Curve)& aC2D, //->
+                                             Standard_Real& TolReached2d)
 {
   Standard_Real aFirst, aLast;
 
@@ -541,46 +583,83 @@ void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE,
 //purpose  : 
 //=======================================================================
   void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF,
-                                           const Handle(Geom_Curve)& aC3D,
-                                           const Standard_Real aFirst,
-                                           const Standard_Real aLast,
-                                           Handle(Geom2d_Curve)& aC2D, 
-                                           Standard_Real& TolReached2d)
+   const Handle(Geom_Curve)& aC3D,
+   const Standard_Real aFirst,
+   const Standard_Real aLast,
+   Handle(Geom2d_Curve)& aC2D, 
+   Standard_Real& TolReached2d)
 {
-  Standard_Real aTolR;
+  Standard_Real aTolR = Precision::Confusion();
   Handle(Geom2d_Curve) aC2DA;
-
-  BRepAdaptor_Surface aBAS(aF, Standard_False);
-  Handle(BRepAdaptor_HSurface) aBAHS = new BRepAdaptor_HSurface(aBAS);
-  Handle(GeomAdaptor_HCurve)   aBAHC = new GeomAdaptor_HCurve(aC3D, aFirst, aLast);
+  //
+  Handle(Geom_Surface) aS=BRep_Tool::Surface(aF);
+  GeomAdaptor_Surface aGAS(aS);
+  Handle(GeomAdaptor_HSurface) aBAHS=
+    new GeomAdaptor_HSurface(aGAS);
+  Handle(GeomAdaptor_HCurve) aBAHC = 
+    new GeomAdaptor_HCurve(aC3D, aFirst, aLast);
   
   //when the type of surface is GeomAbs_SurfaceOfRevolution
-  if (aBAS.GetType() == GeomAbs_SurfaceOfRevolution) {
-    Standard_Real aTR = 1.e-7;
-    ProjLib_ProjectedCurve aProj1(aBAHS, aBAHC, aTR);
-    BOPTools_AlgoTools2D::MakePCurveOfType(aProj1, aC2D);
-    aTolR = aProj1.GetTolerance();
-  } else {
-    ProjLib_ProjectedCurve aProjCurv(aBAHS, aBAHC);// 1
-    BOPTools_AlgoTools2D::MakePCurveOfType(aProjCurv, aC2D);
-    aTolR=aProjCurv.GetTolerance();
+  if (aGAS.GetType() == GeomAbs_SurfaceOfRevolution) {
+    Standard_Real aTR = Precision::Confusion();
+
+    try
+    {
+      ProjLib_ProjectedCurve aProj1(aBAHS, aBAHC, aTR);
+      BOPTools_AlgoTools2D::MakePCurveOfType(aProj1, aC2D);
+      aTolR = aProj1.GetTolerance();
+
+    }
+    catch(Standard_Failure){}
+  }
+  else
+  {
+    try
+    {
+      ProjLib_ProjectedCurve aProjCurv(aBAHS, aBAHC);// 1
+      BOPTools_AlgoTools2D::MakePCurveOfType(aProjCurv, aC2D);
+      aTolR=aProjCurv.GetTolerance();
+    }
+    catch(Standard_Failure){}
   }
   //
-  if (aC2D.IsNull()) { 
-    ProjLib_ProjectedCurve aProjCurvAgain(aBAHS, aBAHC, TolReached2d);// 2
-    BOPTools_AlgoTools2D::MakePCurveOfType(aProjCurvAgain, aC2D);
-    aTolR = aProjCurvAgain.GetTolerance();
+  if (aC2D.IsNull())
+  {
+    try
+    {
+      ProjLib_ProjectedCurve aProjCurvAgain(aBAHS, aBAHC, TolReached2d);// 2
+      BOPTools_AlgoTools2D::MakePCurveOfType(aProjCurvAgain, aC2D);
+      aTolR = aProjCurvAgain.GetTolerance();
+    }
+    catch(Standard_Failure){}
     //
-    if (aC2D.IsNull()) { 
+    if (aC2D.IsNull())
+    { 
       Standard_Real aTR=0.0001;
       ProjLib_ProjectedCurve aProj3(aBAHS, aBAHC, aTR);// 3
       BOPTools_AlgoTools2D::MakePCurveOfType(aProj3, aC2D);
       aTolR = aProj3.GetTolerance();
     }
   }
+
+  Handle(Geom2d_BSplineCurve) aBSC = Handle(Geom2d_BSplineCurve)::DownCast(aC2D);
+  if(!aBSC.IsNull())
+  { //Changing a parametric range of the BSplineCurve for getting same-domain with 
+    //source 3D-curve.
+    
+    if(!IsEqual(aBSC->FirstParameter(), aFirst) || !IsEqual(aBSC->LastParameter(), aLast))
+    {
+      TColStd_Array1OfReal anArr(1, aBSC->NbKnots());
+      aBSC->Knots(anArr);
+      BSplCLib::Reparametrize(aFirst, aLast, anArr);
+      aBSC->SetKnots(anArr);
+    }
+  }
+
   TolReached2d=aTolR;
   
-  BOPTools_AlgoTools2D::AdjustPCurveOnFace (aF, aFirst, aLast, aC2D, aC2DA);
+  BOPTools_AlgoTools2D::AdjustPCurveOnFace (aF, aFirst, aLast, 
+                                            aC2D, aC2DA);
   aC2D=aC2DA;
 }
 
@@ -589,7 +668,7 @@ void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE,
 //purpose  : 
 //=======================================================================
   void  BOPTools_AlgoTools2D::MakePCurveOfType(const ProjLib_ProjectedCurve& PC, 
-                                           Handle(Geom2d_Curve)& C2D)
+   Handle(Geom2d_Curve)& C2D)
 {
   
   switch (PC.GetType()) {
@@ -702,7 +781,7 @@ Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E)
 
   aTol=BRep_Tool::Tolerance(aE);
   aBB.UpdateEdge(aE, aC2D, aF, aTol);
-}
+    }
 //=======================================================================
 //function : MakeCurveOnSurface
 //purpose  : 
@@ -715,7 +794,7 @@ Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E)
                                              Standard_Real& aToler)
 {
   BOPTools_AlgoTools2D::Make2D(aE, aF, aC2D, aFirst, aLast, aToler);
-}
+  }
 
 //=======================================================================
 //function : TangentOnEdge
@@ -726,7 +805,7 @@ Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E)
                                                    gp_Vec& Tg)
 {
   Standard_Boolean isdgE;
-  
+
   isdgE = BRep_Tool::Degenerated(E); 
   if (isdgE) {
     return Standard_False;
@@ -745,7 +824,7 @@ Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E)
   l = BC.LastParameter();
   tolE = BC.Tolerance(); 
   tolp = BC.Resolution(tolE);
-  
+
   onf = Abs(f-par)<tolp; 
   onl = Abs(l-par)<tolp; 
   inbounds = (f<par) && (par<l);
@@ -753,15 +832,15 @@ Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E)
   if ((!inbounds) && (!onf) && (!onl)) {
     return Standard_False;
   }
-  
-  
+
+
   gp_Pnt aP;
 
   BC.D1(par, aP, Tg);
   Tg.Normalize(); 
   
   return Standard_True;
-}
+    }
 //=======================================================================
 //function : TangentOnEdge
 //purpose  : 
@@ -771,9 +850,9 @@ Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E)
 {
   Standard_Real aT;
   gp_Vec aTg;
-
+    
   DTg.SetCoord(1.,0.,0.);
-
+    
   aT= BOPTools_AlgoTools2D::IntermediatePoint (aE);
   Standard_Boolean bIsFound=BOPTools_AlgoTools2D::TangentOnEdge(aT, aE, aTg);
   if (bIsFound) {
@@ -782,7 +861,7 @@ Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E)
   }
   return bIsFound;
 }
-  
+
 //=======================================================================
 //function : TangentOnVertex
 //purpose  : 
@@ -802,12 +881,12 @@ Standard_Boolean CheckEdgeLength (const TopoDS_Edge& E)
   ok =BOPTools_AlgoTools2D::TangentOnEdge (par, e, tg);
   if (!ok) {
     return ok;
-  }
+    }
   if (v.IsSame(vl)) {
     tg.Reverse();
   }
   aVec=tg;
-
+  
   return ok;
 }
 
index 87ca37f47d1baaadae34c03ed623b547f9c9733b..e66a33f3057fce0780ba9f73e0a8b262ac1310bb 100644 (file)
@@ -84,14 +84,16 @@ is
         theS2   : Shape     from TopoDS; 
         theOp   : Operation from BOPAlgo;
         bTestSE : Boolean   from Standard; 
-        bTestSI : Boolean   from Standard)
+        bTestSI : Boolean   from Standard;
+        theCopy : Boolean from Standard = Standard_True)
       is protected;  
     ---Purpose: Initialyzes data.
  
     SetData(me:out; 
         theS   : Shape   from TopoDS; 
         bTestSE : Boolean from Standard = Standard_True; 
-        bTestSI : Boolean from Standard = Standard_True);
+        bTestSI : Boolean from Standard = Standard_True;
+        theCopy : Boolean from Standard = Standard_True);
     ---Purpose: Sets data for check by Init method.
     -- The method provides alternative way for checking single shape. 
      
@@ -100,7 +102,8 @@ is
         theS2   : Shape     from TopoDS; 
         theOp   : Operation from BOPAlgo = BOPAlgo_UNKNOWN;
         bTestSE : Boolean   from Standard = Standard_True; 
-        bTestSI : Boolean   from Standard = Standard_True);
+        bTestSI : Boolean   from Standard = Standard_True;
+        theCopy : Boolean from Standard = Standard_True);
     ---Purpose: Sets data for check by Init method.
     -- The method provides alternative way for checking couple of shapes.
     
index b13947268d14480b1681f8791f2ab3b8ef68e899..741d73286ad82c895b93b284c88d56b00c0685ef 100644 (file)
 //=======================================================================
   void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS,
                                   const Standard_Boolean bTestSE,
-                                  const Standard_Boolean bTestSI)
+                                  const Standard_Boolean bTestSI,
+                                  const Standard_Boolean theCopy)
 {
-  Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
+  Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI, theCopy);
 }
 
 //=======================================================================
                                   const TopoDS_Shape& theS2,
                                   const BOPAlgo_Operation theOp,
                                   const Standard_Boolean bTestSE,
-                                  const Standard_Boolean bTestSI)
+                                  const Standard_Boolean bTestSI,
+                                  const Standard_Boolean theCopy)
 {
-  Init(theS1, theS2, theOp, bTestSE, bTestSI);
+  Init(theS1, theS2, theOp, bTestSE, bTestSI, theCopy);
 }
 
 
                                const TopoDS_Shape& theS2,
                                const BOPAlgo_Operation theOp,
                                const Standard_Boolean bTestSE,
-                               const Standard_Boolean bTestSI)
+                               const Standard_Boolean bTestSI,
+                               const Standard_Boolean theCopy )
 {
   myResult.Clear();
-  myS1 = theS1.IsNull() ? theS1 : BRepBuilderAPI_Copy(theS1).Shape();
-  myS2 = theS2.IsNull() ? theS2 : BRepBuilderAPI_Copy(theS2).Shape();
+  myS1 = theS1.IsNull() || !theCopy ? theS1 : BRepBuilderAPI_Copy(theS1).Shape();
+  myS2 = theS2.IsNull() || !theCopy ? theS2 : BRepBuilderAPI_Copy(theS2).Shape();
   //
   myAnalyzer = new BOPAlgo_ArgumentAnalyzer();
   //
index 5d2e594fdfa44115282cc8e0bf5d8112788b830f..8b33d0a0443466eac1226817f0d388620daed2a7 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 #include <ElCLib.hxx>
 #include <Geom_Surface.hxx>
 #include <BRep_Tool.hxx>
+#include <math_RealRandom.hxx>
+#include <BRepTopAdaptor_FClass2d.hxx>
 
 static
-  void FaceNormal (const TopoDS_Face& aF,
-                  const Standard_Real U,
-                  const Standard_Real V,
-                  gp_Dir& aDN);
+  Standard_Boolean FaceNormal (const TopoDS_Face& aF,
+                               const Standard_Real U,
+                               const Standard_Real V,
+                               gp_Dir& aDN);
 
 static 
   Standard_Real GetAddToParam(const gp_Lin& L,const Standard_Real P,const Bnd_Box& B);
@@ -73,13 +75,17 @@ BRepClass3d_SClassifier::BRepClass3d_SClassifier(BRepClass3d_SolidExplorer& S,
 //=======================================================================
 void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& aSE,
                                                   const Standard_Real /*Tol*/) {
-  //-- Idea : Take point A in face1 and point B in face B 
-  //-- (if there is only one face, take 2 points in the same face.)
-  //-- 
-  //-- Intersect straight line AB with the solid and produce transition of the 
-  //-- first point. If the solid has only one face and the straight line AB does not cut it 
-  //-- it is not possible to decide.
 
+  //Take a normal to the first extracted face in its random inner point
+  //and intersect this reversed normal with the faces of the solid.
+  //If the min.par.-intersection point is
+  // a) inner point of a face
+  // b) transition is not TANGENT
+  //    (the line does not touch the face but pierces it)
+  //then set <myState> to IN or OUT according to transition
+  //else take the next random point inside the min.par.-intersected face
+  //and continue
+  
   if(aSE.Reject(gp_Pnt(0,0,0))) { 
     myState=3; //-- in ds solid case without face 
     return;
@@ -87,150 +93,83 @@ void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& aS
   //
   //------------------------------------------------------------
   // 1
-  Standard_Boolean bFound, bFlag;
-  Standard_Integer nump;
-  Standard_Real aParam, aU1 = 0., aV1 = 0., aU2 = 0., aV2 = 0.;
-  gp_Pnt A,B;
-  gp_Dir aDN1, aDN2;
-  TopoDS_Face aF1, aF2;
-  //
-  nump = 0;
-  aParam = 0.5;
+  Standard_Boolean bFound;
+  Standard_Real aParam, aU = 0., aV = 0.;
+  gp_Pnt aPoint;
+  gp_Dir aDN;
+
+  math_RealRandom RandomGenerator(0.1, 0.9);
   myFace.Nullify();
-  myState=2; 
-  for(aSE.InitShell(); aSE.MoreShell() && nump<2;  aSE.NextShell()) { 
-    for(aSE.InitFace();        aSE.MoreFace()  && nump<2; ) {
+  myState=2;
+
+  aSE.InitShell();
+  if (aSE.MoreShell())
+  {
+    aSE.InitFace();
+    if (aSE.MoreFace())
+    {
       TopoDS_Face aF = aSE.CurrentFace();
-      aSE.NextFace();
-      if(!nump) { 
-       nump++;
-       bFound=aSE.FindAPointInTheFace(aF, A, aU1, aV1, aParam);
-       if (!bFound) {
-         return;
-       }
-       aF1=aF;
-       if(!aSE.MoreFace()) { 
-         nump++;
-         bFound=aSE.FindAPointInTheFace(aF, B, aU2, aV2, aParam);
-         if (!bFound) {
-           return;
-         }
-         aF2=aF;
-       }
-      }// if(nump==0) {    
-      else if(nump==1) { 
-       bFound=aSE.FindAPointInTheFace(aF, B, aU2, aV2, aParam);
-       if(!bFound) { 
-         return;
-       } 
-       aF2=aF;
-       nump++;
-      }
-    }// for(aSE.InitFace();    aSE.MoreFace()  && nump<2; ) {
-  }// for(aSE.InitShell(); aSE.MoreShell() && nump<2;  aSE.NextShell()) { 
-  //
-  //------------------------------------------------------------
-  // 2
-  Standard_Integer cpasbon;
-  Standard_Real parmin, aD2, aSP;
-  IntCurveSurface_TransitionOnCurve aTC;    
-  TopAbs_State aState;
-  //
-  parmin = RealLast();
-  //
-  bFlag=Standard_False;
-  if (aF1!=aF2) {
-    FaceNormal(aF1, aU1, aV1, aDN1);
-    FaceNormal(aF2, aU2, aV2, aDN2);
-    aSP=1.-aDN1*aDN2;
-    if (aSP < 1.e-5) {
-      bFlag=!bFlag;
-    }
-  }
-  //
-  aD2=A.SquareDistance(B);
-  if(aD2<0.000001 || bFlag) { 
-    B.SetCoord(A.X()+1,A.Y()+1,A.Z()+1);
-  }
-  //
-  cpasbon = 0;
-  gp_Vec AB(A,B);
-  //
-  do { 
-    switch (cpasbon) 
+      TopAbs_State aState = TopAbs_OUT;
+      IntCurveSurface_TransitionOnCurve aTransition = IntCurveSurface_Tangent;
+      TopoDS_Face MinFace = aF;
+      for (;;)
       {
-      case 1 : AB.SetX(-AB.X());break;
-      case 2 : AB.SetY(-AB.Y());break;
-      case 3 : AB.SetZ(-AB.Z());break;
-      case 4 : AB.SetY(-AB.Y());break;
-      case 5 : AB.SetX(-AB.X());break;
-      }
-    gp_Lin L(A,gp_Dir(AB));    
-    //-- cout<<"\npoint A "<<A.X()<<" "<<A.Y()<<" "<<A.Z()<<endl;
-    //-- cout<<"\npoint B "<<B.X()<<" "<<B.Y()<<" "<<B.Z()<<endl;
-    for(aSE.InitShell();aSE.MoreShell();aSE.NextShell()) { 
-      if(aSE.RejectShell(L) == Standard_False) { 
-       for(aSE.InitFace();aSE.MoreFace(); aSE.NextFace()) {
-         if(aSE.RejectFace(L) == Standard_False) { 
-           TopoDS_Shape aLocalShape = aSE.CurrentFace();
-           TopoDS_Face f = TopoDS::Face(aLocalShape);
-           IntCurvesFace_Intersector& Intersector3d = aSE.Intersector(f);
-           Intersector3d.Perform(L,-RealLast(),parmin); 
-
-           if(Intersector3d.IsDone()) { 
-             if(Intersector3d.NbPnt()) { 
-               if(Intersector3d.WParameter(1) < parmin) {
-                 aState=Intersector3d.State(1);
-                 parmin = Intersector3d.WParameter(1);
-                 if(aState==TopAbs_IN || aState==TopAbs_ON) { 
-                   aTC=Intersector3d.Transition(1);
-                   //-- The intersection point between the line and a face F 
-                   // -- of the solid is in the face F 
-                   if(aTC == IntCurveSurface_Out) { 
-                     //-- The line is going from inside the solid to outside 
-                     //-- the solid.
-                     myState = 3; //-- IN --
-                   }
-                   else if(aTC == IntCurveSurface_In) { 
-                     myState = 4; //-- OUT --
-                   }
-                   myFace  = f;
-                 }
-                 /*
-                 else if(Intersector3d.State(1)==TopAbs_ON)  {
-                   //-- The intersection point between the line and a face F 
-                   //-- of the solid is in the face F 
-                   if(Intersector3d.Transition(1) == IntCurveSurface_Out) { 
-                     //-- The line is going from inside the solid to outside 
-                     //-- the solid.
-                     myState = 3; //-- IN --
-                   }
-                   else if(Intersector3d.Transition(1) == IntCurveSurface_In) { 
-                     myState = 4; //-- OUT --
-                   }
-                   //-- myState = 2;
-                   myFace  = f;
-                 }
-                 */
-               }
-               
-               else { 
-                 //-- No point has been found by the Intersector3d.
-                 //-- Or a Point has been found with a greater parameter.
-               }
-             }
-           }
-         }
-       } //-- Exploration of the faces
-      } //-- Shell has not been rejected
-      else { 
-       myState=1; 
+        aParam = RandomGenerator.Next();
+       bFound = aSE.FindAPointInTheFace(aF, aPoint, aU, aV, aParam);
+       if (!bFound)
+         return;
+
+        if (!FaceNormal(aF, aU, aV, aDN))
+          continue;
+        gp_Lin aLin(aPoint, -aDN);
+        Standard_Real parmin = RealLast();
+        for (aSE.InitShell();aSE.MoreShell();aSE.NextShell()) { 
+          if (aSE.RejectShell(aLin) == Standard_False) { 
+            for (aSE.InitFace();aSE.MoreFace(); aSE.NextFace()) {
+              if (aSE.RejectFace(aLin) == Standard_False) { 
+                TopoDS_Shape aLocalShape = aSE.CurrentFace();
+                TopoDS_Face CurFace = TopoDS::Face(aLocalShape);
+                IntCurvesFace_Intersector& Intersector3d = aSE.Intersector(CurFace);
+                Intersector3d.Perform(aLin,-RealLast(),parmin); 
+                
+                if(Intersector3d.IsDone()) {
+                  if(Intersector3d.NbPnt()) { 
+                    Standard_Integer imin = 1;
+                    for (Standard_Integer i = 2; i <= Intersector3d.NbPnt(); i++)
+                      if (Intersector3d.WParameter(i) < Intersector3d.WParameter(imin))
+                        imin = i;
+                    parmin = Intersector3d.WParameter(imin);
+                    aState = Intersector3d.State(imin);
+                    aTransition = Intersector3d.Transition(imin);
+                    MinFace = CurFace;
+                  }
+                }
+              }
+            }
+          }
+          else
+            myState = 1;
+        } //end of loop on the whole solid
+        
+        if (aState == TopAbs_IN)
+        {
+          if (aTransition == IntCurveSurface_Out) { 
+            //-- The line is going from inside the solid to outside 
+            //-- the solid.
+            myState = 3; //-- IN --
+            return;
+          }
+          else if (aTransition == IntCurveSurface_In) { 
+            myState = 4; //-- OUT --
+            return;
+          }
+        }
+        aF = MinFace;
       }
-    } //-- Exploration of the shells
-    cpasbon++;
-  }
-  while(cpasbon!=0 && cpasbon<5);
+    } //if (aSE.MoreFace())
+  } //if (aSE.MoreShell())
 }
+
 //=======================================================================
 //function : Perform
 //purpose  : 
@@ -516,10 +455,10 @@ Standard_Real GetAddToParam(const gp_Lin&       L,
 //function : FaceNormal
 //purpose  : 
 //=======================================================================
-void FaceNormal (const TopoDS_Face& aF,
-                const Standard_Real U,
-                const Standard_Real V,
-                gp_Dir& aDN)
+Standard_Boolean FaceNormal (const TopoDS_Face& aF,
+                             const Standard_Real U,
+                             const Standard_Real V,
+                             gp_Dir& aDN)
 {
   gp_Pnt aPnt ;
   gp_Vec aD1U, aD1V, aN;
@@ -528,10 +467,13 @@ void FaceNormal (const TopoDS_Face& aF,
   aS=BRep_Tool::Surface(aF);
   aS->D1 (U, V, aPnt, aD1U, aD1V);
   aN=aD1U.Crossed(aD1V);
+  if (aN.Magnitude() <= gp::Resolution())
+    return Standard_False;
+  
   aN.Normalize();  
   aDN.SetXYZ(aN.XYZ());
   if (aF.Orientation() == TopAbs_REVERSED){
     aDN.Reverse();
   }
-  return;
+  return Standard_True;
 }
index 9173aa113b2c0440179782613bc97b27c1c68eea..04b618195f2b4869872dc5e7631dfb91e02e3e2e 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -54,6 +54,8 @@
 #include <BRep_Tool.hxx> 
 #include <BRepClass_FaceClassifier.hxx>
 //<-OCC454(apo)
+#include <BRepTopAdaptor_FClass2d.hxx> 
+
 
 //=======================================================================
 //function : FindAPointInTheFace
@@ -177,6 +179,14 @@ Standard_Boolean BRepClass3d_SolidExplorer::FindAPointInTheFace
       ParamInit *= 0.41234;
       u_ = P.X() + ParamInit* T.X();
       v_ = P.Y() + ParamInit* T.Y();
+
+      //Additional check
+      BRepTopAdaptor_FClass2d Classifier(face, Precision::Confusion());
+      gp_Pnt2d aPnt2d(u_, v_);
+      TopAbs_State StateOfResultingPoint = Classifier.Perform(aPnt2d);
+      if (StateOfResultingPoint != TopAbs_IN)
+        return Standard_False;
+      
       BRepAdaptor_Surface s;
       s.Initialize (face, Standard_False);
       s.D1 (u_, v_, APoint_, theVecD1U, theVecD1V);
@@ -254,42 +264,42 @@ Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace
           }
         }
       }
-         
+          
       for(u=-du+(U1+U2)*0.5; u>U1; u-=du) {         //--  0  0    u decreases
-       for(v=-dv+(V1+V2)*0.5; v>V1; v-=dv) {       //--  X  0    v decreases
-         if(++NbPntCalc>=IndexPoint) {
-           if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { 
-             u_=u; v_=v;
-             surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
-             IndexPoint = NbPntCalc;
-             return(Standard_True);
-           }
-         }
-       }
+        for(v=-dv+(V1+V2)*0.5; v>V1; v-=dv) {       //--  X  0    v decreases
+          if(++NbPntCalc>=IndexPoint) {
+            if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { 
+              u_=u; v_=v;
+              surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
+              IndexPoint = NbPntCalc;
+              return(Standard_True);
+            }
+          }
+        }
       }
       for(u=-du+(U1+U2)*0.5; u>U1; u-=du) {         //--  X  0    u decreases
-       for(v=dv+(V1+V2)*0.5; v<V2; v+=dv) {        //--  0  0    v increases
-         if(++NbPntCalc>=IndexPoint) { 
-           if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { 
-             u_=u; v_=v;
-             surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
-             IndexPoint = NbPntCalc;
-             return(Standard_True);
-           }
-         }
-       }
+        for(v=dv+(V1+V2)*0.5; v<V2; v+=dv) {        //--  0  0    v increases
+          if(++NbPntCalc>=IndexPoint) { 
+            if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { 
+              u_=u; v_=v;
+              surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
+              IndexPoint = NbPntCalc;
+              return(Standard_True);
+            }
+          }
+        }
       }
       for(u=du+(U1+U2)*0.5; u<U2; u+=du) {         //--  0  0     u increases
-       for(v=-dv+(V1+V2)*0.5; v>V1; v-=dv) {      //--  0  X     v decreases
-         if(++NbPntCalc>=IndexPoint) {
-           if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { 
-             u_=u; v_=v;
-             surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
-             IndexPoint = NbPntCalc;
-             return(Standard_True);
-           }
-         }
-       }
+        for(v=-dv+(V1+V2)*0.5; v>V1; v-=dv) {      //--  0  X     v decreases
+          if(++NbPntCalc>=IndexPoint) {
+            if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { 
+              u_=u; v_=v;
+              surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
+              IndexPoint = NbPntCalc;
+              return(Standard_True);
+            }
+          }
+        }
       }
       //-- the remainder
       du = (U2-U1)/37.0;
@@ -298,26 +308,26 @@ Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace
       if(dv<1e-12) dv=1e-12;
       
       for(u=du+U1; u<U2; u+=du) { 
-       for(v=dv+V1; v<V2; v+=dv) {
-         if(++NbPntCalc>=IndexPoint) {
-           if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { 
-             u_=u; v_=v;
-             surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
-             IndexPoint = NbPntCalc;
-             return(Standard_True);
-           }
-         }
-       }
+        for(v=dv+V1; v<V2; v+=dv) {
+          if(++NbPntCalc>=IndexPoint) {
+            if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { 
+              u_=u; v_=v;
+              surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
+              IndexPoint = NbPntCalc;
+              return(Standard_True);
+            }
+          }
+        }
       }
       u=(U1+U2)*0.5;
       v=(V1+V2)*0.5;
       if(++NbPntCalc>=IndexPoint) {
-       if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { 
-         u_=u; v_=v;
-         surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
-         IndexPoint = NbPntCalc;
-         return(Standard_True);
-       }
+        if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) { 
+          u_=u; v_=v;
+          surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
+          IndexPoint = NbPntCalc;
+          return(Standard_True);
+        }
       }
     }
     IndexPoint = NbPntCalc;
@@ -335,9 +345,9 @@ Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace
 //purpose  : Limit infinite parameters
 //=======================================================================
 static void LimitInfiniteUV (Standard_Real& U1,
-                            Standard_Real& V1,
-                            Standard_Real& U2,
-                            Standard_Real& V2)
+                             Standard_Real& V1,
+                             Standard_Real& U2,
+                             Standard_Real& V2)
 {
   Standard_Boolean
     infU1 = Precision::IsNegativeInfinite(U1),
@@ -355,9 +365,9 @@ static void LimitInfiniteUV (Standard_Real& U1,
 //purpose  : 
 //=======================================================================
 static Standard_Integer IsInfiniteUV (Standard_Real& U1, 
-                                     Standard_Real& V1,
-                                     Standard_Real& U2, 
-                                     Standard_Real& V2) 
+                                      Standard_Real& V1,
+                                      Standard_Real& U2, 
+                                      Standard_Real& V2) 
 {
   Standard_Integer aVal = 0;
 
@@ -388,8 +398,8 @@ static Standard_Integer IsInfiniteUV (Standard_Real& U1,
 //           and so on. 
 //=======================================================================
 Standard_Integer BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P, 
-                                                        gp_Lin& L, 
-                                                        Standard_Real& _Par) 
+                                                         gp_Lin& L, 
+                                                         Standard_Real& _Par) 
 {
   const Standard_Real TolU = Precision::PConfusion();
   const Standard_Real TolV = TolU;
@@ -429,7 +439,7 @@ Standard_Integer BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P,
       //
       //avoid process faces from uncorrected shells
       if( Abs (U2 - U1) < 1.e-12 || Abs(V2 - V1) < 1.e-12) {
-       return 2;
+        return 2;
       }
       //
       Standard_Real svmyparam=myParamOnEdge;
@@ -441,60 +451,60 @@ Standard_Integer BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P,
       Extrema_ExtPS Ext(P, GA, TolU, TolV);
       //
       if (Ext.IsDone() && Ext.NbExt() > 0) {
-       Standard_Integer i, iNear,  iEnd;
-       Standard_Real  aUx, aVx, Dist2, Dist2Min;
-       Extrema_POnSurf aPx;
-       //
-       iNear = 1;
-       Dist2Min = Ext.SquareDistance(1);
-       iEnd = Ext.NbExt();
-       for (i = 2; i <= iEnd; i++) {
-         aPx=Ext.Point(i);
-         aPx.Parameter(aUx, aVx);
-         if (aUx>=U1 && aUx<=U2 && aVx>=V1 && aVx<=V2) {
-           Dist2 = Ext.SquareDistance(i);
-           if (Dist2 < Dist2Min) {
-             Dist2Min = Dist2; 
-             iNear = i;
-           }
-         }
-       }
-       //
-       Standard_Real aDist2Tresh=1.e-24;
-       //
-       if (Dist2Min<aDist2Tresh) {
-         if (anInfFlag) {
-           return 1;
-         } 
-         else {
-           BRepClass_FaceClassifier classifier2d;
-           Standard_Real            aU;
-           Standard_Real            aV;
-
-           (Ext.Point(iNear)).Parameter(aU, aV);
-
-           gp_Pnt2d aPuv(aU, aV);
-
-           classifier2d.Perform(face,aPuv,Precision::PConfusion());
-
-           TopAbs_State aState = classifier2d.State();
-
-           if (aState == TopAbs_IN || aState == TopAbs_ON) {
-             return 1;
-           }
-           else {
-             return 3; // skv - the point is on surface but outside face.
-           }
-         }
-       }
-       if (anInfFlag) {
-         APoint = (Ext.Point(iNear)).Value();
-         gp_Vec V(P,APoint);
-         _Par = V.Magnitude(); 
-         L = gp_Lin(P,V);
-         ptfound=Standard_True;
-         return 0;
-       }
+        Standard_Integer i, iNear,  iEnd;
+        Standard_Real  aUx, aVx, Dist2, Dist2Min;
+        Extrema_POnSurf aPx;
+        //
+        iNear = 1;
+        Dist2Min = Ext.SquareDistance(1);
+        iEnd = Ext.NbExt();
+        for (i = 2; i <= iEnd; i++) {
+          aPx=Ext.Point(i);
+          aPx.Parameter(aUx, aVx);
+          if (aUx>=U1 && aUx<=U2 && aVx>=V1 && aVx<=V2) {
+            Dist2 = Ext.SquareDistance(i);
+            if (Dist2 < Dist2Min) {
+              Dist2Min = Dist2; 
+              iNear = i;
+            }
+          }
+        }
+        //
+        Standard_Real aDist2Tresh=1.e-24;
+        //
+        if (Dist2Min<aDist2Tresh) {
+          if (anInfFlag) {
+            return 1;
+          
+          else {
+            BRepClass_FaceClassifier classifier2d;
+            Standard_Real            aU;
+            Standard_Real            aV;
+
+            (Ext.Point(iNear)).Parameter(aU, aV);
+
+            gp_Pnt2d aPuv(aU, aV);
+
+            classifier2d.Perform(face,aPuv,Precision::PConfusion());
+
+            TopAbs_State aState = classifier2d.State();
+
+            if (aState == TopAbs_IN || aState == TopAbs_ON) {
+              return 1;
+            }
+            else {
+              return 3; // skv - the point is on surface but outside face.
+            }
+          }
+        }
+        if (anInfFlag) {
+          APoint = (Ext.Point(iNear)).Value();
+          gp_Vec V(P,APoint);
+          _Par = V.Magnitude(); 
+          L = gp_Lin(P,V);
+          ptfound=Standard_True;
+          return 0;
+        }
       }
       //The point is not ON the face or surface. The face is restricted.
       // find point in a face not too far from a projection of P on face
@@ -506,7 +516,9 @@ Standard_Integer BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P,
           ++NbPointsOK;
           gp_Vec V (P, APoint);
           Par = V.Magnitude();
-          if (Par > gp::Resolution())
+          if (Par > gp::Resolution() &&
+              aVecD1U.Magnitude() > gp::Resolution() &&
+              aVecD1V.Magnitude() > gp::Resolution())
           {
             gp_Vec Norm = aVecD1U.Crossed (aVecD1V);
             Standard_Real tt = Norm.Magnitude();
@@ -529,8 +541,8 @@ Standard_Integer BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P,
       while(IndexPoint<200 && NbPointsOK<16);
 
       myParamOnEdge=svmyparam;
-      if(maxscal>0.2) {                  
-       return 0;
+      if(maxscal>0.2) {                  
+        return 0;
       }
 
 
@@ -542,16 +554,16 @@ Standard_Integer BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P,
 
       Standard_Boolean encoreuneface = faceexplorer.More();
       if(ptfound==Standard_False && encoreuneface==Standard_False) { 
-       if(myParamOnEdge < 0.0001) { 
-         //-- This case takes place when the point is on the solid
-         //-- and this solid is reduced to a face 
-         gp_Pnt PBidon(P.X()+1.0,P.Y(),P.Z());
-         gp_Vec V(P,PBidon);
-         Par= 1.0;
-         _Par=Par;
-         L  = gp_Lin(P,V);
-         return 0;
-       }
+        if(myParamOnEdge < 0.0001) { 
+          //-- This case takes place when the point is on the solid
+          //-- and this solid is reduced to a face 
+          gp_Pnt PBidon(P.X()+1.0,P.Y(),P.Z());
+          gp_Vec V(P,PBidon);
+          Par= 1.0;
+          _Par=Par;
+          L  = gp_Lin(P,V);
+          return 0;
+        }
       }
     } //-- Exploration of the faces   
 
@@ -580,12 +592,12 @@ Standard_Integer BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P,
     else {
       myParamOnEdge*=0.5;  
       if(myParamOnEdge < 0.0001) { 
-       gp_Pnt PBidon(P.X()+1.0,P.Y(),P.Z());
-       gp_Vec V(P,PBidon);
-       Par= 1.0;
-       _Par=Par;
-       L  = gp_Lin(P,V);
-       return 0;
+        gp_Pnt PBidon(P.X()+1.0,P.Y(),P.Z());
+        gp_Vec V(P,PBidon);
+        Par= 1.0;
+        _Par=Par;
+        L  = gp_Lin(P,V);
+        return 0;
       }
     }
   } //-- for(;;) { ...  } 
@@ -896,8 +908,8 @@ Standard_Boolean BRepClass3d_SolidExplorer::RejectFace(const gp_Lin& ) const
 //           compute  intersections. 
 //=======================================================================
 Standard_Integer  BRepClass3d_SolidExplorer::Segment(const gp_Pnt& P, 
-                                                    gp_Lin& L, 
-                                                    Standard_Real& Par)  
+                                                     gp_Lin& L, 
+                                                     Standard_Real& Par)  
 {
   Standard_Integer bRetFlag;
   myFirstFace = 0;
@@ -931,9 +943,9 @@ const Bnd_Box& BRepClass3d_SolidExplorer::Box() const {
 //=======================================================================
 
 void BRepClass3d_SolidExplorer::DumpSegment(const gp_Pnt&,
-                                           const gp_Lin&,
-                                           const Standard_Real,
-                                           const TopAbs_State) const
+                                            const gp_Lin&,
+                                            const Standard_Real,
+                                            const TopAbs_State) const
 {
 #ifdef DEB
  
index 0487208416e470f135b0abaf74cb696a59a0efd0..66337396e8c16468ec112d0f01f703983b27c02d 100644 (file)
@@ -5,8 +5,8 @@
 --
 -- This file is part of Open CASCADE Technology software library.
 --
--- This library is free software; you can redistribute it and / or modify it
--- under the terms of the GNU Lesser General Public version 2.1 as published
+-- This library is free software; you can redistribute it and/or modify it under
+-- the terms of the GNU Lesser General Public License version 2.1 as published
 -- by the Free Software Foundation, with special exception defined in the file
 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 -- distribution for complete text of the license and disclaimer of any warranty.
index eb3282630f7949f12977fece0bd4eea8d3477f04..108ee9eed4e44eb1cce04bccb1187eb635ec76ee 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
index b70d5110aef075fdc90e2f122410f85fd04488b5..90e9cda76b11b5318ad31246dd1de865e0207b72 100644 (file)
@@ -2,8 +2,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 #ifndef _BRepExtrema_DistShapeShape_HeaderFile
 #define _BRepExtrema_DistShapeShape_HeaderFile
 
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_DefineAlloc_HeaderFile
-#include <Standard_DefineAlloc.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _Standard_Integer_HeaderFile
-#include <Standard_Integer.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _BRepExtrema_SeqOfSolution_HeaderFile
 #include <BRepExtrema_SeqOfSolution.hxx>
-#endif
-#ifndef _BRepExtrema_SolutionElem_HeaderFile
 #include <BRepExtrema_SolutionElem.hxx>
-#endif
-#ifndef _TopoDS_Shape_HeaderFile
 #include <TopoDS_Shape.hxx>
-#endif
-#ifndef _TopTools_IndexedMapOfShape_HeaderFile
 #include <TopTools_IndexedMapOfShape.hxx>
-#endif
-#ifndef _Extrema_ExtFlag_HeaderFile
 #include <Extrema_ExtFlag.hxx>
-#endif
-#ifndef _Extrema_ExtAlgo_HeaderFile
 #include <Extrema_ExtAlgo.hxx>
-#endif
-#ifndef _BRepExtrema_SupportType_HeaderFile
 #include <BRepExtrema_SupportType.hxx>
-#endif
-#ifndef _Standard_OStream_HeaderFile
-#include <Standard_OStream.hxx>
-#endif
-#ifndef _gp_Pnt_HeaderFile
 #include <gp_Pnt.hxx>
-#endif
+#include <Standard_OStream.hxx>
+#include <Standard_DefineAlloc.hxx>
+
 class TopoDS_Shape;
 class TopTools_IndexedMapOfShape;
 class Bnd_SeqOfBox;
index 38cbcc49f8b9e2418c9c907c843d2845e0c12023..3a755870ab029ad7497152d711f56bd057a721f8 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
index ee4e924e3309fa8548d1bfc6c4ff17edd8722de6..56cd6d2e55b49faea44bb94ca10726948287cd9a 100644 (file)
@@ -2,8 +2,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 #ifndef _BRepExtrema_DistanceSS_HeaderFile
 #define _BRepExtrema_DistanceSS_HeaderFile
 
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_DefineAlloc_HeaderFile
-#include <Standard_DefineAlloc.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _BRepExtrema_SeqOfSolution_HeaderFile
 #include <BRepExtrema_SeqOfSolution.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Extrema_ExtFlag_HeaderFile
 #include <Extrema_ExtFlag.hxx>
-#endif
-#ifndef _Extrema_ExtAlgo_HeaderFile
 #include <Extrema_ExtAlgo.hxx>
-#endif
-#ifndef _Precision_HeaderFile
 #include <Precision.hxx>
-#endif
+#include <Standard_DefineAlloc.hxx>
+
 class TopoDS_Shape;
 class Bnd_Box;
 class TopoDS_Vertex;
index b9b228ae6155e9f2d3e2d51423605ae6667d5fa3..9ca3b84ade9c6a7b48d87df99d0fe4c9a3f681cd 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -43,8 +43,11 @@ void BRepExtrema_ExtCC::Initialize(const TopoDS_Edge& E2)
   Standard_Real V1,V2;
   BRepAdaptor_Curve Curv(E2);
   myHC = new BRepAdaptor_HCurve(Curv);
+  Standard_Real Tol = Min(BRep_Tool::Tolerance(E2), Precision::Confusion());
+  Tol = Max(Curv.Resolution(Tol), Precision::PConfusion());
   BRep_Tool::Range(E2,V1,V2);
   myExtCC.SetCurve(2,myHC->Curve(),V1,V2);
+  myExtCC.SetTolerance(2, Tol);
 }
 
 //=======================================================================
@@ -57,8 +60,11 @@ void BRepExtrema_ExtCC::Perform(const TopoDS_Edge& E1)
   Standard_Real U1, U2;
   BRepAdaptor_Curve Curv(E1);
   Handle(BRepAdaptor_HCurve) HC = new BRepAdaptor_HCurve(Curv);
+  Standard_Real Tol = Min(BRep_Tool::Tolerance(E1), Precision::Confusion());
+  Tol = Max(Curv.Resolution(Tol), Precision::PConfusion());
   BRep_Tool::Range(E1,U1,U2);
   myExtCC.SetCurve (1, HC->Curve(), U1, U2);
+  myExtCC.SetTolerance(1, Tol);
   myExtCC.Perform();
 }
 
index 41127405d55119832c935714aef9b2301ebe7ef8..c426ec7f1b21401278a0eea4b0fc65442ff84db4 100644 (file)
@@ -2,8 +2,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 #ifndef _BRepExtrema_ExtCC_HeaderFile
 #define _BRepExtrema_ExtCC_HeaderFile
 
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_DefineAlloc_HeaderFile
+#include <Extrema_ExtCC.hxx>
+#include <BRepAdaptor_HCurve.hxx>
 #include <Standard_DefineAlloc.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
 
-#ifndef _Extrema_ExtCC_HeaderFile
-#include <Extrema_ExtCC.hxx>
-#endif
-#ifndef _Handle_BRepAdaptor_HCurve_HeaderFile
-#include <Handle_BRepAdaptor_HCurve.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Standard_Integer_HeaderFile
-#include <Standard_Integer.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
 class BRepAdaptor_HCurve;
 class TopoDS_Edge;
 class gp_Pnt;
index 0bd78e1578a5ea039b0e86cb8fa9501a4481f270..897f2018c1acaa62152f9c8240d31c5c060f9c52 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -33,7 +33,7 @@
 
 BRepExtrema_ExtCF::BRepExtrema_ExtCF(const TopoDS_Edge& E, const TopoDS_Face& F)
 {
-  Initialize(F);
+  Initialize(E, F);
   Perform(E, F);
 }
 
@@ -42,14 +42,24 @@ BRepExtrema_ExtCF::BRepExtrema_ExtCF(const TopoDS_Edge& E, const TopoDS_Face& F)
 //purpose  : 
 //=======================================================================
 
-void BRepExtrema_ExtCF::Initialize(const TopoDS_Face& F2)
+void BRepExtrema_ExtCF::Initialize(const TopoDS_Edge& E, const TopoDS_Face& F)
 {
-  BRepAdaptor_Surface Surf(F2);
+  BRepAdaptor_Surface Surf(F);
+  BRepAdaptor_Curve aC(E);
   myHS = new BRepAdaptor_HSurface(Surf);
-  const Standard_Real Tol = BRep_Tool::Tolerance(F2);
+  Standard_Real aTolC, aTolS;
+  //
+  aTolS = Min(BRep_Tool::Tolerance(F), Precision::Confusion());
+  aTolS = Min(Surf.UResolution(aTolS), Surf.VResolution(aTolS));
+  aTolS = Max(aTolS, Precision::PConfusion());
+  //
+  aTolC = Min(BRep_Tool::Tolerance(E), Precision::Confusion());
+  aTolC = aC.Resolution(aTolC);
+  aTolC = Max(aTolC, Precision::PConfusion());
+  //
   Standard_Real U1, U2, V1, V2;
-  BRepTools::UVBounds(F2, U1, U2, V1, V2);
-  myExtCS.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol, Tol);
+  BRepTools::UVBounds(F, U1, U2, V1, V2);
+  myExtCS.Initialize(myHS->Surface(), U1, U2, V1, V2, aTolC, aTolS);
 }
 
 //=======================================================================
index 8d524cc34755212df94a80da441e8b270a4b9873..b820c788f14f4a2e2628e79169da4089b42f13f0 100644 (file)
@@ -2,8 +2,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 #ifndef _BRepExtrema_ExtCF_HeaderFile
 #define _BRepExtrema_ExtCF_HeaderFile
 
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_DefineAlloc_HeaderFile
-#include <Standard_DefineAlloc.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _Extrema_ExtCS_HeaderFile
 #include <Extrema_ExtCS.hxx>
-#endif
-#ifndef _Standard_Integer_HeaderFile
-#include <Standard_Integer.hxx>
-#endif
-#ifndef _TColStd_SequenceOfReal_HeaderFile
 #include <TColStd_SequenceOfReal.hxx>
-#endif
-#ifndef _Extrema_SequenceOfPOnSurf_HeaderFile
 #include <Extrema_SequenceOfPOnSurf.hxx>
-#endif
-#ifndef _Extrema_SequenceOfPOnCurv_HeaderFile
 #include <Extrema_SequenceOfPOnCurv.hxx>
-#endif
-#ifndef _Handle_BRepAdaptor_HSurface_HeaderFile
-#include <Handle_BRepAdaptor_HSurface.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-#ifndef _Extrema_POnCurv_HeaderFile
+#include <BRepAdaptor_HSurface.hxx>
 #include <Extrema_POnCurv.hxx>
-#endif
-#ifndef _Extrema_POnSurf_HeaderFile
 #include <Extrema_POnSurf.hxx>
-#endif
+#include <Standard_DefineAlloc.hxx>
+
 class BRepAdaptor_HSurface;
 class TopoDS_Edge;
 class TopoDS_Face;
@@ -70,12 +39,12 @@ class BRepExtrema_ExtCF
   {
   }
   //! It calculates all the distances. <br>
-  Standard_EXPORT BRepExtrema_ExtCF(const TopoDS_Edge& V,const TopoDS_Face& E);
+  Standard_EXPORT BRepExtrema_ExtCF(const TopoDS_Edge& E,const TopoDS_Face& F);
 
-  Standard_EXPORT void Initialize(const TopoDS_Face& E);
+  Standard_EXPORT void Initialize(const TopoDS_Edge& E, const TopoDS_Face& F);
   //! An exception is raised if the fields have not been initialized. <br>
   //! Be careful: this method uses the Face only for classify not for the fields. <br>
-  Standard_EXPORT void Perform(const TopoDS_Edge& V,const TopoDS_Face& F);
+  Standard_EXPORT void Perform(const TopoDS_Edge& E,const TopoDS_Face& F);
   //! True if the distances are found. <br>
   Standard_EXPORT Standard_Boolean IsDone() const
   {
index 8807a40e29cc72b52b512a49b9808c8201493baa..0881dcc4cbb6a4cb091bea4e82eaebd9649dadf0 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -47,7 +47,9 @@ void BRepExtrema_ExtFF::Initialize(const TopoDS_Face& F2)
 {
   BRepAdaptor_Surface Surf(F2);
   myHS = new BRepAdaptor_HSurface(Surf);
-  const Standard_Real Tol = BRep_Tool::Tolerance(F2);
+  Standard_Real Tol = Min(BRep_Tool::Tolerance(F2), Precision::Confusion());
+  Tol = Min(Surf.UResolution(Tol), Surf.VResolution(Tol));
+  Tol = Max(Tol, Precision::PConfusion());
   Standard_Real U1, U2, V1, V2;
   BRepTools::UVBounds(F2, U1, U2, V1, V2);
   myExtSS.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol);
@@ -66,7 +68,9 @@ void BRepExtrema_ExtFF::Perform(const TopoDS_Face& F1, const TopoDS_Face& F2)
 
   BRepAdaptor_Surface Surf1(F1);
   Handle(BRepAdaptor_HSurface) HS1 = new BRepAdaptor_HSurface(Surf1);
-  const Standard_Real Tol1 = BRep_Tool::Tolerance(F1);
+  Standard_Real Tol1 = Min(BRep_Tool::Tolerance(F1), Precision::Confusion());
+  Tol1 = Min(Surf1.UResolution(Tol1), Surf1.VResolution(Tol1));
+  Tol1 = Max(Tol1, Precision::PConfusion());
   Standard_Real U1, U2, V1, V2;
   BRepTools::UVBounds(F1, U1, U2, V1, V2);
   myExtSS.Perform(HS1->Surface(), U1, U2, V1, V2, Tol1);
index b97ee80473e53a8df9a493b97730a2a072bb21f8..05fe925ac492f5dec5d1c799dffedc844136252a 100644 (file)
@@ -2,8 +2,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 #ifndef _BRepExtrema_ExtFF_HeaderFile
 #define _BRepExtrema_ExtFF_HeaderFile
 
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_DefineAlloc_HeaderFile
-#include <Standard_DefineAlloc.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _Extrema_ExtSS_HeaderFile
 #include <Extrema_ExtSS.hxx>
-#endif
-#ifndef _Standard_Integer_HeaderFile
-#include <Standard_Integer.hxx>
-#endif
-#ifndef _TColStd_SequenceOfReal_HeaderFile
 #include <TColStd_SequenceOfReal.hxx>
-#endif
-#ifndef _Extrema_SequenceOfPOnSurf_HeaderFile
 #include <Extrema_SequenceOfPOnSurf.hxx>
-#endif
-#ifndef _Handle_BRepAdaptor_HSurface_HeaderFile
-#include <Handle_BRepAdaptor_HSurface.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-#ifndef _Extrema_POnSurf_HeaderFile
+#include <BRepAdaptor_HSurface.hxx>
 #include <Extrema_POnSurf.hxx>
-#endif
+#include <Standard_DefineAlloc.hxx>
+
 class BRepAdaptor_HSurface;
 class TopoDS_Face;
 class gp_Pnt;
index 0817c4f157c3d452c6c9c268e32864a2d96cc871..4c491c8863462c154071b89ab3f095c118190800 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -44,8 +44,10 @@ void BRepExtrema_ExtPC::Initialize(const TopoDS_Edge& E)
   Standard_Real U1,U2;
   BRepAdaptor_Curve Curv(E);
   myHC = new BRepAdaptor_HCurve(Curv);
+  Standard_Real Tol = Min(BRep_Tool::Tolerance(E), Precision::Confusion());
+  Tol = Max(Curv.Resolution(Tol), Precision::PConfusion());
   BRep_Tool::Range(E,U1,U2);
-  myExtPC.Initialize(myHC->Curve(),U1,U2);
+  myExtPC.Initialize(myHC->Curve(),U1,U2,Tol);
 }
 
 //=======================================================================
index 9d54a6fef65493cc9be6228d7a319419c232ac6f..188b10bb0479e4117430a6c5f6c41829ec558f7e 100644 (file)
@@ -2,8 +2,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 #ifndef _BRepExtrema_ExtPC_HeaderFile
 #define _BRepExtrema_ExtPC_HeaderFile
 
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_DefineAlloc_HeaderFile
+#include <Extrema_ExtPC.hxx>
+#include <BRepAdaptor_HCurve.hxx>
 #include <Standard_DefineAlloc.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
 
-#ifndef _Extrema_ExtPC_HeaderFile
-#include <Extrema_ExtPC.hxx>
-#endif
-#ifndef _Handle_BRepAdaptor_HCurve_HeaderFile
-#include <Handle_BRepAdaptor_HCurve.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Standard_Integer_HeaderFile
-#include <Standard_Integer.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
 class BRepAdaptor_HCurve;
 class TopoDS_Vertex;
 class TopoDS_Edge;
index ac7e38fdd2e40a659d33b8187bd0517421bf9ec2..5b2d4be3005f4a15f66fb2e7b79d17851ac0107d 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -24,6 +24,7 @@
 #include <BRepClass_FaceClassifier.hxx>
 #include <gp_Pnt2d.hxx>
 #include <BRepAdaptor_Surface.hxx>
+#include <Precision.hxx>
 
 //=======================================================================
 //function : BRepExtrema_ExtPF
@@ -48,12 +49,15 @@ void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& TheFace,
   // cette surface doit etre en champ. Extrema ne fait
   // pas de copie et prend seulement un pointeur dessus.
   mySurf.Initialize(TheFace, Standard_False); 
-  const Standard_Real Tol = BRep_Tool::Tolerance(TheFace);
+  Standard_Real Tol = Min(BRep_Tool::Tolerance(TheFace), Precision::Confusion());
+  Standard_Real aTolU, aTolV;
+  aTolU = Max(mySurf.UResolution(Tol), Precision::PConfusion());
+  aTolV = Max(mySurf.VResolution(Tol), Precision::PConfusion()); 
   Standard_Real U1, U2, V1, V2;
   BRepTools::UVBounds(TheFace, U1, U2, V1, V2);
   myExtPS.SetFlag(TheFlag);
   myExtPS.SetAlgo(TheAlgo);
-  myExtPS.Initialize(mySurf, U1, U2, V1, V2, Tol, Tol);
+  myExtPS.Initialize(mySurf, U1, U2, V1, V2, aTolU, aTolV);
 }
 
 //=======================================================================
index 3261f1abc93995225d9d664ce386d0bfea51924b..5c50f7e07fc3510e81802e787451792c25d056de 100644 (file)
@@ -2,8 +2,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 #ifndef _BRepExtrema_ExtPF_HeaderFile
 #define _BRepExtrema_ExtPF_HeaderFile
 
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_DefineAlloc_HeaderFile
 #include <Standard_DefineAlloc.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _Extrema_ExtPS_HeaderFile
 #include <Extrema_ExtPS.hxx>
-#endif
-#ifndef _Standard_Integer_HeaderFile
 #include <Standard_Integer.hxx>
-#endif
-#ifndef _TColStd_SequenceOfReal_HeaderFile
 #include <TColStd_SequenceOfReal.hxx>
-#endif
-#ifndef _Extrema_SequenceOfPOnSurf_HeaderFile
 #include <Extrema_SequenceOfPOnSurf.hxx>
-#endif
-#ifndef _BRepAdaptor_Surface_HeaderFile
 #include <BRepAdaptor_Surface.hxx>
-#endif
-#ifndef _Extrema_ExtFlag_HeaderFile
 #include <Extrema_ExtFlag.hxx>
-#endif
-#ifndef _Extrema_ExtAlgo_HeaderFile
 #include <Extrema_ExtAlgo.hxx>
-#endif
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
+
 class TopoDS_Vertex;
 class TopoDS_Face;
 class gp_Pnt;
index f38e8df488d64436de0381ab927b7545362d5662..ff9a0a04aec025330e739f762ba889fe4d7ee14c 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
index 312d826bc11dd45afbbe44aa45623ed2acde88d4..6083f179f75a2f6fd224d6efe955cd1b2ec7881b 100644 (file)
@@ -2,8 +2,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 #ifndef _BRepExtrema_Poly_HeaderFile
 #define _BRepExtrema_Poly_HeaderFile
 
-#ifndef _Standard_HeaderFile
 #include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
 
-#ifndef _Standard_Boolean_HeaderFile
-#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
 class TopoDS_Shape;
 class gp_Pnt;
 
-
 class BRepExtrema_Poly
 {
  public:
 
-  //! returns Standard_True if OK. <br>
+  //! returns Standard_True if OK.
   Standard_EXPORT static Standard_Boolean Distance(const TopoDS_Shape& S1,const TopoDS_Shape& S2,gp_Pnt& P1,gp_Pnt& P2,Standard_Real& dist);
 };
 
index a6d7a3cea660f2dd138c79ea48cc0cabab1c5683..8e368ffd27789cee14ed4ce8abb611af79b13740 100644 (file)
@@ -2,8 +2,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 #ifndef _BRepExtrema_SeqOfSolution_HeaderFile
 #define _BRepExtrema_SeqOfSolution_HeaderFile
 
-#ifndef _NCollection_Sequence_HeaderFile
 #include <NCollection_Sequence.hxx>
-#endif
-#ifndef _BRepExtrema_SolutionElem_HeaderFile
 #include <BRepExtrema_SolutionElem.hxx>
-#endif
 
 typedef NCollection_Sequence<BRepExtrema_SolutionElem> BRepExtrema_SeqOfSolution;
 
index 3c9e5d91ed7f247dd956e4aa3cd412f9710d6458..61dba48bbd22178a3799ad126a3b9e3c2cecd2a1 100644 (file)
@@ -2,8 +2,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 #ifndef _BRepExtrema_SolutionElem_HeaderFile
 #define _BRepExtrema_SolutionElem_HeaderFile
 
-#ifndef _Standard_HeaderFile
-#include <Standard.hxx>
-#endif
-#ifndef _Standard_DefineAlloc_HeaderFile
-#include <Standard_DefineAlloc.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _Standard_Real_HeaderFile
-#include <Standard_Real.hxx>
-#endif
-#ifndef _gp_Pnt_HeaderFile
 #include <gp_Pnt.hxx>
-#endif
-#ifndef _BRepExtrema_SupportType_HeaderFile
 #include <BRepExtrema_SupportType.hxx>
-#endif
-#ifndef _TopoDS_Vertex_HeaderFile
 #include <TopoDS_Vertex.hxx>
-#endif
-#ifndef _TopoDS_Edge_HeaderFile
 #include <TopoDS_Edge.hxx>
-#endif
-#ifndef _TopoDS_Face_HeaderFile
 #include <TopoDS_Face.hxx>
-#endif
-class gp_Pnt;
-class TopoDS_Vertex;
-class TopoDS_Edge;
-class TopoDS_Face;
 
-
-//! This class is used to store information relative to the <br>
-//! minimum distance between two shapes. <br>
+//! This class is used to store information relative to the minimum distance between two shapes.
 class BRepExtrema_SolutionElem
 {
  public:
 
   DEFINE_STANDARD_ALLOC
 
-  Standard_EXPORT BRepExtrema_SolutionElem()
-  : myDist(0.), myPoint(0.,0.,0.), mySupType(BRepExtrema_IsVertex), myPar1(0.), myPar2(0.)
-  {
-  }
-  //! initialisation of the fields <br>
-  //! This constructor is used when the solution of a distance is a Vertex. <br>
-  //! The different initialized fields are: <br>
-  //!            _ the distance d <br>
-  //!            _ the solution point <br>
-  //!            _ the type of solution <br>
-  //!            _ and the Vertex. <br>
-  Standard_EXPORT BRepExtrema_SolutionElem(const Standard_Real d,const gp_Pnt& Pt,const BRepExtrema_SupportType SolType,const TopoDS_Vertex& vertex)
-  : myDist(d), myPoint(Pt), mySupType(SolType), myVertex(vertex), myPar1(0.), myPar2(0.)
-  {
-  }
-  //! initialisation of  the fiels. <br>
-  //! This constructor is used when the  solution of distance is on an Edge. <br>
-  //! The different initialized fields are: <br>
-  //!            _ the distance d, <br>
-  //!            _ the solution point, <br>
-  //!            _ the type of solution, <br>
-  //!            _ the Edge, <br>
-  //!            _ and the parameter t to locate the solution. <br>
-  Standard_EXPORT BRepExtrema_SolutionElem(const Standard_Real d,const gp_Pnt& Pt,const BRepExtrema_SupportType SolType,const TopoDS_Edge& edge,const Standard_Real t)
-  : myDist(d), myPoint(Pt), mySupType(SolType), myEdge(edge), myPar1(t), myPar2(0.)
+  //! Empty constructor
+  BRepExtrema_SolutionElem()
+  : myDist    (0.0),
+    myPoint   (0.0, 0.0, 0.0),
+    mySupType (BRepExtrema_IsVertex),
+    myPar1    (0.0),
+    myPar2    (0.0)
   {
   }
-  //! initialisation of the fields <br>
-  //! This constructor is used when the  solution of distance is in <br>
-  //! a Face. The different initialized fields are: <br>
-  //!            _ the distance d, <br>
-  //!            _ the solution point, <br>
-  //!            _ the type of solution, <br>
-  //!            _ the Face, <br>
-  //!            _ and the parameter u et v to locate the solution. <br>
-  Standard_EXPORT BRepExtrema_SolutionElem(const Standard_Real d,const gp_Pnt& Pt,const BRepExtrema_SupportType SolType,const TopoDS_Face& face,const Standard_Real u,const Standard_Real v)
-  : myDist(d), myPoint(Pt), mySupType(SolType), myFace(face), myPar1(u), myPar2(v)
-  {
-  }
-  //! returns the value of the minimum distance. <br>
-  Standard_EXPORT Standard_Real Dist() const
+
+  //! This constructor is used when the solution of a distance is a Vertex.
+  //! The different initialized fields are:
+  //! @param theDist    the distance
+  //! @param thePoint   the solution point
+  //! @param theSolType the type of solution
+  //! @param theVertex  and the Vertex
+  BRepExtrema_SolutionElem (const Standard_Real           theDist,
+                            const gp_Pnt&                 thePoint,
+                            const BRepExtrema_SupportType theSolType,
+                            const TopoDS_Vertex&          theVertex)
+  : myDist    (theDist),
+    myPoint   (thePoint),
+    mySupType (theSolType),
+    myVertex  (theVertex),
+    myPar1    (0.0),
+    myPar2    (0.0) {}
+
+  //! This constructor is used when the  solution of distance is on an Edge.
+  //! The different initialized fields are:
+  //! @param theDist    the distance
+  //! @param thePoint   the solution point
+  //! @param theSolType the type of solution
+  //! @param theEdge    the Edge
+  //! @param theParam   the parameter to locate the solution
+  BRepExtrema_SolutionElem (const Standard_Real           theDist,
+                            const gp_Pnt&                 thePoint,
+                            const BRepExtrema_SupportType theSolType,
+                            const TopoDS_Edge&            theEdge,
+                            const Standard_Real           theParam)
+  : myDist    (theDist),
+    myPoint   (thePoint),
+    mySupType (theSolType),
+    myEdge    (theEdge),
+    myPar1    (theParam),
+    myPar2    (0.0) {}
+
+  //! This constructor is used when the  solution of distance is in a Face.
+  //! The different initialized fields are:
+  //! @param theDist    the distance
+  //! @param thePoint   the solution point
+  //! @param theSolType the type of solution
+  //! @param theFace    the Face
+  //! @param theU       U parameter to locate the solution
+  //! @param theV       V parameter to locate the solution
+  BRepExtrema_SolutionElem (const Standard_Real           theDist,
+                            const gp_Pnt&                 thePoint,
+                            const BRepExtrema_SupportType theSolType,
+                            const TopoDS_Face&            theFace,
+                            const Standard_Real           theU,
+                            const Standard_Real           theV)
+  : myDist    (theDist),
+    myPoint   (thePoint),
+    mySupType (theSolType),
+    myFace    (theFace),
+    myPar1    (theU),
+    myPar2    (theV) {}
+
+  //! Returns the value of the minimum distance.
+  Standard_Real Dist() const
   {
     return myDist;
   }
-  //! returns the solution point. <br>
-  Standard_EXPORT const gp_Pnt & Point() const
+
+  //! Returns the solution point.
+  const gp_Pnt& Point() const
   {
     return myPoint;
   }
-  //! returns the Support type : <br>
-  //!      IsVertex => The solution is a vertex. <br>
-  //!      IsOnEdge => The solution belongs to an Edge. <br>
-  //!      IsInFace => The solution is inside a Face. <br>
-  Standard_EXPORT BRepExtrema_SupportType SupportKind() const
+
+  //! Returns the Support type:
+  //!   IsVertex => The solution is a vertex.
+  //!   IsOnEdge => The solution belongs to an Edge.
+  //!   IsInFace => The solution is inside a Face.
+  BRepExtrema_SupportType SupportKind() const
   {
     return mySupType;
   }
-  //! returns the vertex if the solution is a Vertex. <br>
-  Standard_EXPORT const TopoDS_Vertex & Vertex() const
+
+  //! Returns the vertex if the solution is a Vertex.
+  const TopoDS_Vertex& Vertex() const
   {
     return myVertex;
   }
-  //! returns the vertex if the solution is an Edge. <br>
-  Standard_EXPORT const TopoDS_Edge & Edge() const
+
+  //! Returns the vertex if the solution is an Edge.
+  const TopoDS_Edge& Edge() const
   {
     return myEdge;
   }
-  //! returns the vertex if the solution is an Face. <br>
-  Standard_EXPORT const TopoDS_Face & Face() const
+
+  //! Returns the vertex if the solution is an Face.
+  const TopoDS_Face& Face() const
   {
     return myFace;
   }
-  //! returns the parameter t if the solution is on Edge. <br>
-  Standard_EXPORT void EdgeParameter(Standard_Real& par1) const
+
+  //! Returns the parameter value if the solution is on Edge.
+  void EdgeParameter (Standard_Real& theParam) const
   {
-    par1 = myPar1;
+    theParam = myPar1;
   }
-  //! returns the parameters u et v if the solution is in a Face. <br>
-  Standard_EXPORT void FaceParameter(Standard_Real& par1,Standard_Real& par2) const
+
+  //! Returns the parameters U and V if the solution is in a Face.
+  void FaceParameter (Standard_Real& theU,
+                      Standard_Real& theV) const
   {
-    par1 = myPar1;
-    par2 = myPar2;
+    theU = myPar1;
+    theV = myPar2;
   }
 
  private:
@@ -155,6 +162,7 @@ class BRepExtrema_SolutionElem
   TopoDS_Face myFace;
   Standard_Real myPar1;
   Standard_Real myPar2;
+
 };
 
 #endif
index 346dd93b8a87133dbe1497be1ce66971301ac487..47d475bf4f91f21f71de1acd140f0fcb5e803279 100644 (file)
@@ -2,8 +2,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -26,8 +26,4 @@ enum BRepExtrema_SupportType
   BRepExtrema_IsInFace
 };
 
-#ifndef _Standard_PrimitiveTypes_HeaderFile
-#include <Standard_PrimitiveTypes.hxx>
-#endif
-
 #endif
index 6ff012df8c7fc60df2ec942bce247ecf1e6eed2f..13dd25d6f1a77ba09a16597d8fcbc06ae164396c 100644 (file)
@@ -68,7 +68,7 @@
 //=======================================================================
 
 void BRepFeat::SampleEdges(const TopoDS_Shape& theShape,
-                          TColgp_SequenceOfPnt& theSeq)
+                           TColgp_SequenceOfPnt& theSeq)
 {
   LocOpe::SampleEdges(theShape,theSeq);
 }
@@ -81,7 +81,7 @@ void BRepFeat::SampleEdges(const TopoDS_Shape& theShape,
 //=======================================================================
 
 void BRepFeat::Barycenter(const TopoDS_Shape& S, 
-                         gp_Pnt& B)
+                          gp_Pnt& B)
 {
   TopTools_MapOfShape theMap;
   TopExp_Explorer exp(S,TopAbs_EDGE);
@@ -100,9 +100,9 @@ void BRepFeat::Barycenter(const TopoDS_Shape& S,
       C = BRep_Tool::Curve(edg,Loc,f,l);
       C = Handle(Geom_Curve)::DownCast(C->Transformed(Loc.Transformation()));
       for (i=1;i<NECHANTBARYC; i++) {
-       prm = ((NECHANTBARYC-i)*f + i*l)/NECHANTBARYC;
-       Bar += C->Value(prm).XYZ();
-       nbp++;
+        prm = ((NECHANTBARYC-i)*f + i*l)/NECHANTBARYC;
+        Bar += C->Value(prm).XYZ();
+        nbp++;
       }
     }
   }
@@ -125,7 +125,7 @@ void BRepFeat::Barycenter(const TopoDS_Shape& S,
 //=======================================================================
 
 Standard_Real BRepFeat::ParametricBarycenter(const TopoDS_Shape& S, 
-                                            const Handle(Geom_Curve)& CC)
+                                             const Handle(Geom_Curve)& CC)
 {
   TopTools_MapOfShape theMap;
   TopExp_Explorer exp(S,TopAbs_EDGE);
@@ -147,24 +147,24 @@ Standard_Real BRepFeat::ParametricBarycenter(const TopoDS_Shape& S,
       C = BRep_Tool::Curve(edg,Loc,f,l);
       C = Handle(Geom_Curve)::DownCast(C->Transformed(Loc.Transformation()));
       for (i=1;i<NECHANTBARYC; i++) {
-       prm = ((NECHANTBARYC-i)*f + i*l)/NECHANTBARYC;
-       gp_Pnt pone = C->Value(prm);
-       // On projette sur CC
-       extpc.Perform(pone);
-       if (extpc.IsDone() && extpc.NbExt() >= 1) {
-         Standard_Real Dist2Min = extpc.SquareDistance(1);
-         Standard_Integer kmin = 1;
-         for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
-           Standard_Real Dist2 = extpc.SquareDistance(k);
-           if (Dist2 < Dist2Min) {
-             Dist2Min = Dist2;
-             kmin = k;
-           }
-         }
-         nbp++;
-         Standard_Real prmp = extpc.Point(kmin).Parameter();
-         parbar += prmp;
-       }         
+        prm = ((NECHANTBARYC-i)*f + i*l)/NECHANTBARYC;
+        gp_Pnt pone = C->Value(prm);
+        // On projette sur CC
+        extpc.Perform(pone);
+        if (extpc.IsDone() && extpc.NbExt() >= 1) {
+          Standard_Real Dist2Min = extpc.SquareDistance(1);
+          Standard_Integer kmin = 1;
+          for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
+            Standard_Real Dist2 = extpc.SquareDistance(k);
+            if (Dist2 < Dist2Min) {
+              Dist2Min = Dist2;
+              kmin = k;
+            }
+          }
+          nbp++;
+          Standard_Real prmp = extpc.Point(kmin).Parameter();
+          parbar += prmp;
+        }          
       }
     }
   }
@@ -175,17 +175,17 @@ Standard_Real BRepFeat::ParametricBarycenter(const TopoDS_Shape& S,
       // On projette sur CC
       extpc.Perform(pone);
       if (extpc.IsDone() && extpc.NbExt() >= 1) {
-           Standard_Real Dist2Min = extpc.SquareDistance(1);
-           Standard_Integer kmin = 1;
-           for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
-             Standard_Real Dist2 = extpc.SquareDistance(k);
-             if (Dist2 < Dist2Min) {
-               Dist2Min = Dist2;
-               kmin = k;
-             }
-           }
-           nbp++;
-      }          
+            Standard_Real Dist2Min = extpc.SquareDistance(1);
+            Standard_Integer kmin = 1;
+            for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
+              Standard_Real Dist2 = extpc.SquareDistance(k);
+              if (Dist2 < Dist2Min) {
+                Dist2Min = Dist2;
+                kmin = k;
+              }
+            }
+            nbp++;
+      }          
     }
   }
 
@@ -200,13 +200,13 @@ Standard_Real BRepFeat::ParametricBarycenter(const TopoDS_Shape& S,
 //=======================================================================
 
 void BRepFeat::ParametricMinMax(const TopoDS_Shape& S, 
-                               const Handle(Geom_Curve)& CC,
-                               Standard_Real& prmin,
-                               Standard_Real& prmax,
-                               Standard_Real& prbmin,
-                               Standard_Real& prbmax,
-                               Standard_Boolean& flag,
-                               const Standard_Boolean Ori)
+                                const Handle(Geom_Curve)& CC,
+                                Standard_Real& prmin,
+                                Standard_Real& prmax,
+                                Standard_Real& prbmin,
+                                Standard_Real& prbmax,
+                                Standard_Boolean& flag,
+                                const Standard_Boolean Ori)
 {
   LocOpe_CSIntersector ASI(S);
   TColGeom_SequenceOfCurve scur;
@@ -215,19 +215,19 @@ void BRepFeat::ParametricMinMax(const TopoDS_Shape& S,
   if(ASI.IsDone() && ASI.NbPoints(1) >=1) {
     if (!Ori) {
       prmin = Min(ASI.Point(1,1).Parameter(), 
-                 ASI.Point(1, ASI.NbPoints(1)).Parameter());
+                  ASI.Point(1, ASI.NbPoints(1)).Parameter());
       prmax = Max(ASI.Point(1,1).Parameter(), 
-                 ASI.Point(1, ASI.NbPoints(1)).Parameter());
+                  ASI.Point(1, ASI.NbPoints(1)).Parameter());
     }
     else {
       TopAbs_Orientation Ori = ASI.Point(1,1).Orientation();
       if (Ori ==  TopAbs_FORWARD) {
-       prmin = ASI.Point(1,1).Parameter();
-       prmax = ASI.Point(1, ASI.NbPoints(1)).Parameter();
+        prmin = ASI.Point(1,1).Parameter();
+        prmax = ASI.Point(1, ASI.NbPoints(1)).Parameter();
       }
       else {
-       prmax = ASI.Point(1,1).Parameter();
-       prmin = ASI.Point(1, ASI.NbPoints(1)).Parameter();
+        prmax = ASI.Point(1,1).Parameter();
+        prmin = ASI.Point(1, ASI.NbPoints(1)).Parameter();
       }
     }
     flag = Standard_True;
@@ -259,28 +259,28 @@ void BRepFeat::ParametricMinMax(const TopoDS_Shape& S,
       C = BRep_Tool::Curve(edg,Loc,f,l);
       C = Handle(Geom_Curve)::DownCast(C->Transformed(Loc.Transformation()));
       for (i=1;i<NECHANTBARYC; i++) {
-       prm = ((NECHANTBARYC-i)*f + i*l)/NECHANTBARYC;
-       gp_Pnt pone = C->Value(prm);
-       // On projette sur CC
-       extpc.Perform(pone);
-       if (extpc.IsDone() && extpc.NbExt() >= 1) {
-         Standard_Real Dist2Min = extpc.SquareDistance(1);
-         Standard_Integer kmin = 1;
-         for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
-           Standard_Real Dist2 = extpc.SquareDistance(k);
-           if (Dist2 < Dist2Min) {
-             Dist2Min = Dist2;
-             kmin = k;
-           }
-         }
-         Standard_Real prmp = extpc.Point(kmin).Parameter();
-         if (prmp <= prbmin) {
-           prbmin = prmp;
-         }
-         if (prmp >= prbmax) {
-           prbmax = prmp;
-         }
-       }         
+        prm = ((NECHANTBARYC-i)*f + i*l)/NECHANTBARYC;
+        gp_Pnt pone = C->Value(prm);
+        // On projette sur CC
+        extpc.Perform(pone);
+        if (extpc.IsDone() && extpc.NbExt() >= 1) {
+          Standard_Real Dist2Min = extpc.SquareDistance(1);
+          Standard_Integer kmin = 1;
+          for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
+            Standard_Real Dist2 = extpc.SquareDistance(k);
+            if (Dist2 < Dist2Min) {
+              Dist2Min = Dist2;
+              kmin = k;
+            }
+          }
+          Standard_Real prmp = extpc.Point(kmin).Parameter();
+          if (prmp <= prbmin) {
+            prbmin = prmp;
+          }
+          if (prmp >= prbmax) {
+            prbmax = prmp;
+          }
+        }          
       }
     }
   }
@@ -291,23 +291,23 @@ void BRepFeat::ParametricMinMax(const TopoDS_Shape& S,
       // On projette sur CC
       extpc.Perform(pone);
       if (extpc.IsDone() && extpc.NbExt() >= 1) {
-       Standard_Real Dist2Min = extpc.SquareDistance(1);
-       Standard_Integer kmin = 1;
-       for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
-         Standard_Real Dist2 = extpc.SquareDistance(k);
-         if (Dist2 < Dist2Min) {
-           Dist2Min = Dist2;
-           kmin = k;
-         }
-       }
-       Standard_Real prmp = extpc.Point(kmin).Parameter();
-       if (prmp <= prbmin) {
-         prbmin = prmp;
-       }
-       if (prmp >= prbmax) {
-         prbmax = prmp;
-       }
-      }          
+        Standard_Real Dist2Min = extpc.SquareDistance(1);
+        Standard_Integer kmin = 1;
+        for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
+          Standard_Real Dist2 = extpc.SquareDistance(k);
+          if (Dist2 < Dist2Min) {
+            Dist2Min = Dist2;
+            kmin = k;
+          }
+        }
+        Standard_Real prmp = extpc.Point(kmin).Parameter();
+        if (prmp <= prbmin) {
+          prbmin = prmp;
+        }
+        if (prmp >= prbmax) {
+          prbmax = prmp;
+        }
+      }          
     }
   }
 }
@@ -321,7 +321,7 @@ void BRepFeat::ParametricMinMax(const TopoDS_Shape& S,
 //=======================================================================
 
 static Standard_Boolean IsIn (BRepTopAdaptor_FClass2d& FC,
-                                Geom2dAdaptor_Curve      AC)
+                                 Geom2dAdaptor_Curve      AC)
 {
  Standard_Real Def = 100*Precision::Confusion();
  GCPnts_QuasiUniformDeflection QU(AC,Def);
@@ -345,12 +345,12 @@ static Standard_Boolean IsIn (BRepTopAdaptor_FClass2d& FC,
   //---------------
 
 static void PutInBoundsU (Standard_Real      umin,
-                        Standard_Real      umax,
-                        Standard_Real      eps,
-                        Standard_Real      period,
-                        Standard_Real      f,
-                        Standard_Real      l,
-                        Handle(Geom2d_Curve)&       C2d)
+                         Standard_Real      umax,
+                         Standard_Real      eps,
+                         Standard_Real      period,
+                         Standard_Real      f,
+                         Standard_Real      l,
+                         Handle(Geom2d_Curve)&       C2d)
 {
   gp_Pnt2d      Pf      = C2d->Value(f);
   gp_Pnt2d      Pl      = C2d->Value(l);
@@ -391,12 +391,12 @@ static void PutInBoundsU (Standard_Real      umin,
   //---------------
 
 static void PutInBoundsV (Standard_Real     vmin,
-                        Standard_Real      vmax,
-                        Standard_Real      eps,
-                        Standard_Real      period,
-                        Standard_Real      f,
-                        Standard_Real      l,
-                        Handle(Geom2d_Curve)&       C2d)
+                         Standard_Real      vmax,
+                         Standard_Real      eps,
+                         Standard_Real      period,
+                         Standard_Real      f,
+                         Standard_Real      l,
+                         Handle(Geom2d_Curve)&       C2d)
 {
   gp_Pnt2d      Pf      = C2d->Value(f);
   gp_Pnt2d      Pl      = C2d->Value(l);
@@ -435,7 +435,7 @@ static void PutInBoundsV (Standard_Real     vmin,
 
 
 Standard_Boolean BRepFeat::IsInside(const TopoDS_Face& F1,
-                                 const TopoDS_Face& F2)
+                                  const TopoDS_Face& F2)
 {
   TopExp_Explorer exp;
   exp.Init(F1, TopAbs_EDGE);
@@ -459,7 +459,7 @@ Standard_Boolean BRepFeat::IsInside(const TopoDS_Face& F1,
   TopoDS_Shape aLocalShape = F2.Oriented(TopAbs_FORWARD);
   BRepTopAdaptor_FClass2d FC (TopoDS::Face(aLocalShape),Precision::Confusion());
 //  BRepTopAdaptor_FClass2d FC (TopoDS::Face(F2.Oriented(TopAbs_FORWARD)),
-//                             Precision::Confusion());
+//                                Precision::Confusion());
   for(; exp.More(); exp.Next()) {
     Standard_Real   f1,l1;
     Handle(Geom_Curve) C0 = BRep_Tool::Curve(TopoDS::Edge(exp.Current()),f1,l1);
@@ -488,7 +488,7 @@ Standard_Boolean BRepFeat::IsInside(const TopoDS_Face& F1,
 
 
 void BRepFeat::FaceUntil(const TopoDS_Shape& Sbase,
-                        TopoDS_Face& FUntil)
+                         TopoDS_Face& FUntil)
 {
   Bnd_Box B;
   BRepBndLib::Add(Sbase,B);
@@ -514,11 +514,11 @@ void BRepFeat::FaceUntil(const TopoDS_Shape& Sbase,
   }
   else if (styp == STANDARD_TYPE(Geom_CylindricalSurface)) {
     str = new Geom_RectangularTrimmedSurface
-      (s, 0., 2.*M_PI, bnd, -bnd, Standard_True, Standard_True);
+      (s, bnd, -bnd, Standard_False, Standard_True);
   }
   else if (styp == STANDARD_TYPE(Geom_ConicalSurface)) {
     str = new Geom_RectangularTrimmedSurface
-      (s, 0., 2.*M_PI, bnd, -bnd, Standard_True, Standard_True);
+      (s, bnd, -bnd, Standard_False, Standard_True);
   }
   else {
     FUntil.Nullify();
@@ -536,8 +536,8 @@ void BRepFeat::FaceUntil(const TopoDS_Shape& Sbase,
 //=======================================================================
 
 TopoDS_Solid BRepFeat::Tool(const TopoDS_Shape& SRef,
-                           const TopoDS_Face& Fac,
-                           const TopAbs_Orientation Orf)
+                            const TopoDS_Face& Fac,
+                            const TopAbs_Orientation Orf)
 {
   TopTools_ListOfShape lfaces;
 //  for (TopExp_Explorer exp(SRef,TopAbs_FACE); exp.More(); exp.Next()) {
@@ -603,9 +603,9 @@ TopoDS_Solid BRepFeat::Tool(const TopoDS_Shape& SRef,
 //function : Print
 //purpose  : Print the error Description of a StatusError on a stream.
 //=======================================================================
-       
+            
 Standard_OStream& BRepFeat::Print(const BRepFeat_StatusError se, 
-                                 Standard_OStream& s)
+                                  Standard_OStream& s)
 {
   switch(se) {
   case BRepFeat_OK :
index d2002c7c30dce6d983d449b43c1494e03a316d09..aa8046a6db4dc2fbc5f4302ec2bd647f89e53422 100644 (file)
@@ -40,7 +40,7 @@
 #include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
 #include <ElCLib.hxx>
-
+#include <GeomAdaptor_Curve.hxx>
 
 #include <GeomAdaptor_Surface.hxx>
 #include <GeomAbs_SurfaceType.hxx>
index 4e1276d1e39e0303d806b7256e7db277af1107e8..a0416584f71b9012370c49f4584e37542586e3f4 100644 (file)
@@ -59,6 +59,7 @@
 #include <TopExp.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Vertex.hxx>
+#include <TopExp_Explorer.hxx>
 
 #ifdef DRAW
 #include <DrawTrSurf.hxx>
index de29c2afc836f103683f2ba23020e7d328e51967..34f3e935cef9ebffeff0085f54ed79ac110f3343 100644 (file)
@@ -5,8 +5,8 @@
 --
 -- This file is part of Open CASCADE Technology software library.
 --
--- This library is free software; you can redistribute it and / or modify it
--- under the terms of the GNU Lesser General Public version 2.1 as published
+-- This library is free software; you can redistribute it and/or modify it under
+-- the terms of the GNU Lesser General Public License version 2.1 as published
 -- by the Free Software Foundation, with special exception defined in the file
 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 -- distribution for complete text of the license and disclaimer of any warranty.
@@ -37,7 +37,9 @@ uses
      TopAbs, 
      TopExp,
      StdFail,
-     gp
+     gp,
+     Bnd,
+     TopTools
 
 is
 
index 72a1eab7bca93183ceea42f24e211194e3900c14..ba736756f75afbd3da698d008d13c52c27d6263f 100644 (file)
@@ -5,8 +5,8 @@
 --
 -- This file is part of Open CASCADE Technology software library.
 --
--- This library is free software; you can redistribute it and / or modify it
--- under the terms of the GNU Lesser General Public version 2.1 as published
+-- This library is free software; you can redistribute it and/or modify it under
+-- the terms of the GNU Lesser General Public License version 2.1 as published
 -- by the Free Software Foundation, with special exception defined in the file
 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 -- distribution for complete text of the license and disclaimer of any warranty.
 
 class Inter from BRepIntCurveSurface 
 
-       ---Purpose: Computes the intersection between a face and a curve
+       ---Purpose: Computes the intersection between a face and a
+       --          curve. To intersect one curve with shape method
+       --          Init(Shape, curve, tTol) should be used.  To
+       --          intersect a few curves with specified shape it is
+       --          necessary to load shape one time using method
+       --          Load(shape, tol) and find intersection points for
+       --          each curve using method Init(curve).  For
+       --          iteration by intersection points method More() and
+       --          Next() should be used.  
        --          
+       --- Example:
+       ---  Inter.Load(shape, tol); 
+       ---  for( i =1; i <= nbCurves;i++) 
+       ---   { 
+       ---    Inter.Init(curve); 
+       ---    for(  ;Inter.More(); Inter.Next()) 
+       ---    {
+       ---     .......
+       ---    }
+       ---   }
 
 uses  
 --modified by NIZNHY-PKV Sun Dec 15 16:52:33 2002  f 
@@ -34,7 +52,11 @@ uses
      Lin                 from gp,
      Pnt                 from gp,
      TransitionOnCurve   from IntCurveSurface,
-     Face                from TopoDS
+     Face                from TopoDS,
+     Box                 from Bnd,
+     SequenceOfShape     from TopTools,
+     HArray1OfBox        from Bnd,
+     HCurve               from GeomAdaptor
     
      
 raises 
@@ -47,118 +69,110 @@ is
        --- Purpose: Empty constructor;
        
     Init(me : in out;
-        Sh : Shape from TopoDS;
-        Cu : Curve from GeomAdaptor;
-        Tol: Real  from Standard)
+        theShape : Shape from TopoDS;
+            theCurve : Curve from GeomAdaptor;
+            theTol: Real  from Standard);
            
        --- Purpose: Load the Shape, the curve  and initialize the
        --           tolerance used for the classification.
-       is static;
+       
     
     Init(me : in out;
-        Sh : Shape from TopoDS;
-        L  : Lin   from gp;
-        Tol: Real  from Standard)
+        theShape : Shape from TopoDS;
+            theLine  : Lin   from gp;
+            theTol: Real  from Standard);
            
        --- Purpose: Load the Shape, the curve  and initialize the
        --           tolerance used for the classification.
-       is static;
-    
-    More(me) 
+       
 
-       --- Purpose: returns True if there is a current face.
-       returns Boolean from Standard
-       is static;
+    Load(me : in out; theShape : Shape from TopoDS; theTol: Real  from Standard);
+    --- Purpose: Load the Shape,   and initialize the
+         --           tolerance used for the classification.
+
+    Init(me : in out; theCurve : Curve from GeomAdaptor);
+    --- Purpose: Method to find intersections of specified curve with loaded shape.
+         
     
+    More(me) returns Boolean from Standard;
+       --- Purpose: returns True if there is a current face.
+           
                                             
-    Next(me: in out)
-
-       --- Purpose: Sets the explorer to the next face.
-       is static;
+    Next(me: in out);
+       --- Purpose: Sets the next intersection point to check.
+       
        
-    Find(me: in out) 
+    Find(me: in out) is protected;
        ---Purpose: Internal function
-       is static protected;
-
-    Point(me)
        
-       ---Purpose: returns the current Intersection point.
-       
-       returns IntersectionPoint from IntCurveSurface
-       raises NotDone from StdFail
-       is static;       
 
-    Pnt(me) 
+    Point(me) returns IntersectionPoint from IntCurveSurface
+         ---Purpose: returns the current Intersection point.
+       raises NotDone from StdFail;
+     
+
+    Pnt(me) returns Pnt from gp
        ---Purpose: returns the current geometric Point
        ---C++: return const & 
-       returns Pnt from gp
-       raises NotDone from StdFail
-       is static;
+       raises NotDone from StdFail;
+       
        
 
-    U(me) 
+    U(me) returns Real from Standard
        ---Purpose: returns the U parameter of the current point 
        --          on the current face.
-       returns Real from Standard
-       raises NotDone from StdFail
-       is static;
+         raises NotDone from StdFail;
+
 
-    V(me) 
+    V(me) returns Real from Standard
        ---Purpose: returns the V parameter of the current point 
        --          on the current face.
-       returns Real from Standard
-       raises NotDone from StdFail
-       is static;
+       raises NotDone from StdFail;
+       
 
-    W(me) 
+    W(me) returns Real from Standard
        ---Purpose: returns the  parameter of the current point 
        --          on the curve.
-       returns Real from Standard
-       raises NotDone from StdFail
-       is static;
+         raises NotDone from StdFail;
 
-    State(me)
 
-       ---Purpose: returns the current state  (IN or ON)
-       returns State from TopAbs
-       raises NotDone from StdFail
-       is static;
+    State(me) returns State from TopAbs
+         ---Purpose: returns the current state  (IN or ON)
+       raises NotDone from StdFail;
 
-    Transition(me) 
-    
+
+    Transition(me) returns TransitionOnCurve   from IntCurveSurface
        ---Purpose: returns the transition of the line on the surface (IN or OUT or UNKNOWN)
-       returns TransitionOnCurve   from IntCurveSurface
-       raises NotDone from StdFail
-       is static;
+       raises NotDone from StdFail;
        
-    Face(me)
-    
+       
+    Face(me) returns Face from TopoDS;
        ---Purpose: returns the current face.
-        ---C++: return const &
-       returns Face from TopoDS
-       is static;
+      ---C++: return const &
+       
+        FindPoint(me : in out) returns Boolean from Standard is protected;
+    ---Purpose: Method chec found intersection point
 
+    Clear(me : in out) is protected;
+    ---Purpose: Method to clear fields of class
 
 fields
 
-    empty          : Boolean           from Standard;
-    curveisaline   : Boolean           from Standard;
-    tolerance      : Real              from Standard;
-    line           : Lin               from gp;
-    curve          : Curve             from GeomAdaptor;
+    myTolerance      : Real              from Standard;
+    myCurve          : HCurve             from GeomAdaptor;
+       
+    myIntcs          : HInter             from IntCurveSurface;
     
-    explorer       : Explorer          from TopExp;
-    classifier     : FaceClassifier    from BRepClass;
-    --intcs          : ICSInter          from BRepIntCurveSurface;
-    intcs          : HInter             from IntCurveSurface;
+    myCurrentindex   : Integer           from Standard;
+    myCurrentnbpoints: Integer           from Standard;  
+    myFastClass       :  TopolTool  from  BRepTopAdaptor; 
     
-    currentindex   : Integer           from Standard;
-    currentnbpoints: Integer           from Standard;
---modified by NIZNHY-PKV Sun Dec 15 16:51:34 2002  f     
-    FastClass       :  TopolTool  from  BRepTopAdaptor; 
-    SurfForFastClass:  HSurface  from BRepAdaptor;  
-    currentstate    :  State  from  TopAbs; 
-    currentU        :  Real  from  Standard;
-    currentV        :  Real  from  Standard;
---modified by NIZNHY-PKV Sun Dec 15 16:52:15 2002  t    
+    myCurrentstate    :  State  from  TopAbs; 
+    myCurrentU        :  Real  from  Standard;
+    myCurrentV        :  Real  from  Standard;
+    myCurveBox      : Box from Bnd;
+    myIndFace       : Integer from Standard;
+    myFaces         : SequenceOfShape from TopTools;
+    myFaceBoxes     : HArray1OfBox from Bnd;
+
 end Inter from BRepIntCurveSurface;
index 486998a0febf7360accf626f530e4008be45b872..5416e189568e582f50cc649f4ce59c0455432726 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 #include <GeomAdaptor_HCurve.hxx>
 #include <BRepTopAdaptor_TopolTool.hxx>
 #include <BRepAdaptor_HSurface.hxx>
-
-//modified by NIZNHY-PKV Sun Dec 15 16:57:10 2002 f
-/*
-static Standard_Real currentU,currentV;
-TopAbs_State currentstate;
-static Handle(BRepTopAdaptor_TopolTool) FastClass
-       = new  BRepTopAdaptor_TopolTool();
-
-static Handle(BRepAdaptor_HSurface) SurfForFastClass
-       = new  BRepAdaptor_HSurface();
-*/
-//modified by NIZNHY-PKV Sun Dec 15 16:57:14 2002 t
+#include <BRepBndLib.hxx>
+#include <Bnd_Box.hxx>
+#include <BndLib_Add3dCurve.hxx>
+#include <Bnd_HArray1OfBox.hxx>
 
 //===========================================================================
 //function :BRepIntCurveSurface_Inter::BRepIntCurveSurface_Inte
 //purpose  : 
 //===========================================================================
 BRepIntCurveSurface_Inter::BRepIntCurveSurface_Inter()
-     : empty(Standard_True) 
 {
-//modified by NIZNHY-PKV Sun Dec 15 16:58:10 2002 f
-  FastClass = new  BRepTopAdaptor_TopolTool();
-  SurfForFastClass = new  BRepAdaptor_HSurface();
-//modified by NIZNHY-PKV Sun Dec 15 16:58:13 2002 t
-}
-
-void BRepIntCurveSurface_Inter::Init(const TopoDS_Shape& ashape,
-                                    const GeomAdaptor_Curve& acurve,
-                                    const Standard_Real tol) { 
-  empty = Standard_False;
-  curveisaline = Standard_False;
-  curve = acurve;
-  explorer.Init(ashape,TopAbs_FACE);
-  currentnbpoints = 0;
-  tolerance = tol;
-  Find();
+  myFastClass = new  BRepTopAdaptor_TopolTool();
+  Clear();
 }
 
-void BRepIntCurveSurface_Inter::Init(const TopoDS_Shape& ashape,
-                                    const gp_Lin&       aline,
-                                    const Standard_Real tol) { 
-  empty = Standard_False;
-  curveisaline = Standard_True;
-  line = aline;
-  Handle(Geom_Line) geomline = new Geom_Line(aline);
-  curve.Load(geomline);
-  explorer.Init(ashape,TopAbs_FACE);
-  currentnbpoints = 0;
-  tolerance = tol;
-  Find();
+//===========================================================================
+//function :Init
+//purpose  : 
+//===========================================================================
+
+void BRepIntCurveSurface_Inter::Init(const TopoDS_Shape& theShape,
+                                    const GeomAdaptor_Curve& theCurve,
+                                    const Standard_Real theTol) 
+{ 
+  Load(theShape, theTol);
+  Init(theCurve);
+}
+
+//===========================================================================
+//function :Init
+//purpose  : 
+//===========================================================================
+
+void BRepIntCurveSurface_Inter::Init(const TopoDS_Shape& theShape,
+                                    const gp_Lin&       theLine,
+                                    const Standard_Real theTol) 
+{ 
+  Handle(Geom_Line) geomline = new Geom_Line(theLine);
+  GeomAdaptor_Curve aCurve(geomline);
+  Load(theShape, theTol);
+  Init(aCurve);
+  
 }
 
-Standard_Boolean BRepIntCurveSurface_Inter::More() const {
-  return(explorer.More());
+//===========================================================================
+//function :Clear
+//purpose  : 
+//===========================================================================
+
+void BRepIntCurveSurface_Inter::Clear()
+{  
+  myCurrentindex = 0;
+  myCurrentnbpoints = 0;
+  myIndFace = 0;
+  myCurrentstate = TopAbs_UNKNOWN;
+  myCurrentU = 0;
+  myCurrentV = 0;
+
 }
 
-void BRepIntCurveSurface_Inter::Next() { 
+//===========================================================================
+//function :Load
+//purpose  : 
+//===========================================================================
+
+void BRepIntCurveSurface_Inter::Load(const TopoDS_Shape& theShape ,const Standard_Real theTol)
+{
+  Clear();
+  myFaces.Clear();
+  myFaceBoxes.Nullify();
+  myTolerance = theTol;
+  TopExp_Explorer explorer(theShape,TopAbs_FACE);
+  for( ; explorer.More(); explorer.Next())
+    myFaces.Append(explorer.Current());
+ }
+//===========================================================================
+//function :Init
+//purpose  : 
+//===========================================================================
+
+void BRepIntCurveSurface_Inter::Init(const GeomAdaptor_Curve& theCurve )
+{
+  Clear();
+  myCurveBox.SetVoid();
+  Standard_Real aFirst =  theCurve.FirstParameter();
+  Standard_Real aLast =   theCurve.LastParameter();
+  myCurve = new GeomAdaptor_HCurve(theCurve );
+  if( !Precision::IsInfinite(aFirst) && !Precision::IsInfinite(aLast) )
+    BndLib_Add3dCurve::Add(myCurve->Curve(),0., myCurveBox);
   Find();
 }
 
-void BRepIntCurveSurface_Inter::Find() { 
+//===========================================================================
+//function :More
+//purpose  : 
+//===========================================================================
+Standard_Boolean BRepIntCurveSurface_Inter::More() const 
+{
+  return (myIndFace <= myFaces.Length()  );
+}
 
-  static Standard_Real UMin = 0.0;
-  static Standard_Real UMax = 0.0;
-  static Standard_Real VMin = 0.0;
-  static Standard_Real VMax = 0.0;
-  static Standard_Real PeriodU = 0.0;
-  static Standard_Real PeriodV = 0.0;
+//===========================================================================
+//function :Next
+//purpose  : 
+//===========================================================================
+void BRepIntCurveSurface_Inter::Next() 
+{ 
+  if(myCurrentnbpoints)
+    myCurrentindex++;
+  Find();
+}
+
+//===========================================================================
+//function :Find
+//purpose  : 
+//===========================================================================
+void BRepIntCurveSurface_Inter::Find() 
+{ 
+  if(myCurrentnbpoints && myCurrentindex <= myCurrentnbpoints && FindPoint())
+    return;
   
-  if(currentnbpoints) { 
-    while(currentindex < currentnbpoints) { 
-      currentindex++;
-      Standard_Real U = intcs.Point(currentindex).U();
-      Standard_Real V = intcs.Point(currentindex).V();
-      //-------------------------------------------------------
-      //-- Try to reframe point U,V in the face UV
-      //-- 
-      if(PeriodU) { 
-       while(U>UMin) 
-         U-=PeriodU;
-      }
-      if(PeriodV) { 
-       while(V>VMin)
-         V-=PeriodV;
-      }
-//    Standard_Real UInit = U;
-      Standard_Real VInit = V;
-      do { //-- Loop on U  
-       V = VInit;
-       do { //-- Loop on V
-         gp_Pnt2d Puv(U,V);
-         //--- 
-         //-- classifier.Perform(TopoDS::Face(explorer.Current()),Puv,tolerance);
-         currentstate = FastClass->Classify(Puv,tolerance); //-- MODIF
-         //-- TopAbs_State currentstate = classifier.State();
-
-         if(currentstate == TopAbs_ON || currentstate == TopAbs_IN) { 
-           currentU = U;
-           currentV = V;       
-           return;     
-         }
-         V+=PeriodV;       
-       }
-       while(PeriodV && V< VMax);
-       U+=PeriodU;
-      }
-      while(PeriodU && U<UMax);
+  myCurrentnbpoints = 0;
+  myCurrentindex = 0;
+
+  Standard_Integer i = myIndFace +1;
+  for( ; i <= myFaces.Length(); i++)
+  {
+    TopoDS_Shape aCurface= myFaces(i);       
+    if( myFaceBoxes.IsNull())
+      myFaceBoxes = new Bnd_HArray1OfBox(1, myFaces.Length());
+    Bnd_Box& aFaceBox  = myFaceBoxes->ChangeValue(i);
+    if( aFaceBox.IsVoid())
+    {
+      BRepBndLib::Add(aCurface, aFaceBox);
+      aFaceBox.SetGap(myTolerance);//Precision::Confusion());
     }
-    explorer.Next();
+    Standard_Boolean isOut = ( myCurve->GetType() == GeomAbs_Line ? aFaceBox.IsOut(myCurve->Line()) :
+      ( !myCurveBox.IsVoid() ? aFaceBox.IsOut(myCurveBox ) : Standard_False ) );
+    if(isOut )
+      continue;
+    Handle(BRepAdaptor_HSurface) aSurfForFastClass = new BRepAdaptor_HSurface(TopoDS::Face(aCurface));
+    myIntcs.Perform(myCurve,aSurfForFastClass);
+    myCurrentnbpoints = myIntcs.NbPoints();
+    if( !myCurrentnbpoints)
+      continue;
+
+    myFastClass->Initialize(aSurfForFastClass);
+    myIndFace = i;
+    if(FindPoint())
+      return; 
+    myCurrentnbpoints = 0;
   }
+
+  if(!myCurrentnbpoints && i > myFaces.Length())
+  {
+    myIndFace = i;
+    return;
+  }
+}
+
+//===========================================================================
+//function :FindPoint
+//purpose  : 
+//===========================================================================
+Standard_Boolean BRepIntCurveSurface_Inter::FindPoint()
+{
+  Standard_Integer j =  (!myCurrentindex ?  1 : myCurrentindex);
   
-  if(explorer.More()) { 
-    //---------------------------------------------
-    BRepAdaptor_Surface brepadaptsurf;
-    
-    TopoDS_Face face=TopoDS::Face(explorer.Current());
-    face.Orientation(TopAbs_FORWARD);
-    
-    brepadaptsurf.Initialize(face,Standard_True);
-    //----------------------------------------------
-    //-- Update variables PeriodU,PeriodV
-    //--
-
-    SurfForFastClass->ChangeSurface().Initialize(face); //-- MODIF
-//    SurfForFastClass->ChangeSurface().Initialize(TopoDS::Face(face)); //-- MODIF
-    FastClass->Initialize(SurfForFastClass); //-- MODIF
-    if( brepadaptsurf.Surface().IsUPeriodic()) { 
-      PeriodU = brepadaptsurf.Surface().UPeriod();
-      UMin = brepadaptsurf.Surface().FirstUParameter();
-      UMax = brepadaptsurf.Surface().LastUParameter();
-    }
-    else { 
-      PeriodU = 0.0;
-    }
-    if( brepadaptsurf.Surface().IsVPeriodic()) { 
-      PeriodV = brepadaptsurf.Surface().VPeriod();
-      VMin = brepadaptsurf.Surface().FirstVParameter();
-      VMax = brepadaptsurf.Surface().LastVParameter();
-    }
-    else { 
-      PeriodV = 0.0;
-    }
+  for( ; j <= myCurrentnbpoints; j++ )
+  {
+    Standard_Real anU = myIntcs.Point(j).U();
+    Standard_Real aV = myIntcs.Point(j).V();
+  
+    gp_Pnt2d Puv( anU,aV );
 
-    //----------------------------------------------
-    Handle(GeomAdaptor_HCurve)   HC = new GeomAdaptor_HCurve(curve);
-    Handle(BRepAdaptor_HSurface) HS = new BRepAdaptor_HSurface(brepadaptsurf);
-    //----------------------------------------------
-    //-- intcs.Perform(curve,brepadaptsurf);
-    intcs.Perform(HC,HS);
-
-    currentindex = 0;
-    currentnbpoints = intcs.NbPoints();
-    if(currentnbpoints) { 
-      Find();
-    }
-    else { 
-      explorer.Next();
-      Find(); 
+    myCurrentstate = myFastClass->Classify(Puv,myTolerance); 
+    if(myCurrentstate == TopAbs_ON || myCurrentstate == TopAbs_IN) 
+    { 
+      myCurrentindex = j;
+      myCurrentU = anU;
+      myCurrentV = aV; 
+      return Standard_True; 
     }
   }
-  else { 
-    currentnbpoints=0; 
-  }
+  return Standard_False;
 }
 
+//===========================================================================
+//function :Point
+//purpose  : 
+//===========================================================================
 
-IntCurveSurface_IntersectionPoint BRepIntCurveSurface_Inter::Point() const {
-  if(currentindex==0) 
+IntCurveSurface_IntersectionPoint BRepIntCurveSurface_Inter::Point() const 
+{
+  if(myCurrentindex==0) 
     StdFail_NotDone::Raise();
-  const IntCurveSurface_IntersectionPoint& ICPS = intcs.Point(currentindex);
+  const IntCurveSurface_IntersectionPoint& ICPS = myIntcs.Point(myCurrentindex);
   return(IntCurveSurface_IntersectionPoint(ICPS.Pnt(),
-                                          currentU,     // ICPS.U(),
-                                          currentV,     // ICPS.V(),
+                                          myCurrentU,     // ICPS.U(),
+                                          myCurrentV,     // ICPS.V(),
                                           ICPS.W(),
                                           ICPS.Transition()));
-  //-- return(intcs.Point(currentindex));
+  //-- return(myIntcs.Point(myCurrentindex));
 }
 
-Standard_Real BRepIntCurveSurface_Inter::U() const {
-  if(currentindex==0) 
+//===========================================================================
+//function :U
+//purpose  : 
+//===========================================================================
+Standard_Real BRepIntCurveSurface_Inter::U() const 
+{
+  if(myCurrentindex==0) 
     StdFail_NotDone::Raise();
-  //-- return(intcs.Point(currentindex).U());
-  return(currentU);
+  //-- return(myIntcs.Point(myCurrentindex).U());
+  return(myCurrentU);
 }
 
-Standard_Real BRepIntCurveSurface_Inter::V() const {
-  if(currentindex==0) 
+//===========================================================================
+//function :V
+//purpose  : 
+//===========================================================================
+Standard_Real BRepIntCurveSurface_Inter::V() const 
+{
+  if(myCurrentindex==0) 
     StdFail_NotDone::Raise();
-  //-- return(intcs.Point(currentindex).V());
-  return(currentV);
+  //-- return(myIntcs.Point(myCurrentindex).V());
+  return(myCurrentV);
 }
 
-Standard_Real BRepIntCurveSurface_Inter::W() const {
-  if(currentindex==0) 
+//===========================================================================
+//function :W
+//purpose  : 
+//===========================================================================
+Standard_Real BRepIntCurveSurface_Inter::W() const 
+{
+  if(myCurrentindex==0) 
     StdFail_NotDone::Raise();
-  return(intcs.Point(currentindex).W());
+  return(myIntcs.Point(myCurrentindex).W());
 }
 
-TopAbs_State BRepIntCurveSurface_Inter::State() const {
-  if(currentindex==0) 
+//===========================================================================
+//function :State
+//purpose  : 
+//===========================================================================
+TopAbs_State BRepIntCurveSurface_Inter::State() const 
+{
+  if(myCurrentindex==0) 
     StdFail_NotDone::Raise();
   //-- return(classifier.State());
-  return(currentstate);
+  return(myCurrentstate);
 }
 
-IntCurveSurface_TransitionOnCurve BRepIntCurveSurface_Inter::Transition() const {
-  if(currentindex==0) 
+//===========================================================================
+//function :Transition
+//purpose  : 
+//===========================================================================
+IntCurveSurface_TransitionOnCurve BRepIntCurveSurface_Inter::Transition() const 
+{
+  if(myCurrentindex==0) 
     StdFail_NotDone::Raise();
-  return(intcs.Point(currentindex).Transition());
+  return(myIntcs.Point(myCurrentindex).Transition());
 }
 
-const TopoDS_Face& BRepIntCurveSurface_Inter::Face() const { 
-  return(TopoDS::Face(explorer.Current()));
+//===========================================================================
+//function :Face
+//purpose  : 
+//===========================================================================
+const TopoDS_Face& BRepIntCurveSurface_Inter::Face() const 
+{ 
+  return(TopoDS::Face(myFaces.Value(myIndFace)));
 }
 
+//===========================================================================
+//function :Pnt
+//purpose  : 
+//===========================================================================
 const gp_Pnt& BRepIntCurveSurface_Inter::Pnt() const { 
-  if(currentindex==0) 
+  if(myCurrentindex==0) 
     StdFail_NotDone::Raise();
-  return(intcs.Point(currentindex).Pnt());
+  return(myIntcs.Point(myCurrentindex).Pnt());
 }
+
index 885168bea1b95fa53b9b495b2aa0ae64dfb99ea6..3583817c6ea50e50347116c4ad7f349d8e418a6f 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -75,6 +75,7 @@
 #include <BRepOffset.hxx>
 #include <BRepOffset_MakeOffset.hxx>
 #include <BRepClass3d_SolidClassifier.hxx>
+#include <GeomAdaptor_Curve.hxx>
 
 static 
   void SampleEdges (const TopoDS_Shape&   theShape, 
@@ -115,7 +116,7 @@ void  BRepTest::OtherCommands(Draw_Interpretor& theCommands)
                  ,__FILE__,subshape,g);
 
   theCommands.Add("BRepIntCS",
-                 "Calcul d'intersection entre face et curve : BRepIntCS curve shape"
+    "Calcul d'intersection entre face et curve : BRepIntCS curve1 [curve2 ...] shape [res] [tol]"
                  ,__FILE__,brepintcs,g);
 
   theCommands.Add("makeboss",  "create a boss on the shape myS", __FILE__, MakeBoss, g);
@@ -273,25 +274,54 @@ Standard_Integer subshape(Draw_Interpretor& di, Standard_Integer n, const char**
 //function : brepintcs
 //purpose  : 
 //=======================================================================
-Standard_Integer brepintcs(Draw_Interpretor& , Standard_Integer n, const char** a)
+Standard_Integer brepintcs(Draw_Interpretor& di, Standard_Integer n, const char** a)
 {
-  if (n <= 2) return 1;
-  TopoDS_Shape S = DBRep::Get(a[n-1]);
-  if (S.IsNull()) return 3;
-
-  static BRepIntCurveSurface_Inter theAlg;
-  static double tol=1e-6;
-  static int nbpi=0;
-  static gp_Pnt curp;
+  if (n <= 2) 
+  {
+    cout<<"Invalid input arguments. Should be: curve1 [curve2 ...] shape [result] [tol]"<<endl;
+    return 1;
+  }
+  Standard_Integer indshape = 2;
+  TopoDS_Shape S;
+  for( ; indshape <= n-1 ; indshape++)
+  {
+    S = DBRep::Get(a[indshape]);
+    if(!S.IsNull())
+      break;
+  }
+  if (S.IsNull()) 
+  {
+    cout<<"Invalid input shape"<<endl;
+    return 1;
+  }
 
-  if (n==3) {
+  BRepIntCurveSurface_Inter theAlg;
+  double tol=1e-6;
+  if( indshape < n-1)
+  {
+    Standard_Real preci = atof(a[n-1]);
+    if(preci >= Precision::Confusion())
+      tol = preci;
+  }
+  int nbpi=0;
+  gp_Pnt curp;
+  TopoDS_Compound aComp;
+  BRep_Builder aB;
+  aB.MakeCompound(aComp);
+  if (indshape == 2) {
     Handle(Geom_Curve) C= DrawTrSurf::GetCurve(a[1]);
     if (C.IsNull()) return 2;
     GeomAdaptor_Curve acur(C);
     theAlg.Init(S, acur, tol);
+
     for (; theAlg.More(); theAlg.Next()) {
       curp=theAlg.Pnt();
+      TopoDS_Vertex aV;
+
+      aB.MakeVertex(aV, curp, 0);
+      aB.Add(aComp, aV);
       nbpi++;
+      di<<"Point "<<nbpi<<" : "<<curp.X()<<" "<<curp.Y()<<" "<<curp.Z()<<"\n";
       char name[64];
       char* temp = name; // pour portage WNT
       Sprintf(temp, "%s_%d", "brics", nbpi); 
@@ -299,24 +329,31 @@ Standard_Integer brepintcs(Draw_Interpretor& , Standard_Integer n, const char**
     }
   }
   else {
-    Handle(Geom_Line) hl;
-    gp_Lin thel;
-    for (Standard_Integer il = 1; il<n ; il++) {
-      hl= Handle(Geom_Line)::DownCast(DrawTrSurf::GetCurve(a[il]));
+    theAlg.Load(S,tol );
+    for (Standard_Integer il = 1; il<indshape ; il++) 
+    {
+      Handle(Geom_Curve) hl= DrawTrSurf::GetCurve(a[il]);
       if (!hl.IsNull()) {
-       thel=hl->Lin();
-         theAlg.Init(S, thel, tol);
-       for (; theAlg.More(); theAlg.Next()) {
-         curp=theAlg.Pnt();
-         nbpi++;
-         char name[64];
-         char* temp = name; // pour portage WNT
-         Sprintf(temp, "%s_%d", "brics", nbpi); 
-         DrawTrSurf::Set(temp, curp);
-       }
+        theAlg.Init(hl);
+        for (; theAlg.More(); theAlg.Next()) {
+          curp=theAlg.Pnt();
+          nbpi++;
+          TopoDS_Vertex aV;
+          aB.MakeVertex(aV, curp, 0);
+          aB.Add(aComp, aV);
+          di<<"Point "<<nbpi<<" : "<<curp.X()<<" "<<curp.Y()<<" "<<curp.Z()<<"\n";
+          char name[64];
+          char* temp = name; // pour portage WNT
+          Sprintf(temp, "%s_%d", "brics", nbpi); 
+          DrawTrSurf::Set(temp, curp);
+        }
       }
     }
   }
+  if(!nbpi)
+    di<<"Points of intersections are not found"<<"\n";
+  if(indshape < n-1)
+    DBRep::Set(a[n-1], aComp);
   //POP pour NT
   return 0;
 }
index cb062eca787b3a6768083d136ef00027f36c4f12..56f315724a41efa7e12b8fdc3365287668b7ea7b 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -45,27 +45,27 @@ Extrema_ExtCS::Extrema_ExtCS()
 }
 
 Extrema_ExtCS::Extrema_ExtCS(const Adaptor3d_Curve&   C,
-                            const Adaptor3d_Surface& S,
-                            const Standard_Real    TolC,
-                            const Standard_Real    TolS)
+  const Adaptor3d_Surface& S,
+  const Standard_Real    TolC,
+  const Standard_Real    TolS)
 
 {
   Initialize(S, S.FirstUParameter(), S.LastUParameter(), 
-            S.FirstVParameter(), S.LastVParameter(), 
-            TolC, TolS);
+    S.FirstVParameter(), S.LastVParameter(), 
+    TolC, TolS);
   Perform(C, C.FirstParameter(), C.LastParameter());
 }
 
 Extrema_ExtCS::Extrema_ExtCS(const Adaptor3d_Curve&   C,
-                            const Adaptor3d_Surface& S,
-                            const Standard_Real    UCinf,
-                            const Standard_Real    UCsup,
-                            const Standard_Real    Uinf,       
-                            const Standard_Real    Usup,
-                            const Standard_Real    Vinf,       
-                            const Standard_Real    Vsup,
-                            const Standard_Real    TolC,
-                            const Standard_Real    TolS)
+  const Adaptor3d_Surface& S,
+  const Standard_Real    UCinf,
+  const Standard_Real    UCsup,
+  const Standard_Real    Uinf, 
+  const Standard_Real    Usup,
+  const Standard_Real    Vinf, 
+  const Standard_Real    Vsup,
+  const Standard_Real    TolC,
+  const Standard_Real    TolS)
 
 {
   Initialize(S, Uinf, Usup, Vinf, Vsup, TolC, TolS);
@@ -74,12 +74,12 @@ Extrema_ExtCS::Extrema_ExtCS(const Adaptor3d_Curve&   C,
 
 
 void Extrema_ExtCS::Initialize(const Adaptor3d_Surface& S,
-                              const Standard_Real    Uinf,     
-                              const Standard_Real    Usup,
-                              const Standard_Real    Vinf,     
-                              const Standard_Real    Vsup,
-                              const Standard_Real    TolC,
-                              const Standard_Real    TolS)
+  const Standard_Real    Uinf, 
+  const Standard_Real    Usup,
+  const Standard_Real    Vinf, 
+  const Standard_Real    Vsup,
+  const Standard_Real    TolC,
+  const Standard_Real    TolS)
 {
   myS = (Adaptor3d_SurfacePtr)&S;
   myIsPar = Standard_False;
@@ -92,10 +92,10 @@ void Extrema_ExtCS::Initialize(const Adaptor3d_Surface& S,
   myStype  = myS->GetType();
 }
 
-                               
+
 void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C,
-                           const Standard_Real  Uinf,
-                           const Standard_Real  Usup)
+  const Standard_Real  Uinf,
+  const Standard_Real  Usup)
 {
   myucinf = Uinf;
   myucsup = Usup;
@@ -112,17 +112,17 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C,
 
   case GeomAbs_Line: 
     {
-      
+
       switch(myStype) {
       case GeomAbs_Sphere:
-       myExtElCS.Perform(C.Line(), myS->Sphere());
-       break;   
+        myExtElCS.Perform(C.Line(), myS->Sphere());
+        break;   
       case GeomAbs_Cylinder:
-       myExtElCS.Perform(C.Line(), myS->Cylinder());
-       break;
+        myExtElCS.Perform(C.Line(), myS->Cylinder());
+        break;
       case GeomAbs_Plane:
-       myExtElCS.Perform(C.Line(), myS->Plane());
-       if (myExtElCS.IsParallel())   break;
+        myExtElCS.Perform(C.Line(), myS->Plane());
+        if (myExtElCS.IsParallel())   break;
 
       case GeomAbs_Torus:
       case GeomAbs_Cone:
@@ -130,104 +130,101 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C,
       case GeomAbs_BSplineSurface:
       case GeomAbs_SurfaceOfRevolution:
       case GeomAbs_SurfaceOfExtrusion:
+      case GeomAbs_OffsetSurface:
       case GeomAbs_OtherSurface:
-       {
-         Standard_Real cfirst = myucinf, clast = myucsup;
-         Standard_Real ufirst = myS->FirstUParameter(), ulast = myS->LastUParameter(), 
-                       vfirst = myS->FirstVParameter(), vlast = myS->LastVParameter();
-
-         if(Precision::IsInfinite(Abs(cfirst)) || Precision::IsInfinite(Abs(clast))) {
-
-           Bnd_Box aSurfBox;
-      BndLib_AddSurface::Add(*myS, ufirst, ulast, vfirst, vlast, Precision::Confusion(), aSurfBox);
-           Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
-           aSurfBox.Get(xmin, ymin, zmin, xmax, ymax, zmax);
-           Standard_Real tmin = Precision::Infinite(), tmax = -tmin;
-           gp_Lin aLin = C.Line();
-           
-
-           if(!( Precision::IsInfinite(Abs(xmin)) || Precision::IsInfinite(Abs(xmax)) || 
-                 Precision::IsInfinite(Abs(ymin)) || Precision::IsInfinite(Abs(ymax)) || 
-                 Precision::IsInfinite(Abs(zmin)) || Precision::IsInfinite(Abs(zmax)))  ) {
-             
-             Extrema_ExtPElC anExt;
-             Extrema_POnCurv aPntOnLin;
-             Standard_Real aParOnLin;
-             Standard_Real lim = Precision::Infinite();
-             gp_Pnt aLimPntArray[8];
-             
-             aLimPntArray[0].SetCoord(xmin, ymin, zmin);
-             aLimPntArray[1].SetCoord(xmax, ymin, zmin);
-             aLimPntArray[2].SetCoord(xmin, ymax, zmin);
-             aLimPntArray[3].SetCoord(xmax, ymax, zmin);
-             aLimPntArray[4].SetCoord(xmin, ymin, zmax);
-             aLimPntArray[5].SetCoord(xmax, ymin, zmax);
-             aLimPntArray[6].SetCoord(xmin, ymax, zmax);
-             aLimPntArray[7].SetCoord(xmax, ymax, zmax);
-
-             for(i = 0; i <= 7; i++) {
-               anExt.Perform(aLimPntArray[i], aLin, Precision::Confusion(), -lim, lim);
-               aPntOnLin = anExt.Point(1);
-               aParOnLin = aPntOnLin.Parameter();
-               tmin = Min(aParOnLin, tmin);
-               tmax = Max(aParOnLin, tmax);
-             }
-             
-           }
-           else {
-             tmin = -1.e+50;
-             tmax =  1.e+50;
-           }
-
-
-           cfirst = Max(cfirst, tmin);
-           clast  = Min(clast,  tmax);
-
-         }
-
-
-           
-         Extrema_GenExtCS Ext(C, *myS, NbT, NbU, NbV, cfirst, clast, ufirst, ulast,
-                              vfirst, vlast, mytolC, mytolS);
-
-         myDone = Ext.IsDone();
-         if (myDone) {
-           Standard_Integer NbExt = Ext.NbExt();
-           Standard_Real T,U,V;
-           Extrema_POnCurv PC;
-           Extrema_POnSurf PS;
-           for (i = 1; i <= NbExt; i++) {
-             PC = Ext.PointOnCurve(i);
-             PS = Ext.PointOnSurface(i);
-             T = PC.Parameter();
-             PS.Parameter(U, V);
+        {
+          Standard_Real cfirst = myucinf, clast = myucsup;
+          Standard_Real ufirst = myS->FirstUParameter(), ulast = myS->LastUParameter(), 
+            vfirst = myS->FirstVParameter(), vlast = myS->LastVParameter();
+
+          if(Precision::IsInfinite(Abs(cfirst)) || Precision::IsInfinite(Abs(clast))) {
+
+            Bnd_Box aSurfBox;
+            BndLib_AddSurface::Add(*myS, ufirst, ulast, vfirst, vlast, Precision::Confusion(), aSurfBox);
+            Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
+            aSurfBox.Get(xmin, ymin, zmin, xmax, ymax, zmax);
+            Standard_Real tmin = Precision::Infinite(), tmax = -tmin;
+            gp_Lin aLin = C.Line();
+
+
+            if(!( Precision::IsInfinite(Abs(xmin)) || Precision::IsInfinite(Abs(xmax)) || 
+              Precision::IsInfinite(Abs(ymin)) || Precision::IsInfinite(Abs(ymax)) || 
+              Precision::IsInfinite(Abs(zmin)) || Precision::IsInfinite(Abs(zmax)))  ) {
+
+                Extrema_ExtPElC anExt;
+                Extrema_POnCurv aPntOnLin;
+                Standard_Real aParOnLin;
+                Standard_Real lim = Precision::Infinite();
+                gp_Pnt aLimPntArray[8];
+
+                aLimPntArray[0].SetCoord(xmin, ymin, zmin);
+                aLimPntArray[1].SetCoord(xmax, ymin, zmin);
+                aLimPntArray[2].SetCoord(xmin, ymax, zmin);
+                aLimPntArray[3].SetCoord(xmax, ymax, zmin);
+                aLimPntArray[4].SetCoord(xmin, ymin, zmax);
+                aLimPntArray[5].SetCoord(xmax, ymin, zmax);
+                aLimPntArray[6].SetCoord(xmin, ymax, zmax);
+                aLimPntArray[7].SetCoord(xmax, ymax, zmax);
+
+                for(i = 0; i <= 7; i++) {
+                  anExt.Perform(aLimPntArray[i], aLin, Precision::Confusion(), -lim, lim);
+                  aPntOnLin = anExt.Point(1);
+                  aParOnLin = aPntOnLin.Parameter();
+                  tmin = Min(aParOnLin, tmin);
+                  tmax = Max(aParOnLin, tmax);
+                }
+
+            }
+            else {
+              tmin = -1.e+50;
+              tmax =  1.e+50;
+            }
+
+
+            cfirst = Max(cfirst, tmin);
+            clast  = Min(clast,  tmax);
+
+          }
+
+
+
+          Extrema_GenExtCS Ext(C, *myS, NbT, NbU, NbV, cfirst, clast, ufirst, ulast,
+            vfirst, vlast, mytolC, mytolS);
+
+          myDone = Ext.IsDone();
+          if (myDone) {
+            Standard_Integer NbExt = Ext.NbExt();
+            Standard_Real T,U,V;
+            Extrema_POnCurv PC;
+            Extrema_POnSurf PS;
+            for (i = 1; i <= NbExt; i++) {
+              PC = Ext.PointOnCurve(i);
+              PS = Ext.PointOnSurface(i);
+              T = PC.Parameter();
+              PS.Parameter(U, V);
               AddSolution(C, T, U, V, PC.Value(), PS.Value(), Ext.SquareDistance(i));
-           }
-         }
-         return;
-         
-       }
-#ifndef DEB
-      default:
-#endif
-       break;
+            }
+          }
+          return;
+
+        }
       }
       break;
     }
-//  Modified by skv - Thu Jul  7 12:29:34 2005 OCC9134 Begin
+    //  Modified by skv - Thu Jul  7 12:29:34 2005 OCC9134 Begin
   case GeomAbs_Circle:
     {
       if(myStype == GeomAbs_Cylinder) {
-       myExtElCS.Perform(C.Circle(), myS->Cylinder());
-       break;
+        myExtElCS.Perform(C.Circle(), myS->Cylinder());
+        break;
       }
     }
   case GeomAbs_Hyperbola: 
     {
       if(myCtype == GeomAbs_Hyperbola && myStype == GeomAbs_Plane) {
-//  Modified by skv - Thu Jul  7 12:29:34 2005 OCC9134 End
-       myExtElCS.Perform(C.Hyperbola(), myS->Plane());
-       break;
+        //  Modified by skv - Thu Jul  7 12:29:34 2005 OCC9134 End
+        myExtElCS.Perform(C.Hyperbola(), myS->Plane());
+        break;
       }
     }
   default:
@@ -235,30 +232,30 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C,
       Extrema_GenExtCS Ext;
       Ext.Initialize(*myS, NbU, NbV, mytolS);
       if(myCtype == GeomAbs_Hyperbola) {
-       Standard_Real tmin = Max(-20., C.FirstParameter());
-       Standard_Real tmax = Min(20., C.LastParameter());
-       Ext.Perform(C, NbT, tmin, tmax, mytolC); // to avoid overflow
+        Standard_Real tmin = Max(-20., C.FirstParameter());
+        Standard_Real tmax = Min(20., C.LastParameter());
+        Ext.Perform(C, NbT, tmin, tmax, mytolC); // to avoid overflow
       }
       else {
-       if(myCtype == GeomAbs_Circle && NbT < 13) {
-         NbT = 13;
-       }
-       Ext.Perform(C, NbT, mytolC);
+        if(myCtype == GeomAbs_Circle && NbT < 13) {
+          NbT = 13;
+        }
+        Ext.Perform(C, NbT, mytolC);
       }
-       
+
       myDone = Ext.IsDone();
       if (myDone) {
-       Standard_Integer NbExt = Ext.NbExt();
-       Standard_Real T,U,V;
-       Extrema_POnCurv PC;
-       Extrema_POnSurf PS;
-       for (i = 1; i <= NbExt; i++) {
-         PC = Ext.PointOnCurve(i);
-         PS = Ext.PointOnSurface(i);
-         T = PC.Parameter();
-         PS.Parameter(U, V);
+        Standard_Integer NbExt = Ext.NbExt();
+        Standard_Real T,U,V;
+        Extrema_POnCurv PC;
+        Extrema_POnSurf PS;
+        for (i = 1; i <= NbExt; i++) {
+          PC = Ext.PointOnCurve(i);
+          PS = Ext.PointOnSurface(i);
+          T = PC.Parameter();
+          PS.Parameter(U, V);
           AddSolution(C, T, U, V, PC.Value(), PS.Value(), Ext.SquareDistance(i));
-       }
+        }
 
         //Add sharp points
         Standard_Integer SolNumber = mySqDist.Length();
@@ -289,7 +286,7 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C,
           {
             ProjPS.Point(jmin).Parameter(U,V);
             AddSolution(C, T, U, V,
-                        aPnt, ProjPS.Point(jmin).Value(), MinSqDist);
+              aPnt, ProjPS.Point(jmin).Value(), MinSqDist);
           }
         }
         //Cut sharp solutions to keep only minimum and maximum
@@ -309,7 +306,7 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C,
           Extrema_POnCurv MaxPC = myPOnC(imax);
           Extrema_POnSurf MinPS = myPOnS(imin);
           Extrema_POnSurf MaxPS = myPOnS(imax);
-          
+
           mySqDist.Remove(SolNumber + 1, mySqDist.Length());
           myPOnC.Remove(SolNumber + 1, myPOnC.Length());
           myPOnS.Remove(SolNumber + 1, myPOnS.Length());
@@ -326,7 +323,7 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C,
     }
     break;
   }
-  
+
   myDone = myExtElCS.IsDone();
   if (myDone) {
     myIsPar = myExtElCS.IsParallel();
@@ -337,16 +334,16 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C,
       Standard_Integer NbExt = myExtElCS.NbExt();
       Standard_Real U, V;
       for (i = 1; i <= NbExt; i++) {
-       Extrema_POnCurv PC;
-       Extrema_POnSurf PS;
-       myExtElCS.Points(i, PC, PS);
-       Standard_Real Ucurve = PC.Parameter();
-       PS.Parameter(U, V);
+        Extrema_POnCurv PC;
+        Extrema_POnSurf PS;
+        myExtElCS.Points(i, PC, PS);
+        Standard_Real Ucurve = PC.Parameter();
+        PS.Parameter(U, V);
         AddSolution(C, Ucurve, U, V, PC.Value(), PS.Value(), myExtElCS.SquareDistance(i));
       }
     }
   }
-  
+
 }
 
 
@@ -379,8 +376,8 @@ Standard_Integer Extrema_ExtCS::NbExt() const
 
 
 void Extrema_ExtCS::Points(const Standard_Integer N,
-                           Extrema_POnCurv&       P1,
-                           Extrema_POnSurf&       P2) const
+  Extrema_POnCurv&       P1,
+  Extrema_POnSurf&       P2) const
 {
   if(!myDone) StdFail_NotDone::Raise();
   P1 = myPOnC.Value(N);
@@ -388,17 +385,17 @@ void Extrema_ExtCS::Points(const Standard_Integer N,
 }
 
 Standard_Boolean Extrema_ExtCS::AddSolution(const Adaptor3d_Curve& theCurve,
-                                            const Standard_Real aT,
-                                            const Standard_Real aU,
-                                            const Standard_Real aV,
-                                            const gp_Pnt& PointOnCurve,
-                                            const gp_Pnt& PointOnSurf,
-                                            const Standard_Real SquareDist)
+  const Standard_Real aT,
+  const Standard_Real aU,
+  const Standard_Real aV,
+  const gp_Pnt& PointOnCurve,
+  const gp_Pnt& PointOnSurf,
+  const Standard_Real SquareDist)
 {
   Standard_Boolean Added = Standard_False;
 
   Standard_Real T = aT, U = aU, V = aV;
-  
+
   if (theCurve.IsPeriodic())
     T = ElCLib::InPeriod(T, myucinf, myucinf + theCurve.Period());
   if (myS->IsUPeriodic())
@@ -409,8 +406,8 @@ Standard_Boolean Extrema_ExtCS::AddSolution(const Adaptor3d_Curve& theCurve,
   Extrema_POnCurv aPC;
   Extrema_POnSurf aPS;
   if ((myucinf-T) <= mytolC && (T-myucsup) <= mytolC &&
-      (myuinf-U) <= mytolS && (U-myusup) <= mytolS &&
-      (myvinf-V) <= mytolS && (V-myvsup) <= mytolS)
+    (myuinf-U) <= mytolS && (U-myusup) <= mytolS &&
+    (myvinf-V) <= mytolS && (V-myvsup) <= mytolS)
   {
     Standard_Boolean IsNewSolution = Standard_True;
     for (Standard_Integer j = 1; j <= mySqDist.Length(); j++)
@@ -421,8 +418,8 @@ Standard_Boolean Extrema_ExtCS::AddSolution(const Adaptor3d_Curve& theCurve,
       Standard_Real Uj, Vj;
       aPS.Parameter(Uj, Vj);
       if (Abs(T - Tj) <= mytolC &&
-          Abs(U - Uj) <= mytolS &&
-          Abs(V - Vj) <= mytolS)
+        Abs(U - Uj) <= mytolS &&
+        Abs(V - Vj) <= mytolS)
       {
         IsNewSolution = Standard_False;
         break;
index e462bfe10022fcfbee82be24a19c627d2e5204ef..eaac06f171d3b2446bb4318bf5c145176025b9a0 100644 (file)
@@ -258,7 +258,7 @@ void Extrema_ExtPExtS::Perform (const gp_Pnt& P)
     Extrema_POnCurv POC=anExt.Point(i);
     U = POC.Parameter();
     //// modified by jgv, 23.12.2008 for OCC17194 ////
-    if (myC->IsPeriodic())
+    if (myC->IsPeriodic() || (myC->GetType() == GeomAbs_Circle) || (myC->GetType() == GeomAbs_Ellipse))
     {
       Standard_Real U2 = U;
       ElCLib::AdjustPeriodic(myuinf, myuinf + 2.*M_PI, Precision::PConfusion(), U, U2);
index 5254bac4f3c2b937e852268a1a4e4442fe1c3787..bff4cad83baba085f22b9d14276939c90e1664d2 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -44,13 +44,13 @@ Extrema_GenExtCS::Extrema_GenExtCS()
 //purpose  : 
 //=======================================================================
 
- Extrema_GenExtCS::Extrema_GenExtCS(const Adaptor3d_Curve& C, 
-                                   const Adaptor3d_Surface& S, 
-                                   const Standard_Integer NbT, 
-                                   const Standard_Integer NbU, 
-                                   const Standard_Integer NbV, 
-                                   const Standard_Real Tol1, 
-                                   const Standard_Real Tol2)
+Extrema_GenExtCS::Extrema_GenExtCS(const Adaptor3d_Curve& C, 
+  const Adaptor3d_Surface& S, 
+  const Standard_Integer NbT, 
+  const Standard_Integer NbU, 
+  const Standard_Integer NbV, 
+  const Standard_Real Tol1, 
+  const Standard_Real Tol2)
 {
   Initialize(S, NbU, NbV, Tol2);
   Perform(C, NbT, Tol1);
@@ -61,19 +61,19 @@ Extrema_GenExtCS::Extrema_GenExtCS()
 //purpose  : 
 //=======================================================================
 
- Extrema_GenExtCS::Extrema_GenExtCS(const Adaptor3d_Curve& C, 
-                                   const Adaptor3d_Surface& S, 
-                                   const Standard_Integer NbT, 
-                                   const Standard_Integer NbU, 
-                                   const Standard_Integer NbV, 
-                                   const Standard_Real tmin, 
-                                   const Standard_Real tsup, 
-                                   const Standard_Real Umin, 
-                                   const Standard_Real Usup,
-                                   const Standard_Real Vmin, 
-                                   const Standard_Real Vsup, 
-                                   const Standard_Real Tol1, 
-                                   const Standard_Real Tol2)
+Extrema_GenExtCS::Extrema_GenExtCS(const Adaptor3d_Curve& C, 
+  const Adaptor3d_Surface& S, 
+  const Standard_Integer NbT, 
+  const Standard_Integer NbU, 
+  const Standard_Integer NbV, 
+  const Standard_Real tmin, 
+  const Standard_Real tsup, 
+  const Standard_Real Umin, 
+  const Standard_Real Usup,
+  const Standard_Real Vmin, 
+  const Standard_Real Vsup, 
+  const Standard_Real Tol1, 
+  const Standard_Real Tol2)
 {
   Initialize(S, NbU, NbV, Umin,Usup,Vmin,Vsup,Tol2);
   Perform(C, NbT, tmin, tsup, Tol1);
@@ -85,9 +85,9 @@ Extrema_GenExtCS::Extrema_GenExtCS()
 //=======================================================================
 
 void Extrema_GenExtCS::Initialize(const Adaptor3d_Surface& S, 
-                                 const Standard_Integer NbU, 
-                                 const Standard_Integer NbV, 
-                                 const Standard_Real Tol2)
+  const Standard_Integer NbU, 
+  const Standard_Integer NbV, 
+  const Standard_Real Tol2)
 {
   myumin = S.FirstUParameter();
   myusup = S.LastUParameter();
@@ -102,13 +102,13 @@ void Extrema_GenExtCS::Initialize(const Adaptor3d_Surface& S,
 //=======================================================================
 
 void Extrema_GenExtCS::Initialize(const Adaptor3d_Surface& S, 
-                                 const Standard_Integer NbU, 
-                                 const Standard_Integer NbV, 
-                                 const Standard_Real Umin, 
-                                 const Standard_Real Usup, 
-                                 const Standard_Real Vmin, 
-                                 const Standard_Real Vsup, 
-                                 const Standard_Real Tol2)
+  const Standard_Integer NbU, 
+  const Standard_Integer NbV, 
+  const Standard_Real Umin, 
+  const Standard_Real Usup, 
+  const Standard_Real Vmin, 
+  const Standard_Real Vsup, 
+  const Standard_Real Tol2)
 {
   myS = (Adaptor3d_SurfacePtr)&S;
   myusample = NbU;
@@ -126,8 +126,8 @@ void Extrema_GenExtCS::Initialize(const Adaptor3d_Surface& S,
 //=======================================================================
 
 void Extrema_GenExtCS::Perform(const Adaptor3d_Curve& C, 
-                              const Standard_Integer NbT,
-                              const Standard_Real Tol1)
+  const Standard_Integer NbT,
+  const Standard_Real Tol1)
 {
   mytmin = C.FirstParameter();
   mytsup = C.LastParameter();
@@ -140,10 +140,10 @@ void Extrema_GenExtCS::Perform(const Adaptor3d_Curve& C,
 //=======================================================================
 
 void Extrema_GenExtCS::Perform(const Adaptor3d_Curve& C, 
-                              const Standard_Integer NbT,
-                              const Standard_Real tmin, 
-                              const Standard_Real tsup, 
-                              const Standard_Real Tol1)
+  const Standard_Integer NbT,
+  const Standard_Real tmin, 
+  const Standard_Real tsup, 
+  const Standard_Real Tol1)
 {
   myDone = Standard_False;
   myF.Initialize(C,*myS);
@@ -189,7 +189,7 @@ void Extrema_GenExtCS::Perform(const Adaptor3d_Curve& C,
     Standard_Real dfUFirst = aCurve->FirstParameter();
     // Create iso line of U=U0
     GeomAdaptor_Curve anAx(new Geom_Line(aCurve->Value(dfUFirst), aDir),
-                           trimvmin, trimvsup);
+      trimvmin, trimvsup);
     Extrema_ExtCC aLocator(C, anAx);
     if (aLocator.IsDone() && aLocator.NbExt()>0)
     {
@@ -198,28 +198,28 @@ void Extrema_GenExtCS::Perform(const Adaptor3d_Curve& C,
       Extrema_POnCurv aP1, aP2;
       for (iExt=1; iExt<=aLocator.NbExt(); iExt++)
       {
-  aLocator.Points (iExt, aP1, aP2);
-  // Parameter on curve
-  UV(1) = aP1.Parameter();
-  // To find parameters on surf, try ExtPS
-  Extrema_ExtPS aPreciser (aP1.Value(), *myS, mytol2, mytol2);
-  if (aPreciser.IsDone())
-  {
-    // Managed to find extremas between point and surface
-    Standard_Integer iPExt;
-    for (iPExt=1; iPExt<=aPreciser.NbExt(); iPExt++)
-    {
-      aPreciser.Point(iPExt).Parameter(UV(2),UV(3));
-      math_FunctionSetRoot S1 (myF,UV,Tol,UVinf,UVsup);
-    }
-  }
-  else
-  {
-    // Failed... try the point on iso line
-    UV(2) = dfUFirst;
-    UV(3) = aP2.Parameter();
-    math_FunctionSetRoot S1 (myF,UV,Tol,UVinf,UVsup);
-  }
+        aLocator.Points (iExt, aP1, aP2);
+        // Parameter on curve
+        UV(1) = aP1.Parameter();
+        // To find parameters on surf, try ExtPS
+        Extrema_ExtPS aPreciser (aP1.Value(), *myS, mytol2, mytol2);
+        if (aPreciser.IsDone())
+        {
+          // Managed to find extremas between point and surface
+          Standard_Integer iPExt;
+          for (iPExt=1; iPExt<=aPreciser.NbExt(); iPExt++)
+          {
+            aPreciser.Point(iPExt).Parameter(UV(2),UV(3));
+            math_FunctionSetRoot S1 (myF,UV,Tol,UVinf,UVsup);
+          }
+        }
+        else
+        {
+          // Failed... try the point on iso line
+          UV(2) = dfUFirst;
+          UV(3) = aP2.Parameter();
+          math_FunctionSetRoot S1 (myF,UV,Tol,UVinf,UVsup);
+        }
       } // for (iExt=1; iExt<=aLocator.NbExt(); iExt++)
     } // if (aLocator.IsDone() && aLocator.NbExt()>0)
   } // if (myS.Type() == GeomAbs_ExtrusionSurface)
@@ -228,10 +228,63 @@ void Extrema_GenExtCS::Perform(const Adaptor3d_Curve& C,
     Standard_Real aCUAdd = (mytsup - mytmin) / mytsample;
     Standard_Real aSUAdd = (myusup - myumin) / myusample;
     Standard_Real aSVAdd = (myvsup - myvmin) / myvsample;
+    Standard_Real tres = C.Resolution(1.);
+    Standard_Real ures = myS->UResolution(1.);
+    Standard_Real vres = myS->VResolution(1.);
+    tres = aCUAdd / tres;
+    ures = aSUAdd / ures;
+    vres = aSVAdd / vres;
+    Standard_Real minres = Min(tres, Min(ures, vres));
+    Standard_Real factor = 5.;
+    Standard_Integer maxnbs = 50;
+    minres *= factor;
+    if(minres > Epsilon(1.))
+    {
+      if(tres > minres)
+      {
+        Standard_Real rsample = mytsample * tres / minres;
+        if(rsample > maxnbs)
+        {
+          mytsample = maxnbs;
+        }
+        else
+        {
+          mytsample = RealToInt(rsample);
+        }
+        aCUAdd = (mytsup - mytmin) / mytsample;
+      }
+      if(ures > minres)
+      {
+        Standard_Real rsample = myusample * ures / minres;
+        if(rsample > maxnbs)
+        {
+          myusample = maxnbs;
+        }
+        else
+        {
+          myusample = RealToInt(rsample);
+        }
+        aSUAdd = (myusup - myumin) / myusample;
+      }
+      if(vres > minres)
+      {
+        Standard_Real rsample = myvsample * vres / minres;
+        if(rsample > maxnbs)
+        {
+          myvsample = maxnbs;
+        }
+        else
+        {
+          myvsample = RealToInt(rsample);
+        }
+        aSVAdd = (myvsup - myvmin) / myvsample;
+      }
+    }
+
     TColgp_HArray1OfPnt aCPs(1, mytsample);
     TColgp_HArray2OfPnt aSPs(1, myusample, 1, myvsample);
     Standard_Integer aRestIterCount = 3;
-      // The value is calculated by the bug CR23830.
+    // The value is calculated by the bug CR23830.
     Standard_Integer aCUDen = 2, aSUDen = 2, aSVDen = 2;
     Standard_Boolean anAreAvSqsInited = Standard_False;
     Standard_Real aCUSq = 0, aSUSq = 0, aSVSq = 0;
@@ -302,7 +355,7 @@ void Extrema_GenExtCS::Perform(const Adaptor3d_Curve& C,
         UV(1) = aMaxCU;
         UV(2) = aMaxSU;
         UV(3) = aMaxSV;
-        math_FunctionSetRoot(myF, UV, Tol, UVinf, UVsup);
+        math_FunctionSetRoot aFunc(myF, UV, Tol, UVinf, UVsup);
         break;
       }
       //
index 6306d365a60471840faea0e1497eb553b4a387af..da5d23c01afb383cd7f63101b22b98fcdf8a7c92 100644 (file)
@@ -226,7 +226,7 @@ is
        NoSuchObject from Standard
      is redefined static;     
           
-
+    NbSamples(me) returns Integer from Standard is redefined;
 
     Bezier(me) returns BezierCurve from Geom2d
     raises 
index 3323b085a9681aa30b8a0001b2ee5b03579b5518..e9e2013a53131214b02091e7bff8487de414da1c 100644 (file)
@@ -860,3 +860,40 @@ Handle(Geom2d_BSplineCurve) Geom2dAdaptor_Curve::BSpline() const
   return *((Handle(Geom2d_BSplineCurve)*)&myCurve);
 }
 
+static Standard_Integer nbPoints(const Handle(Geom2d_Curve)& theCurve) 
+{
+  Standard_Integer nbs = 10;
+  
+  if(theCurve->IsKind(STANDARD_TYPE( Geom2d_Line)) )
+    nbs = 2;
+  else if(theCurve->IsKind(STANDARD_TYPE( Geom2d_BezierCurve))) 
+  {
+    nbs = 3 + (*((Handle(Geom2d_BezierCurve)*)&theCurve))->NbPoles();
+  }
+  else if(theCurve->IsKind(STANDARD_TYPE( Geom2d_BSplineCurve))) { 
+    nbs =  (*((Handle(Geom2d_BSplineCurve)*)&theCurve))->NbKnots();
+    nbs*= (*((Handle(Geom2d_BSplineCurve)*)&theCurve))->Degree();
+    if(nbs < 2.0) nbs=2;
+  }
+  else if (theCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve)))
+  {
+    Handle(Geom2d_Curve) aCurve = (*((Handle(Geom2d_OffsetCurve)*)&theCurve))->BasisCurve();
+    return Max(nbs, nbPoints(aCurve));
+  }
+
+  else if (theCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve)))
+  {
+    Handle(Geom2d_Curve) aCurve = (*((Handle(Geom2d_TrimmedCurve)*)&theCurve))->BasisCurve();
+    return Max(nbs, nbPoints(aCurve));
+  }
+  if(nbs>300)
+    nbs = 300;
+  return nbs;
+  
+}
+
+Standard_Integer Geom2dAdaptor_Curve::NbSamples() const
+{
+  return  nbPoints(myCurve);
+}
index 1ce928fc862711c85bc1a98f1750aeb47467358d..8ef54be62298550f88b809b46235c5897a1bce5b 100644 (file)
@@ -170,6 +170,7 @@ is
    Degree(myclass; C : IntCurveCurve) returns Integer from Standard;
        ---C++: inline
 
+   
 
 end CurveTool;
 
index 93e43fae540bb284e12c376ff1f9b99b4f745367..2217d73ab4ef935d28908fc9c6fd067948cd65b6 100644 (file)
@@ -25,14 +25,10 @@ Standard_Integer Geom2dInt_CurveTool::NbSamples (const IntCurveCurve& C,
                                                 const Standard_Real U0,
                                                 const Standard_Real U1) {
   GeomAbs_CurveType typC = C.GetType();
-  static Standard_Real nbsOther = 10.0;
-  Standard_Real nbs = nbsOther;
+  
+  Standard_Integer nbs = C.NbSamples();
 
-  if(typC == GeomAbs_Line) 
-    nbs = 2;
-  else if(typC == GeomAbs_BezierCurve) 
-    nbs = 3 + C.NbPoles();
-  else if(typC == GeomAbs_BSplineCurve) { 
+  if(typC == GeomAbs_BSplineCurve) { 
     Standard_Real t=C.LastParameter()-C.FirstParameter();
     Standard_Real t1=U1-U0;
     if(t1<0.0) t1=-t1;
@@ -41,38 +37,15 @@ Standard_Integer Geom2dInt_CurveTool::NbSamples (const IntCurveCurve& C,
     nbs*= (t1/t);
     if(nbs < 4.0) nbs=4;
   }
-  //// modified by jgv, 20.02.02 for bug OCC165 ////
-  else if (typC == GeomAbs_OtherCurve)
-    nbs = 20;
-  //////////////////////////////////////////////////
-
+  
   if(nbs>300)
     nbs = 300;
-  return((Standard_Integer)nbs);
+  return nbs;
 }
 //============================================================
 Standard_Integer Geom2dInt_CurveTool::NbSamples (const IntCurveCurve& C) { 
-  GeomAbs_CurveType typC = C.GetType();
-  static Standard_Real nbsOther = 10.0;
-  Standard_Real nbs = nbsOther;
-  
-  if(typC == GeomAbs_Line) 
-    nbs = 2;
-  else if(typC == GeomAbs_BezierCurve) 
-    nbs = 3 + C.NbPoles();
-  else if(typC == GeomAbs_BSplineCurve) { 
-    nbs = C.NbKnots();
-    nbs*= C.Degree();
-    if(nbs < 2.0) nbs=2;
-  }
-  //// modified by jgv, 20.02.02 for bug OCC165 ////
-  else if (typC == GeomAbs_OtherCurve)
-    nbs = 20;
-  //////////////////////////////////////////////////
-
-  if(nbs>300)
-    nbs = 300;
-  return((Standard_Integer)nbs);
+  return C.NbSamples();
 }
 
 
index 3226a11511e24660f8fe134ecd62bf51a4e542ed..b6cb7bd4ed750635bdd32b8fd8266149b7ebd097 100644 (file)
@@ -855,3 +855,41 @@ Handle(Geom_BSplineCurve) GeomAdaptor_Curve::BSpline() const
   return *((Handle(Geom_BSplineCurve)*)&myCurve);
 }
 
+static Standard_Integer nbPoints(const Handle(Geom_Curve)& theCurve) 
+{
+  Standard_Integer nbs = 10;
+  
+  if(theCurve->IsKind(STANDARD_TYPE( Geom_Line)) )
+    nbs = 2;
+  else if(theCurve->IsKind(STANDARD_TYPE( Geom_BezierCurve))) 
+  {
+    nbs = 3 + (*((Handle(Geom_BezierCurve)*)&theCurve))->NbPoles();
+  }
+  else if(theCurve->IsKind(STANDARD_TYPE( Geom_BSplineCurve))) { 
+    nbs =  (*((Handle(Geom_BSplineCurve)*)&theCurve))->NbKnots();
+    nbs*= (*((Handle(Geom_BSplineCurve)*)&theCurve))->Degree();
+    if(nbs < 2.0) nbs=2;
+  }
+  else if (theCurve->IsKind(STANDARD_TYPE(Geom_OffsetCurve)))
+  {
+    Handle(Geom_Curve) aCurve = (*((Handle(Geom_OffsetCurve)*)&theCurve))->BasisCurve();
+    return Max(nbs, nbPoints(aCurve));
+  }
+
+  else if (theCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve)))
+  {
+    Handle(Geom_Curve) aCurve = (*((Handle(Geom_TrimmedCurve)*)&theCurve))->BasisCurve();
+    return Max(nbs, nbPoints(aCurve));
+  }
+  if(nbs>300)
+    nbs = 300;
+  return nbs;
+  
+}
+
+/*Standard_Integer GeomAdaptor_Curve::NbSamples() const
+{
+  return  nbPoints(myCurve);
+}
+*/
index 4f9da150f08675d0a58827233035a356b3e88096..4c3a6da6f4b21c115cd0009200cb990b39a9756d 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 #include <TColStd_HArray1OfReal.hxx>
 
 static void SectionPointToParameters(const Intf_SectionPoint& Sp,
-                                    const IntPatch_Polyhedron& Surf1,
-                                    const IntPatch_Polyhedron& Surf2,
-                                    Standard_Real& u1,
-                                    Standard_Real& v1,
-                                    Standard_Real& u2,
-                                    Standard_Real& v2);
+                                     const IntPatch_Polyhedron& Surf1,
+                                     const IntPatch_Polyhedron& Surf2,
+                                     Standard_Real& u1,
+                                     Standard_Real& v1,
+                                     Standard_Real& u2,
+                                     Standard_Real& v2);
 
 
 static 
-  void AdjustOnPeriodic(const Handle(Adaptor3d_HSurface)& Surf1,
-                       const Handle(Adaptor3d_HSurface)& Surf2,
-                       IntPatch_SequenceOfLine& aSLin);
+void AdjustOnPeriodic(const Handle(Adaptor3d_HSurface)& Surf1,
+                      const Handle(Adaptor3d_HSurface)& Surf2,
+                      IntPatch_SequenceOfLine& aSLin);
 
 static
-  IntSurf_PntOn2S MakeNewPoint(const IntSurf_PntOn2S& replacePnt,
-                               const IntSurf_PntOn2S& oldPnt,
-                               const Standard_Real* Periods);
+IntSurf_PntOn2S MakeNewPoint(const IntSurf_PntOn2S& replacePnt,
+                             const IntSurf_PntOn2S& oldPnt,
+                             const Standard_Real* Periods);
 
 static Standard_Boolean IsPointOnLine(const IntSurf_PntOn2S        &thePOn2S,
                                       const Handle(IntPatch_WLine) &theWLine,
@@ -83,11 +83,11 @@ IntPatch_PrmPrmIntersection::IntPatch_PrmPrmIntersection(): done(Standard_False)
 // purpose  : 
 //==================================================================================
 void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&   Surf1,
-                                          const Handle(Adaptor3d_TopolTool)& D1,
-                                          const Standard_Real  TolTangency,
-                                          const Standard_Real  Epsilon,
-                                          const Standard_Real  Deflection,
-                                          const Standard_Real  Increment)
+                                           const Handle(Adaptor3d_TopolTool)& D1,
+                                           const Standard_Real  TolTangency,
+                                           const Standard_Real  Epsilon,
+                                           const Standard_Real  Deflection,
+                                           const Standard_Real  Increment)
 { 
   IntPatch_Polyhedron Poly1( Surf1, D1->NbSamplesU(), D1->NbSamplesV() );
   Perform( Surf1, Poly1, D1, TolTangency, Epsilon, Deflection, Increment );
@@ -98,14 +98,14 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&   S
 // purpose  : 
 //==================================================================================
 void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&   Surf1,
-                                          const IntPatch_Polyhedron& Poly1,
-                                          const Handle(Adaptor3d_TopolTool)& D1,
-                                          const Handle(Adaptor3d_HSurface)&   Surf2,
-                                          const Handle(Adaptor3d_TopolTool)& D2,
-                                          const Standard_Real  TolTangency,
-                                          const Standard_Real  Epsilon,
-                                          const Standard_Real  Deflection,
-                                          const Standard_Real  Increment)
+                                           const IntPatch_Polyhedron& Poly1,
+                                           const Handle(Adaptor3d_TopolTool)& D1,
+                                           const Handle(Adaptor3d_HSurface)&   Surf2,
+                                           const Handle(Adaptor3d_TopolTool)& D2,
+                                           const Standard_Real  TolTangency,
+                                           const Standard_Real  Epsilon,
+                                           const Standard_Real  Deflection,
+                                           const Standard_Real  Increment)
 { 
   IntPatch_Polyhedron Poly2( Surf2 );
   Perform( Surf1, Poly1, D1, Surf2, Poly2, D2, TolTangency, Epsilon, Deflection, Increment);
@@ -116,14 +116,14 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&   S
 // purpose  : 
 //==================================================================================
 void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&   Surf1,
-                                          const Handle(Adaptor3d_TopolTool)& D1,
-                                          const Handle(Adaptor3d_HSurface)&   Surf2,
-                                          const IntPatch_Polyhedron& Poly2,
-                                          const Handle(Adaptor3d_TopolTool)& D2,
-                                          const Standard_Real  TolTangency,
-                                          const Standard_Real  Epsilon,
-                                          const Standard_Real  Deflection,
-                                          const Standard_Real  Increment)
+                                           const Handle(Adaptor3d_TopolTool)& D1,
+                                           const Handle(Adaptor3d_HSurface)&   Surf2,
+                                           const IntPatch_Polyhedron& Poly2,
+                                           const Handle(Adaptor3d_TopolTool)& D2,
+                                           const Standard_Real  TolTangency,
+                                           const Standard_Real  Epsilon,
+                                           const Standard_Real  Deflection,
+                                           const Standard_Real  Increment)
 { 
   IntPatch_Polyhedron Poly1( Surf1 );    
   Perform( Surf1, Poly1, D1, Surf2, Poly2, D2, TolTangency, Epsilon, Deflection, Increment );
@@ -134,15 +134,15 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&   S
 // purpose  : 
 //==================================================================================
 void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&    Surf1,
-                                          const IntPatch_Polyhedron&  Poly1,
-                                          const Handle(Adaptor3d_TopolTool)& D1,
-                                          const Handle(Adaptor3d_HSurface)&    Surf2,
-                                          const IntPatch_Polyhedron&  Poly2,
-                                          const Handle(Adaptor3d_TopolTool)& D2,
-                                          const Standard_Real   TolTangency,
-                                          const Standard_Real   Epsilon,
-                                          const Standard_Real   Deflection,
-                                          const Standard_Real   Increment)
+                                           const IntPatch_Polyhedron&  Poly1,
+                                           const Handle(Adaptor3d_TopolTool)& D1,
+                                           const Handle(Adaptor3d_HSurface)&    Surf2,
+                                           const IntPatch_Polyhedron&  Poly2,
+                                           const Handle(Adaptor3d_TopolTool)& D2,
+                                           const Standard_Real   TolTangency,
+                                           const Standard_Real   Epsilon,
+                                           const Standard_Real   Deflection,
+                                           const Standard_Real   Increment)
 { 
   IntPatch_TheInterfPolyhedron Interference(Poly1,Poly2);
   empt = Standard_True;
@@ -160,7 +160,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
   TColStd_Array1OfReal StartParams(1,4);
 
   IntPatch_ThePWalkingInter PW( Surf1, Surf2, TolTangency, Epsilon, Deflection, Increment );
-    
+
   Standard_Real    SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant
   Standard_Real    incidence;
   Standard_Real    dminiPointLigne;
@@ -183,14 +183,14 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
     do { 
       triok=Standard_True;
       for(Standard_Integer b=2; b<=nbLigSec; b++) {
-       Standard_Integer nb_B = Interference.LineValue(TabL[b]).NumberOfPoints();
-       Standard_Integer nb_A = Interference.LineValue(TabL[b-1]).NumberOfPoints();
-       if( nb_B > nb_A ) { 
-         Standard_Integer tyu=TabL[b]; 
-         TabL[b]=TabL[b-1];
-         TabL[b-1]=tyu;
-         triok=Standard_False;
-       }
+        Standard_Integer nb_B = Interference.LineValue(TabL[b]).NumberOfPoints();
+        Standard_Integer nb_A = Interference.LineValue(TabL[b-1]).NumberOfPoints();
+        if( nb_B > nb_A ) { 
+          Standard_Integer tyu=TabL[b]; 
+          TabL[b]=TabL[b-1];
+          TabL[b-1]=tyu;
+          triok=Standard_False;
+        }
       }
     } while( triok==Standard_False );
 
@@ -201,7 +201,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
       Standard_Integer *TabPtDep = new Standard_Integer [nbp+1];
       Standard_Integer ilig;
       for( ilig = 1; ilig <= nbp; ilig++) 
-       TabPtDep[ilig]=0;
+        TabPtDep[ilig]=0;
 
       Standard_Real UminLig1,VminLig1,UmaxLig1,VmaxLig1;
       Standard_Real UminLig2,VminLig2,UmaxLig2,VmaxLig2;
@@ -214,108 +214,108 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
       VmaxLig2=VminLig2;
 
       for( ilig = 2; ilig <= nbp; ilig++ ) { 
-       SectionPointToParameters(LineSec.GetPoint(ilig),Poly1,Poly2,U1,V1,U2,V2);
+        SectionPointToParameters(LineSec.GetPoint(ilig),Poly1,Poly2,U1,V1,U2,V2);
 
-       if(U1>UmaxLig1) UmaxLig1=U1;
-       if(V1>VmaxLig1) VmaxLig1=V1;
-       if(U2>UmaxLig2) UmaxLig2=U2;
-       if(V2>VmaxLig2) VmaxLig2=V2;
+        if(U1>UmaxLig1) UmaxLig1=U1;
+        if(V1>VmaxLig1) VmaxLig1=V1;
+        if(U2>UmaxLig2) UmaxLig2=U2;
+        if(V2>VmaxLig2) VmaxLig2=V2;
 
-       if(U1<UminLig1) UminLig1=U1;
-       if(V1<VminLig1) VminLig1=V1;
-       if(U2<UminLig2) UminLig2=U2;
-       if(V2<VminLig2) VminLig2=V2;
+        if(U1<UminLig1) UminLig1=U1;
+        if(V1<VminLig1) VminLig1=V1;
+        if(U2<UminLig2) UminLig2=U2;
+        if(V2<VminLig2) VminLig2=V2;
       }
-       
+
       Standard_Integer nbps2 = (nbp>3)? (nbp/2) :  1;
       Standard_Integer NombreDePointsDeDepartDuCheminement = 0;
       Standard_Integer IndicePointdeDepart1 = 0,IndicePointdeDepart2 = 0;
       Standard_Boolean lignetrouvee=Standard_False;
 
       do { 
-       NombreDePointsDeDepartDuCheminement++;
-       if(NombreDePointsDeDepartDuCheminement == 1) { 
-         incidence=3.0;
-         Standard_Integer nbp1_4=nbp/4;
-         Standard_Integer nbp3_4=nbp-nbp1_4;
-
-         Standard_Integer nsp;
-         for(nsp=nbp/2; nsp<nbp3_4; nsp++) { 
-           Standard_Real CurrentIncidence =  LineSec.GetPoint(nsp).Incidence();
-           if(CurrentIncidence < incidence) { 
-             nbps2 = nsp;
-             incidence = 0.9*CurrentIncidence;
-           }
-         }
-
-         for(nsp=nbp/2; nsp>nbp1_4; nsp--) { 
-           Standard_Real CurrentIncidence =  LineSec.GetPoint(nsp).Incidence();
-           if(CurrentIncidence < incidence) { 
-             nbps2 = nsp;
-             incidence = 0.9*CurrentIncidence;
-           }
-         }
-
-         if(nbp<3) 
-           NombreDePointsDeDepartDuCheminement=3;
-
-         IndicePointdeDepart1 = nbps2;
-       }
-       else if(NombreDePointsDeDepartDuCheminement == 2) { 
-         if(IndicePointdeDepart1 == 1) { 
-           nbps2 = nbp/2;
-           IndicePointdeDepart2 = nbps2;
-         }
-         else { 
-           nbps2 = 1;
-           IndicePointdeDepart2 = 1;
-         }
-       }
-       else if(NombreDePointsDeDepartDuCheminement == 3) {
-         if(IndicePointdeDepart1 == nbp)
-           nbps2 = (IndicePointdeDepart1+IndicePointdeDepart2)/2;
-         else
-           nbps2 = nbp;
-       }
-       else { 
-         nbps2 = NombreDePointsDeDepartDuCheminement-3;
-         NombreDePointsDeDepartDuCheminement++;
-       } 
-
-       if(TabPtDep[nbps2]==0) { 
-         TabPtDep[nbps2]=1;
-         SectionPointToParameters(LineSec.GetPoint(nbps2),Poly1,Poly2,U1,V1,U2,V2);
-
-         StartParams(1) = U1;
-         StartParams(2) = V1;
-         StartParams(3) = U2;
-         StartParams(4) = V2;
-           
-         HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);
-         dminiPointLigne = SeuildPointLigne + SeuildPointLigne;
-                 
-         if(HasStartPoint) { 
-           StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
-           NbLigCalculee = SLin.Length();
-           Standard_Integer l;
-           for( l=1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) { 
-             const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l));
+        NombreDePointsDeDepartDuCheminement++;
+        if(NombreDePointsDeDepartDuCheminement == 1) { 
+          incidence=3.0;
+          Standard_Integer nbp1_4=nbp/4;
+          Standard_Integer nbp3_4=nbp-nbp1_4;
+
+          Standard_Integer nsp;
+          for(nsp=nbp/2; nsp<nbp3_4; nsp++) { 
+            Standard_Real CurrentIncidence =  LineSec.GetPoint(nsp).Incidence();
+            if(CurrentIncidence < incidence) { 
+              nbps2 = nsp;
+              incidence = 0.9*CurrentIncidence;
+            }
+          }
+
+          for(nsp=nbp/2; nsp>nbp1_4; nsp--) { 
+            Standard_Real CurrentIncidence =  LineSec.GetPoint(nsp).Incidence();
+            if(CurrentIncidence < incidence) { 
+              nbps2 = nsp;
+              incidence = 0.9*CurrentIncidence;
+            }
+          }
+
+          if(nbp<3) 
+            NombreDePointsDeDepartDuCheminement=3;
+
+          IndicePointdeDepart1 = nbps2;
+        }
+        else if(NombreDePointsDeDepartDuCheminement == 2) { 
+          if(IndicePointdeDepart1 == 1) { 
+            nbps2 = nbp/2;
+            IndicePointdeDepart2 = nbps2;
+          }
+          else { 
+            nbps2 = 1;
+            IndicePointdeDepart2 = 1;
+          }
+        }
+        else if(NombreDePointsDeDepartDuCheminement == 3) {
+          if(IndicePointdeDepart1 == nbp)
+            nbps2 = (IndicePointdeDepart1+IndicePointdeDepart2)/2;
+          else
+            nbps2 = nbp;
+        }
+        else { 
+          nbps2 = NombreDePointsDeDepartDuCheminement-3;
+          NombreDePointsDeDepartDuCheminement++;
+        
+
+        if(TabPtDep[nbps2]==0) { 
+          TabPtDep[nbps2]=1;
+          SectionPointToParameters(LineSec.GetPoint(nbps2),Poly1,Poly2,U1,V1,U2,V2);
+
+          StartParams(1) = U1;
+          StartParams(2) = V1;
+          StartParams(3) = U2;
+          StartParams(4) = V2;
+
+          HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);
+          dminiPointLigne = SeuildPointLigne + SeuildPointLigne;
+
+          if(HasStartPoint) { 
+            StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
+            NbLigCalculee = SLin.Length();
+            Standard_Integer l;
+            for( l=1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) { 
+              const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l));
 
               if (IsPointOnLine(StartPOn2S, testwline, Deflection)) {
                 dminiPointLigne = 0.0;
               }
-           } // for ( l ...
-
-           if(dminiPointLigne > SeuildPointLigne) { 
-             PW.Perform(StartParams,UminLig1,VminLig1,UminLig2,VminLig2,UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2);
-             if(PW.IsDone()) {
-               if(PW.NbPoints()>2) { 
-                 RejetLigne = Standard_False;
-                 Point3dDebut = PW.Value(1).Value();
+            } // for ( l ...
+
+            if(dminiPointLigne > SeuildPointLigne) { 
+              PW.Perform(StartParams,UminLig1,VminLig1,UminLig2,VminLig2,UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2);
+              if(PW.IsDone()) {
+                if(PW.NbPoints()>2) { 
+                  RejetLigne = Standard_False;
+                  Point3dDebut = PW.Value(1).Value();
                   const IntSurf_PntOn2S& PointFin = PW.Value(PW.NbPoints());
                   Point3dFin   = PointFin.Value();
-                 for( ver = 1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
-                   const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
+                  for( ver = 1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
+                    const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
 
                     // Check end point if it is on existing line.
                     // Start point is checked before.
@@ -325,69 +325,69 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                     }
 
                     const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
-                   const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts());
-                   if( Point3dDebut.Distance(verPointDebut.Value()) <= TolTangency ) { 
-                     if(Point3dFin.Distance(verPointFin.Value()) <= TolTangency)
-                       RejetLigne = Standard_True; 
-                   }
-                 }
-
-                 if(!RejetLigne) { 
-                   // Calculation transition
-                   IntSurf_TypeTrans trans1,trans2;
-                   Standard_Real locu,locv;
-                   gp_Vec norm1,norm2,d1u,d1v;
-                   gp_Pnt ptbid;
-                   Standard_Integer indextg;
-                   gp_Vec tgline(PW.TangentAtLine(indextg));
-                   PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
-                   Surf1->D1(locu,locv,ptbid,d1u,d1v);
-                   norm1 = d1u.Crossed(d1v);
-                   PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
-                   Surf2->D1(locu,locv,ptbid,d1u,d1v);
-                   norm2 = d1u.Crossed(d1v);
-                   if(tgline.DotCross(norm2,norm1)>0.) {
-                     trans1 = IntSurf_Out;
-                     trans2 = IntSurf_In;
-                   }
-                   else {
-                     trans1 = IntSurf_In;
-                     trans2 = IntSurf_Out;
-                   }
-
-                   Standard_Real TolTang = TolTangency;
-                   Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
-                   IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
-                   IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
-
-                   if(wline->NbVertex() == 0) {
-                     IntPatch_Point vtx;
-                     IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
-                     POn2S.Parameters(pu1,pv1,pu2,pv2);
-                     vtx.SetValue(Point3dDebut,TolTang,Standard_False);
-                     vtx.SetParameters(pu1,pv1,pu2,pv2);
-                     vtx.SetParameter(1);
-                     wline->AddVertex(vtx);
-
-                     POn2S = PW.Line()->Value(wline->NbPnts());
-                     POn2S.Parameters(pu1,pv1,pu2,pv2);
-                     vtx.SetValue(Point3dFin,TolTang,Standard_False);
-                     vtx.SetParameters(pu1,pv1,pu2,pv2);
-                     vtx.SetParameter(wline->NbPnts());
-                     wline->AddVertex(vtx);
-                   }
-
-                   lignetrouvee = Standard_True;
+                    const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts());
+                    if( Point3dDebut.Distance(verPointDebut.Value()) <= TolTangency ) { 
+                      if(Point3dFin.Distance(verPointFin.Value()) <= TolTangency)
+                        RejetLigne = Standard_True; 
+                    }
+                  }
+
+                  if(!RejetLigne) { 
+                    // Calculation transition
+                    IntSurf_TypeTrans trans1,trans2;
+                    Standard_Real locu,locv;
+                    gp_Vec norm1,norm2,d1u,d1v;
+                    gp_Pnt ptbid;
+                    Standard_Integer indextg;
+                    gp_Vec tgline(PW.TangentAtLine(indextg));
+                    PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
+                    Surf1->D1(locu,locv,ptbid,d1u,d1v);
+                    norm1 = d1u.Crossed(d1v);
+                    PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
+                    Surf2->D1(locu,locv,ptbid,d1u,d1v);
+                    norm2 = d1u.Crossed(d1v);
+                    if(tgline.DotCross(norm2,norm1)>0.) {
+                      trans1 = IntSurf_Out;
+                      trans2 = IntSurf_In;
+                    }
+                    else {
+                      trans1 = IntSurf_In;
+                      trans2 = IntSurf_Out;
+                    }
+
+                    Standard_Real TolTang = TolTangency;
+                    Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
+                    IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+                    IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+
+                    if(wline->NbVertex() == 0) {
+                      IntPatch_Point vtx;
+                      IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
+                      POn2S.Parameters(pu1,pv1,pu2,pv2);
+                      vtx.SetValue(Point3dDebut,TolTang,Standard_False);
+                      vtx.SetParameters(pu1,pv1,pu2,pv2);
+                      vtx.SetParameter(1);
+                      wline->AddVertex(vtx);
+
+                      POn2S = PW.Line()->Value(wline->NbPnts());
+                      POn2S.Parameters(pu1,pv1,pu2,pv2);
+                      vtx.SetValue(Point3dFin,TolTang,Standard_False);
+                      vtx.SetParameters(pu1,pv1,pu2,pv2);
+                      vtx.SetParameter(wline->NbPnts());
+                      wline->AddVertex(vtx);
+                    }
+
+                    lignetrouvee = Standard_True;
                     AddWLine(SLin, wline, Deflection);
-                   empt = Standard_False;
-                 }// !RejetLigne
-               }// PW.NbPoints()>2
-             }// done is True
-           }// dminiPointLigne > SeuildPointLigne
-         }// HasStartPoint
-       }// TabPtDep[nbps2]==0
+                    empt = Standard_False;
+                  }// !RejetLigne
+                }// PW.NbPoints()>2
+              }// done is True
+            }// dminiPointLigne > SeuildPointLigne
+          }// HasStartPoint
+        }// TabPtDep[nbps2]==0
       } while( nbp>5 && ( !( ( (NombreDePointsDeDepartDuCheminement >= 3) && lignetrouvee ) || 
-                       ( (NombreDePointsDeDepartDuCheminement-3>=nbp) && !lignetrouvee ) ) ) );
+        ( (NombreDePointsDeDepartDuCheminement-3>=nbp) && !lignetrouvee ) ) ) );
 
       delete [] TabPtDep;
     }// for( ls ...
@@ -397,7 +397,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
 
   Standard_Real UminLig1,VminLig1,UmaxLig1,VmaxLig1;
   Standard_Real UminLig2,VminLig2,UmaxLig2,VmaxLig2;
-    
+
   UminLig1=VminLig1=UminLig2=VminLig2=RealLast();
   UmaxLig1=VmaxLig1=UmaxLig2=VmaxLig2=-UminLig1;
 
@@ -411,7 +411,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
       if(V1>VmaxLig1) VmaxLig1=V1;
       if(U2>UmaxLig2) UmaxLig2=U2;
       if(V2>VmaxLig2) VmaxLig2=V2;
-       
+
       if(U1<UminLig1) UminLig1=U1;
       if(V1<VminLig1) VminLig1=V1;
       if(U2<UminLig2) UminLig2=U2;
@@ -429,31 +429,31 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
       StartParams(2) = V1;
       StartParams(3) = U2;
       StartParams(4) = V2;
-       
+
       HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);
       if(HasStartPoint) { 
-       StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
-       NbLigCalculee = SLin.Length();
-       dminiPointLigne = SeuildPointLigne + SeuildPointLigne; 
-       Standard_Integer l;
-       for( l = 1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) { 
-         const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l));
+        StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
+        NbLigCalculee = SLin.Length();
+        dminiPointLigne = SeuildPointLigne + SeuildPointLigne; 
+        Standard_Integer l;
+        for( l = 1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++)        { 
+          const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l));
 
           if (IsPointOnLine(StartPOn2S, testwline, Deflection)) {
             dminiPointLigne = 0.0;
           }
-       }// for( l ...
-
-       if(dminiPointLigne > SeuildPointLigne) { 
-         PW.Perform(StartParams,UminLig1,VminLig1,UminLig2,VminLig2,UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2);
-         if(PW.IsDone()) {
-           if(PW.NbPoints()>2) { 
-             RejetLigne = Standard_False;
-             Point3dDebut = PW.Value(1).Value();
+        }// for( l ...
+
+        if(dminiPointLigne > SeuildPointLigne) { 
+          PW.Perform(StartParams,UminLig1,VminLig1,UminLig2,VminLig2,UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2);
+          if(PW.IsDone()) {
+            if(PW.NbPoints()>2)        { 
+              RejetLigne = Standard_False;
+              Point3dDebut = PW.Value(1).Value();
               const IntSurf_PntOn2S& PointFin = PW.Value(PW.NbPoints());
               Point3dFin   = PointFin.Value();
-             for(ver=1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
-               const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
+              for(ver=1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
+                const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
 
                 // Check end point if it is on existing line.
                 // Start point is checked before.
@@ -462,66 +462,66 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                   break;
                 }
 
-               const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
-               const IntSurf_PntOn2S& verPointFin   = verwline->Point(verwline->NbPnts());
-               if(Point3dDebut.Distance(verPointDebut.Value()) < TolTangency)
-                 RejetLigne = Standard_True; 
-               else { 
-                 if(Point3dFin.Distance(verPointFin.Value()) < TolTangency)
-                   RejetLigne = Standard_True; 
-               }
-             }
-             
-             if(!RejetLigne) { 
-               IntSurf_TypeTrans trans1,trans2;
-               Standard_Real locu,locv;
-               gp_Vec norm1,norm2,d1u,d1v;
-               gp_Pnt ptbid;
-               Standard_Integer indextg;
-               gp_Vec tgline(PW.TangentAtLine(indextg));
-               PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
-               Surf1->D1(locu,locv,ptbid,d1u,d1v);
-               norm1 = d1u.Crossed(d1v);
-               PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
-               Surf2->D1(locu,locv,ptbid,d1u,d1v);
-               norm2 = d1u.Crossed(d1v);
-               if(tgline.DotCross(norm2,norm1)>0.) {
-                 trans1 = IntSurf_Out;
-                 trans2 = IntSurf_In;
-               }
-               else {
-                 trans1 = IntSurf_In;
-                 trans2 = IntSurf_Out;
-               }
-
-               Standard_Real TolTang = TolTangency;
-               Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
-               IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
-               IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
-
-               if(wline->NbVertex() == 0) {
-                 IntPatch_Point vtx;
-                 IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
-                 POn2S.Parameters(pu1,pv1,pu2,pv2);
-                 vtx.SetValue(Point3dDebut,TolTang,Standard_False);
-                 vtx.SetParameters(pu1,pv1,pu2,pv2);
-                 vtx.SetParameter(1);
-                 wline->AddVertex(vtx);
-                     
-                 POn2S = PW.Line()->Value(wline->NbPnts());
-                 POn2S.Parameters(pu1,pv1,pu2,pv2);
-                 vtx.SetValue(Point3dFin,TolTang,Standard_False);
-                 vtx.SetParameters(pu1,pv1,pu2,pv2);
-                 vtx.SetParameter(wline->NbPnts());
-                 wline->AddVertex(vtx);
-               }
+                const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
+                const IntSurf_PntOn2S& verPointFin   = verwline->Point(verwline->NbPnts());
+                if(Point3dDebut.Distance(verPointDebut.Value()) < TolTangency)
+                  RejetLigne = Standard_True; 
+                else { 
+                  if(Point3dFin.Distance(verPointFin.Value()) < TolTangency)
+                    RejetLigne = Standard_True; 
+                }
+              }
+
+              if(!RejetLigne) { 
+                IntSurf_TypeTrans trans1,trans2;
+                Standard_Real locu,locv;
+                gp_Vec norm1,norm2,d1u,d1v;
+                gp_Pnt ptbid;
+                Standard_Integer indextg;
+                gp_Vec tgline(PW.TangentAtLine(indextg));
+                PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
+                Surf1->D1(locu,locv,ptbid,d1u,d1v);
+                norm1 = d1u.Crossed(d1v);
+                PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
+                Surf2->D1(locu,locv,ptbid,d1u,d1v);
+                norm2 = d1u.Crossed(d1v);
+                if(tgline.DotCross(norm2,norm1)>0.) {
+                  trans1 = IntSurf_Out;
+                  trans2 = IntSurf_In;
+                }
+                else {
+                  trans1 = IntSurf_In;
+                  trans2 = IntSurf_Out;
+                }
+
+                Standard_Real TolTang = TolTangency;
+                Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
+                IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+                IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+
+                if(wline->NbVertex() == 0) {
+                  IntPatch_Point vtx;
+                  IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
+                  POn2S.Parameters(pu1,pv1,pu2,pv2);
+                  vtx.SetValue(Point3dDebut,TolTang,Standard_False);
+                  vtx.SetParameters(pu1,pv1,pu2,pv2);
+                  vtx.SetParameter(1);
+                  wline->AddVertex(vtx);
+
+                  POn2S = PW.Line()->Value(wline->NbPnts());
+                  POn2S.Parameters(pu1,pv1,pu2,pv2);
+                  vtx.SetValue(Point3dFin,TolTang,Standard_False);
+                  vtx.SetParameters(pu1,pv1,pu2,pv2);
+                  vtx.SetParameter(wline->NbPnts());
+                  wline->AddVertex(vtx);
+                }
 
                 AddWLine(SLin, wline, Deflection);
-               empt = Standard_False;
-             }// if !RejetLigne
-           }// PW.NbPoints()>2
-         }// done is True
-       }// dminiPointLigne > SeuildPointLigne
+                empt = Standard_False;
+              }// if !RejetLigne
+            }// PW.NbPoints()>2
+          }// done is True
+        }// dminiPointLigne > SeuildPointLigne
       }// HasStartPoint
     }// for( pz ...
   }// for( z ...
@@ -532,12 +532,12 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
 // purpose  : 
 //==================================================================================
 void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&    Surf1,
-                                          const IntPatch_Polyhedron&  Poly1,
-                                          const Handle(Adaptor3d_TopolTool)& D1,
-                                          const Standard_Real   TolTangency,
-                                          const Standard_Real   Epsilon,
-                                          const Standard_Real   Deflection,
-                                          const Standard_Real   Increment)
+                                           const IntPatch_Polyhedron&  Poly1,
+                                           const Handle(Adaptor3d_TopolTool)& D1,
+                                           const Standard_Real   TolTangency,
+                                           const Standard_Real   Epsilon,
+                                           const Standard_Real   Deflection,
+                                           const Standard_Real   Increment)
 { 
   IntPatch_TheInterfPolyhedron Interference(Poly1);
   empt = Standard_True;
@@ -555,7 +555,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
 
   TColStd_Array1OfReal StartParams(1,4);
   IntPatch_ThePWalkingInter PW(Surf1,Surf1,TolTangency,Epsilon,Deflection,Increment);
-   
+
   Standard_Real    SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant
   Standard_Real    incidence;
   Standard_Real    dminiPointLigne;
@@ -577,210 +577,210 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
       Standard_Integer NombreDePointsDeDepartDuCheminement = 0;
       Standard_Integer IndicePointdeDepart1 = 0, IndicePointdeDepart2 = 0;
       do { 
-       NombreDePointsDeDepartDuCheminement++;
-       if(NombreDePointsDeDepartDuCheminement == 1) { 
-         incidence = 0.0;
-         Standard_Integer nsp1;
-         for( nsp1= nbp/2; nsp1 >= 1; nsp1--) { 
-           SectionPointToParameters(LineSec.GetPoint(nsp1),Poly1,Poly1,U1,V1,U2,V2);
-           Standard_Real CurrentIncidence =  Abs(U1-U2)+Abs(V1-V2);
-           if(CurrentIncidence > incidence) { 
-             nbps2 = nsp1;
-             incidence = CurrentIncidence;
-           }
-         }
-         for( nsp1 = nbp/2; nsp1 <= nbp; nsp1++) { 
-           SectionPointToParameters(LineSec.GetPoint(nsp1),Poly1,Poly1,U1,V1,U2,V2);
-           Standard_Real CurrentIncidence =  Abs(U1-U2)+Abs(V1-V2);
-           if(CurrentIncidence > incidence) { 
-             nbps2 = nsp1;
-             incidence = CurrentIncidence;
-           }
-         }
-
-         if(nbp<3) 
-           NombreDePointsDeDepartDuCheminement=3;
-                 
-         IndicePointdeDepart1 = nbps2;
-       }
-       else if(NombreDePointsDeDepartDuCheminement == 2) { 
-         if(IndicePointdeDepart1 == 1) { 
-           nbps2 = nbp/2;
-           IndicePointdeDepart2 = nbps2;
-         }
-         else { 
-           nbps2 = 1;
-           IndicePointdeDepart2 = 1;
-         }
-       }
-       else {
-         if(IndicePointdeDepart1 == nbp)
-           nbps2 = (IndicePointdeDepart1+IndicePointdeDepart2)/2;
-         else
-           nbps2 = nbp;
-       }
-
-       SectionPointToParameters(LineSec.GetPoint(nbps2),Poly1,Poly1,U1,V1,U2,V2);
-
-       StartParams(1) = U1;
-       StartParams(2) = V1;
-       StartParams(3) = U2;
-       StartParams(4) = V2;
-
-       HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);
-       dminiPointLigne = SeuildPointLigne + SeuildPointLigne;
-       if(HasStartPoint) { 
-         StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
-         if(Abs(pu1-pu2)>1e-7 || Abs(pv1-pv2)>1e-7) { 
-           NbLigCalculee = SLin.Length();
-           Standard_Integer l;
-           for( l = 1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) { 
-             const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l));
-             if( (testwline->IsOutSurf1Box(gp_Pnt2d(pu1,pv1))==Standard_False) &&
-                 (testwline->IsOutSurf2Box(gp_Pnt2d(pu2,pv2))==Standard_False) &&
-                 (testwline->IsOutBox(StartPOn2S.Value())==Standard_False) ) { 
-               NbPntOn2SOnLine = testwline->NbPnts();
-               Standard_Integer ll;
-               for( ll=1; (ll < NbPntOn2SOnLine) && (dminiPointLigne >= SeuildPointLigne); ll++) { 
-                 Standard_Real t,Au1,Av1,Au2,Av2,Bu1,Bv1,Bu2,Bv2;
-                 testwline->Point(ll).Parameters(Au1,Av1,Au2,Av2);
-                 testwline->Point(ll+1).Parameters(Bu1,Bv1,Bu2,Bv2);
-                 if(Au1>Bu1) {
-                   t=Au1;
-                   Au1=Bu1;
-                   Bu1=t;
-                 } 
-                 if(Av1>Bv1) {
-                   t=Av1;
-                   Av1=Bv1;
-                   Bv1=t;
-                 } 
-                 Au1-=1.0e-7;
-                 Av1-=1.0e-7;
-                 Bu1+=1.0e-7;
-                 Bv1+=1.0e-7;
-                 
-                 if((pu1>=Au1) && (pu1<=Bu1) && (pv1>=Av1) && (pv1<=Bv1))
-                   dminiPointLigne = 0.0; 
-                 else { 
-                   if((pu2>=Au1) && (pu2<=Bu1) && (pv2>=Av1) && (pv2<=Bv1))
-                     dminiPointLigne = 0.0;
-                 }
-               }// for( ll ...
-             }// if ...
-           }// for( l ...
-
-           if(dminiPointLigne > SeuildPointLigne) { 
-             PW.Perform(StartParams);
-             if(PW.IsDone()) {
-               if(PW.NbPoints()>2) { 
-                 RejetLigne = Standard_False;
-                 Point3dDebut = PW.Value(1).Value();
-                 Point3dFin   = PW.Value(PW.NbPoints()).Value();
-                 for(ver=1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
-                   const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
-                   const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
-                   const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts());
-                   if(Point3dDebut.Distance(verPointDebut.Value()) < TolTangency)
-                     RejetLigne = Standard_True; 
-                   else { 
-                     if(Point3dFin.Distance(verPointFin.Value()) < TolTangency)
-                       RejetLigne = Standard_True; 
-                   }
-                 }
-
-                 if(!RejetLigne) { 
-                   IntSurf_TypeTrans trans1,trans2;
-                   Standard_Real locu,locv;
-                   gp_Vec norm1,norm2,d1u,d1v;
-                   gp_Pnt ptbid;
-                   Standard_Integer indextg;
-                   gp_Vec tgline(PW.TangentAtLine(indextg));
-                   PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
-                   Surf1->D1(locu,locv,ptbid,d1u,d1v);
-                   norm1 = d1u.Crossed(d1v);
-                   PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
-                   Surf1->D1(locu,locv,ptbid,d1u,d1v);
-                   norm2 = d1u.Crossed(d1v);
-                   if (tgline.DotCross(norm2,norm1)>0.) {
-                     trans1 = IntSurf_Out;
-                     trans2 = IntSurf_In;
-                   }
-                   else {
-                     trans1 = IntSurf_In;
-                     trans2 = IntSurf_Out;
-                   }
-
-                   IntSurf_LineOn2S LineOn2S;
-                   Standard_Integer nbpw,imin,imax,i;
-                   nbpw = PW.Line()->NbPoints();
-                   Standard_Real u1,v1,u2,v2;
-                   i=0;
-                   do { 
-                     i++;
-                     imin=i;
-                     const IntSurf_PntOn2S& Pi   = PW.Line()->Value(i);
-                     Pi.Parameters(u1,v1,u2,v2);
-                   } while((i<nbpw)&&(Abs(u1-u2)<=1e-6 && Abs(v1-v2)<=1e-6));
-                             
-                   if(imin>2)
-                     imin--;
-
-                   i=nbpw+1;
-                   do { 
-                     i--;
-                     imax=i;
-                     const IntSurf_PntOn2S& Pi   = PW.Line()->Value(i);
-                     Pi.Parameters(u1,v1,u2,v2);
-                   } while((i>2)&&(Abs(u1-u2)<=1e-6 && Abs(v1-v2)<=1e-6));
-                                     
-                   if(imax<nbpw)
-                     imax++;
-                   
-                   if(imin<imax) { 
-                     Handle_IntSurf_LineOn2S PWLine = new IntSurf_LineOn2S();
-                     for(i=imin;i<=imax;i++) 
-                       PWLine->Add(PW.Line()->Value(i));
-                     
-                     Standard_Real TolTang = TolTangency;
-                     Handle(IntPatch_WLine) wline = new IntPatch_WLine(PWLine,Standard_False,trans1,trans2);
-                     const IntSurf_PntOn2S& POn2SDeb = wline->Point(1);
-                     const IntSurf_PntOn2S& POn2SFin = wline->Point(wline->NbPnts());
-                     if((POn2SDeb.Value()).Distance(POn2SFin.Value()) <= TolTangency) { 
-                       Standard_Real u1t,v1t,u2t,v2t; 
-                       POn2SDeb.Parameters(u1t,v1t,u2t,v2t);
-                       IntPatch_Point vtx;
-                       vtx.SetValue(POn2SDeb.Value(),TolTang,Standard_False);
-                       vtx.SetParameters(u2t,v2t,u1t,v1t);
-                       vtx.SetParameter(wline->NbPnts());
-                       wline->SetPoint(wline->NbPnts(),vtx);
-                     }
-                     IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf1,Standard_True,TolTang);
-                     if(wline->NbVertex() == 0) {
-                       IntPatch_Point vtx;
-                       IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
-                       POn2S.Parameters(pu1,pv1,pu2,pv2);
-                       vtx.SetValue(Point3dDebut,TolTang,Standard_False);
-                       vtx.SetParameters(pu1,pv1,pu2,pv2);
-                       vtx.SetParameter(1);
-                       wline->AddVertex(vtx);
-                                             
-                       POn2S = PW.Line()->Value(wline->NbPnts());
-                       POn2S.Parameters(pu1,pv1,pu2,pv2);
-                       vtx.SetValue(Point3dFin,TolTang,Standard_False);
-                       vtx.SetParameters(pu1,pv1,pu2,pv2);
-                       vtx.SetParameter(wline->NbPnts());
-                       wline->AddVertex(vtx);
-                     }
-                     SLin.Append(wline);
-                     empt = Standard_False;
-                   }// imin<imax
-                 }// !RejetLigne
-               }// PW.NbPoints()>2
-             }// done is True
-           }// dminiPointLigne > SeuildPointLigne
-         }// Abs || Abs
-       }// HasStartPoint
+        NombreDePointsDeDepartDuCheminement++;
+        if(NombreDePointsDeDepartDuCheminement == 1) { 
+          incidence = 0.0;
+          Standard_Integer nsp1;
+          for( nsp1= nbp/2; nsp1 >= 1; nsp1--) { 
+            SectionPointToParameters(LineSec.GetPoint(nsp1),Poly1,Poly1,U1,V1,U2,V2);
+            Standard_Real CurrentIncidence =  Abs(U1-U2)+Abs(V1-V2);
+            if(CurrentIncidence > incidence) { 
+              nbps2 = nsp1;
+              incidence = CurrentIncidence;
+            }
+          }
+          for( nsp1 = nbp/2; nsp1 <= nbp; nsp1++) { 
+            SectionPointToParameters(LineSec.GetPoint(nsp1),Poly1,Poly1,U1,V1,U2,V2);
+            Standard_Real CurrentIncidence =  Abs(U1-U2)+Abs(V1-V2);
+            if(CurrentIncidence > incidence) { 
+              nbps2 = nsp1;
+              incidence = CurrentIncidence;
+            }
+          }
+
+          if(nbp<3) 
+            NombreDePointsDeDepartDuCheminement=3;
+
+          IndicePointdeDepart1 = nbps2;
+        }
+        else if(NombreDePointsDeDepartDuCheminement == 2) { 
+          if(IndicePointdeDepart1 == 1) { 
+            nbps2 = nbp/2;
+            IndicePointdeDepart2 = nbps2;
+          }
+          else { 
+            nbps2 = 1;
+            IndicePointdeDepart2 = 1;
+          }
+        }
+        else {
+          if(IndicePointdeDepart1 == nbp)
+            nbps2 = (IndicePointdeDepart1+IndicePointdeDepart2)/2;
+          else
+            nbps2 = nbp;
+        }
+
+        SectionPointToParameters(LineSec.GetPoint(nbps2),Poly1,Poly1,U1,V1,U2,V2);
+
+        StartParams(1) = U1;
+        StartParams(2) = V1;
+        StartParams(3) = U2;
+        StartParams(4) = V2;
+
+        HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);
+        dminiPointLigne = SeuildPointLigne + SeuildPointLigne;
+        if(HasStartPoint) { 
+          StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
+          if(Abs(pu1-pu2)>1e-7 || Abs(pv1-pv2)>1e-7) { 
+            NbLigCalculee = SLin.Length();
+            Standard_Integer l;
+            for( l = 1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) { 
+              const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l));
+              if( (testwline->IsOutSurf1Box(gp_Pnt2d(pu1,pv1))==Standard_False) &&
+                (testwline->IsOutSurf2Box(gp_Pnt2d(pu2,pv2))==Standard_False) &&
+                (testwline->IsOutBox(StartPOn2S.Value())==Standard_False) ) { 
+                  NbPntOn2SOnLine = testwline->NbPnts();
+                  Standard_Integer ll;
+                  for( ll=1; (ll < NbPntOn2SOnLine) && (dminiPointLigne >= SeuildPointLigne); ll++) { 
+                    Standard_Real t,Au1,Av1,Au2,Av2,Bu1,Bv1,Bu2,Bv2;
+                    testwline->Point(ll).Parameters(Au1,Av1,Au2,Av2);
+                    testwline->Point(ll+1).Parameters(Bu1,Bv1,Bu2,Bv2);
+                    if(Au1>Bu1) {
+                      t=Au1;
+                      Au1=Bu1;
+                      Bu1=t;
+                    
+                    if(Av1>Bv1) {
+                      t=Av1;
+                      Av1=Bv1;
+                      Bv1=t;
+                    
+                    Au1-=1.0e-7;
+                    Av1-=1.0e-7;
+                    Bu1+=1.0e-7;
+                    Bv1+=1.0e-7;
+
+                    if((pu1>=Au1) && (pu1<=Bu1) && (pv1>=Av1) && (pv1<=Bv1))
+                      dminiPointLigne = 0.0; 
+                    else { 
+                      if((pu2>=Au1) && (pu2<=Bu1) && (pv2>=Av1) && (pv2<=Bv1))
+                        dminiPointLigne = 0.0;
+                    }
+                  }// for( ll ...
+              }// if ...
+            }// for( l ...
+
+            if(dminiPointLigne > SeuildPointLigne) { 
+              PW.Perform(StartParams);
+              if(PW.IsDone()) {
+                if(PW.NbPoints()>2) { 
+                  RejetLigne = Standard_False;
+                  Point3dDebut = PW.Value(1).Value();
+                  Point3dFin   = PW.Value(PW.NbPoints()).Value();
+                  for(ver=1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
+                    const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
+                    const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
+                    const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts());
+                    if(Point3dDebut.Distance(verPointDebut.Value()) < TolTangency)
+                      RejetLigne = Standard_True; 
+                    else { 
+                      if(Point3dFin.Distance(verPointFin.Value()) < TolTangency)
+                        RejetLigne = Standard_True; 
+                    }
+                  }
+
+                  if(!RejetLigne) { 
+                    IntSurf_TypeTrans trans1,trans2;
+                    Standard_Real locu,locv;
+                    gp_Vec norm1,norm2,d1u,d1v;
+                    gp_Pnt ptbid;
+                    Standard_Integer indextg;
+                    gp_Vec tgline(PW.TangentAtLine(indextg));
+                    PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
+                    Surf1->D1(locu,locv,ptbid,d1u,d1v);
+                    norm1 = d1u.Crossed(d1v);
+                    PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
+                    Surf1->D1(locu,locv,ptbid,d1u,d1v);
+                    norm2 = d1u.Crossed(d1v);
+                    if (tgline.DotCross(norm2,norm1)>0.) {
+                      trans1 = IntSurf_Out;
+                      trans2 = IntSurf_In;
+                    }
+                    else {
+                      trans1 = IntSurf_In;
+                      trans2 = IntSurf_Out;
+                    }
+
+                    IntSurf_LineOn2S LineOn2S;
+                    Standard_Integer nbpw,imin,imax,i;
+                    nbpw = PW.Line()->NbPoints();
+                    Standard_Real u1,v1,u2,v2;
+                    i=0;
+                    do { 
+                      i++;
+                      imin=i;
+                      const IntSurf_PntOn2S& Pi   = PW.Line()->Value(i);
+                      Pi.Parameters(u1,v1,u2,v2);
+                    } while((i<nbpw)&&(Abs(u1-u2)<=1e-6 && Abs(v1-v2)<=1e-6));
+
+                    if(imin>2)
+                      imin--;
+
+                    i=nbpw+1;
+                    do { 
+                      i--;
+                      imax=i;
+                      const IntSurf_PntOn2S& Pi   = PW.Line()->Value(i);
+                      Pi.Parameters(u1,v1,u2,v2);
+                    } while((i>2)&&(Abs(u1-u2)<=1e-6 && Abs(v1-v2)<=1e-6));
+
+                    if(imax<nbpw)
+                      imax++;
+
+                    if(imin<imax) { 
+                      Handle_IntSurf_LineOn2S PWLine = new IntSurf_LineOn2S();
+                      for(i=imin;i<=imax;i++) 
+                        PWLine->Add(PW.Line()->Value(i));
+
+                      Standard_Real TolTang = TolTangency;
+                      Handle(IntPatch_WLine) wline = new IntPatch_WLine(PWLine,Standard_False,trans1,trans2);
+                      const IntSurf_PntOn2S& POn2SDeb = wline->Point(1);
+                      const IntSurf_PntOn2S& POn2SFin = wline->Point(wline->NbPnts());
+                      if((POn2SDeb.Value()).Distance(POn2SFin.Value()) <= TolTangency) { 
+                        Standard_Real u1t,v1t,u2t,v2t; 
+                        POn2SDeb.Parameters(u1t,v1t,u2t,v2t);
+                        IntPatch_Point vtx;
+                        vtx.SetValue(POn2SDeb.Value(),TolTang,Standard_False);
+                        vtx.SetParameters(u2t,v2t,u1t,v1t);
+                        vtx.SetParameter(wline->NbPnts());
+                        wline->SetPoint(wline->NbPnts(),vtx);
+                      }
+                      IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf1,Standard_True,TolTang);
+                      if(wline->NbVertex() == 0) {
+                        IntPatch_Point vtx;
+                        IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
+                        POn2S.Parameters(pu1,pv1,pu2,pv2);
+                        vtx.SetValue(Point3dDebut,TolTang,Standard_False);
+                        vtx.SetParameters(pu1,pv1,pu2,pv2);
+                        vtx.SetParameter(1);
+                        wline->AddVertex(vtx);
+
+                        POn2S = PW.Line()->Value(wline->NbPnts());
+                        POn2S.Parameters(pu1,pv1,pu2,pv2);
+                        vtx.SetValue(Point3dFin,TolTang,Standard_False);
+                        vtx.SetParameters(pu1,pv1,pu2,pv2);
+                        vtx.SetParameter(wline->NbPnts());
+                        wline->AddVertex(vtx);
+                      }
+                      SLin.Append(wline);
+                      empt = Standard_False;
+                    }// imin<imax
+                  }// !RejetLigne
+                }// PW.NbPoints()>2
+              }// done is True
+            }// dminiPointLigne > SeuildPointLigne
+          }// Abs || Abs
+        }// HasStartPoint
       } while(nbp>5 && NombreDePointsDeDepartDuCheminement<3);
     }// for( ls ...
   }// nbLigSec>=1
@@ -798,159 +798,159 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
 
       HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);    
       if(HasStartPoint) { 
-       StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
-       if(Abs(pu1-pu2)>1e-7 || Abs(pv1-pv2)>1e-7) { 
-         NbLigCalculee = SLin.Length();
-         dminiPointLigne = SeuildPointLigne + SeuildPointLigne; 
-         Standard_Integer l;
-         for( l = 1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) { 
-           const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l));
-           if( (testwline->IsOutSurf1Box(gp_Pnt2d(pu1,pv1))==Standard_False) &&
-               (testwline->IsOutSurf2Box(gp_Pnt2d(pu2,pv2))==Standard_False) &&
-               (testwline->IsOutBox(StartPOn2S.Value())==Standard_False) ) { 
-             NbPntOn2SOnLine = testwline->NbPnts();
-             Standard_Integer ll;
-             for( ll = 1; (ll < NbPntOn2SOnLine) && (dminiPointLigne >= SeuildPointLigne); ll++) { 
-               Standard_Real t,Au1,Av1,Au2,Av2,Bu1,Bv1,Bu2,Bv2;
-               testwline->Point(ll).Parameters(Au1,Av1,Au2,Av2);
-               testwline->Point(ll+1).Parameters(Bu1,Bv1,Bu2,Bv2);
-               if(Au1>Bu1) {
-                 t=Au1;
-                 Au1=Bu1;
-                 Bu1=t;
-               } 
-               if(Av1>Bv1) {
-                 t=Av1;
-                 Av1=Bv1;
-                 Bv1=t;
-               } 
-               Au1-=1.0e-7;
-               Av1-=1.0e-7;
-               Bu1+=1.0e-7;
-               Bv1+=1.0e-7;
-               if((pu1>=Au1) && (pu1<=Bu1) && (pv1>=Av1) && (pv1<=Bv1))
-                 dminiPointLigne = 0.0; 
-               else { 
-                 if((pu2>=Au1) && (pu2<=Bu1) && (pv2>=Av1) && (pv2<=Bv1))
-                   dminiPointLigne = 0.0;
-               }
-             }// for( ll ...
-           }// if ...
-         }// for( l ...
-           
-         if(dminiPointLigne > SeuildPointLigne) { 
-           PW.Perform(StartParams);
-           if(PW.IsDone()) {
-             if(PW.NbPoints()>2) { 
-               RejetLigne = Standard_False;
-               Point3dDebut = PW.Value(1).Value();
-               Point3dFin   = PW.Value(PW.NbPoints()).Value();
-               for( ver = 1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
-                 const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
-                 const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
-                 const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts());
-                 if(Point3dDebut.Distance(verPointDebut.Value()) < TolTangency)
-                   RejetLigne = Standard_True; 
-                 else { 
-                   if(Point3dFin.Distance(verPointFin.Value()) < TolTangency)
-                     RejetLigne = Standard_True; 
-                 }
-               }
-                 
-               if(!RejetLigne) { 
-                 IntSurf_TypeTrans trans1,trans2;
-                 Standard_Real locu,locv;
-                 gp_Vec norm1,norm2,d1u,d1v;
-                 gp_Pnt ptbid;
-                 Standard_Integer indextg;
-                 gp_Vec tgline(PW.TangentAtLine(indextg));
-                 PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
-                 Surf1->D1(locu,locv,ptbid,d1u,d1v);
-                 norm1 = d1u.Crossed(d1v);
-                 PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
-                 Surf1->D1(locu,locv,ptbid,d1u,d1v);
-                 norm2 = d1u.Crossed(d1v);
-                 if(tgline.DotCross(norm2,norm1)>0.) {
-                   trans1 = IntSurf_Out;
-                   trans2 = IntSurf_In;
-                 }
-                 else {
-                   trans1 = IntSurf_In;
-                   trans2 = IntSurf_Out;
-                 }
-
-                 IntSurf_LineOn2S LineOn2S;
-                 Standard_Integer nbp,imin,imax,i;
-                 nbp = PW.Line()->NbPoints();
-                 Standard_Real u1,v1,u2,v2;
-                 i=0;
-                 do { 
-                   i++;
-                   imin=i;
-                   const IntSurf_PntOn2S& Pi   = PW.Line()->Value(i);
-                   Pi.Parameters(u1,v1,u2,v2);
-                 } while((i<nbp)&&(Abs(u1-u2)<=1e-6 && Abs(v1-v2)<=1e-6));
-
-                 if(imin>2)
-                   imin--;
-                                 
-                 i=nbp+1;
-                 do { 
-                   i--;
-                   imax=i;
-                   const IntSurf_PntOn2S& Pi   = PW.Line()->Value(i);
-                   Pi.Parameters(u1,v1,u2,v2);
-                 } while((i>2)&&(Abs(u1-u2)<=1e-6 && Abs(v1-v2)<=1e-6));
-
-                 if(imax<nbp)
-                   imax++;
-
-                 if(imin<imax) { 
-                   Handle_IntSurf_LineOn2S PWLine = new IntSurf_LineOn2S();
-                   for(i=imin;i<=imax;i++)
-                     PWLine->Add(PW.Line()->Value(i));
-                                     
-                   Standard_Real TolTang = TolTangency;
-                   Handle(IntPatch_WLine) wline = new IntPatch_WLine(PWLine,Standard_False,trans1,trans2);
-                   const IntSurf_PntOn2S& POn2SDeb = wline->Point(1);
-                   const IntSurf_PntOn2S& POn2SFin = wline->Point(wline->NbPnts());
-                   if((POn2SDeb.Value()).Distance(POn2SFin.Value()) <= TolTangency) { 
-                     Standard_Real u1t,v1t,u2t,v2t; 
-                     POn2SDeb.Parameters(u1t,v1t,u2t,v2t);
-                     IntPatch_Point vtx;
-                     vtx.SetValue(POn2SDeb.Value(),TolTang,Standard_False);
-                     vtx.SetParameters(u2t,v2t,u1t,v1t);
-                     vtx.SetParameter(wline->NbPnts());
-                     wline->SetPoint(wline->NbPnts(),vtx);
-                   }
-
-                   IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf1,Standard_True,TolTang);
-
-                   if(wline->NbVertex() == 0) {
-                     IntPatch_Point vtx;
-                     IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
-                     POn2S.Parameters(pu1,pv1,pu2,pv2);
-                     vtx.SetValue(Point3dDebut,TolTang,Standard_False);
-                     vtx.SetParameters(pu1,pv1,pu2,pv2);
-                     vtx.SetParameter(1);
-                     wline->AddVertex(vtx);
-                       
-                     POn2S = PW.Line()->Value(wline->NbPnts());
-                     POn2S.Parameters(pu1,pv1,pu2,pv2);
-                     vtx.SetValue(Point3dFin,TolTang,Standard_False);
-                     vtx.SetParameters(pu1,pv1,pu2,pv2);
-                     vtx.SetParameter(wline->NbPnts());
-                     wline->AddVertex(vtx);
-                   }
-
-                   SLin.Append(wline);
-                   empt = Standard_False;
-                 }// imin<imax
-               }// !RejetLigne
-             }// PW.NbPoints()>2
-           }// done a True
-         }// dminiPointLigne > SeuildPointLigne
-       }// Abs || Abs
+        StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
+        if(Abs(pu1-pu2)>1e-7 || Abs(pv1-pv2)>1e-7) { 
+          NbLigCalculee = SLin.Length();
+          dminiPointLigne = SeuildPointLigne + SeuildPointLigne; 
+          Standard_Integer l;
+          for( l = 1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) { 
+            const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l));
+            if( (testwline->IsOutSurf1Box(gp_Pnt2d(pu1,pv1))==Standard_False) &&
+              (testwline->IsOutSurf2Box(gp_Pnt2d(pu2,pv2))==Standard_False) &&
+              (testwline->IsOutBox(StartPOn2S.Value())==Standard_False) ) { 
+                NbPntOn2SOnLine = testwline->NbPnts();
+                Standard_Integer ll;
+                for( ll = 1; (ll < NbPntOn2SOnLine) && (dminiPointLigne >= SeuildPointLigne); ll++) { 
+                  Standard_Real t,Au1,Av1,Au2,Av2,Bu1,Bv1,Bu2,Bv2;
+                  testwline->Point(ll).Parameters(Au1,Av1,Au2,Av2);
+                  testwline->Point(ll+1).Parameters(Bu1,Bv1,Bu2,Bv2);
+                  if(Au1>Bu1) {
+                    t=Au1;
+                    Au1=Bu1;
+                    Bu1=t;
+                  
+                  if(Av1>Bv1) {
+                    t=Av1;
+                    Av1=Bv1;
+                    Bv1=t;
+                  
+                  Au1-=1.0e-7;
+                  Av1-=1.0e-7;
+                  Bu1+=1.0e-7;
+                  Bv1+=1.0e-7;
+                  if((pu1>=Au1) && (pu1<=Bu1) && (pv1>=Av1) && (pv1<=Bv1))
+                    dminiPointLigne = 0.0; 
+                  else { 
+                    if((pu2>=Au1) && (pu2<=Bu1) && (pv2>=Av1) && (pv2<=Bv1))
+                      dminiPointLigne = 0.0;
+                  }
+                }// for( ll ...
+            }// if ...
+          }// for( l ...
+
+          if(dminiPointLigne > SeuildPointLigne) { 
+            PW.Perform(StartParams);
+            if(PW.IsDone()) {
+              if(PW.NbPoints()>2) { 
+                RejetLigne = Standard_False;
+                Point3dDebut = PW.Value(1).Value();
+                Point3dFin   = PW.Value(PW.NbPoints()).Value();
+                for( ver = 1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
+                  const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
+                  const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
+                  const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts());
+                  if(Point3dDebut.Distance(verPointDebut.Value()) < TolTangency)
+                    RejetLigne = Standard_True; 
+                  else { 
+                    if(Point3dFin.Distance(verPointFin.Value()) < TolTangency)
+                      RejetLigne = Standard_True; 
+                  }
+                }
+
+                if(!RejetLigne)        { 
+                  IntSurf_TypeTrans trans1,trans2;
+                  Standard_Real locu,locv;
+                  gp_Vec norm1,norm2,d1u,d1v;
+                  gp_Pnt ptbid;
+                  Standard_Integer indextg;
+                  gp_Vec tgline(PW.TangentAtLine(indextg));
+                  PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
+                  Surf1->D1(locu,locv,ptbid,d1u,d1v);
+                  norm1 = d1u.Crossed(d1v);
+                  PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
+                  Surf1->D1(locu,locv,ptbid,d1u,d1v);
+                  norm2 = d1u.Crossed(d1v);
+                  if(tgline.DotCross(norm2,norm1)>0.) {
+                    trans1 = IntSurf_Out;
+                    trans2 = IntSurf_In;
+                  }
+                  else {
+                    trans1 = IntSurf_In;
+                    trans2 = IntSurf_Out;
+                  }
+
+                  IntSurf_LineOn2S LineOn2S;
+                  Standard_Integer nbp,imin,imax,i;
+                  nbp = PW.Line()->NbPoints();
+                  Standard_Real u1,v1,u2,v2;
+                  i=0;
+                  do { 
+                    i++;
+                    imin=i;
+                    const IntSurf_PntOn2S& Pi   = PW.Line()->Value(i);
+                    Pi.Parameters(u1,v1,u2,v2);
+                  } while((i<nbp)&&(Abs(u1-u2)<=1e-6 && Abs(v1-v2)<=1e-6));
+
+                  if(imin>2)
+                    imin--;
+
+                  i=nbp+1;
+                  do { 
+                    i--;
+                    imax=i;
+                    const IntSurf_PntOn2S& Pi   = PW.Line()->Value(i);
+                    Pi.Parameters(u1,v1,u2,v2);
+                  } while((i>2)&&(Abs(u1-u2)<=1e-6 && Abs(v1-v2)<=1e-6));
+
+                  if(imax<nbp)
+                    imax++;
+
+                  if(imin<imax) { 
+                    Handle_IntSurf_LineOn2S PWLine = new IntSurf_LineOn2S();
+                    for(i=imin;i<=imax;i++)
+                      PWLine->Add(PW.Line()->Value(i));
+
+                    Standard_Real TolTang = TolTangency;
+                    Handle(IntPatch_WLine) wline = new IntPatch_WLine(PWLine,Standard_False,trans1,trans2);
+                    const IntSurf_PntOn2S& POn2SDeb = wline->Point(1);
+                    const IntSurf_PntOn2S& POn2SFin = wline->Point(wline->NbPnts());
+                    if((POn2SDeb.Value()).Distance(POn2SFin.Value()) <= TolTangency) { 
+                      Standard_Real u1t,v1t,u2t,v2t; 
+                      POn2SDeb.Parameters(u1t,v1t,u2t,v2t);
+                      IntPatch_Point vtx;
+                      vtx.SetValue(POn2SDeb.Value(),TolTang,Standard_False);
+                      vtx.SetParameters(u2t,v2t,u1t,v1t);
+                      vtx.SetParameter(wline->NbPnts());
+                      wline->SetPoint(wline->NbPnts(),vtx);
+                    }
+
+                    IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf1,Standard_True,TolTang);
+
+                    if(wline->NbVertex() == 0) {
+                      IntPatch_Point vtx;
+                      IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
+                      POn2S.Parameters(pu1,pv1,pu2,pv2);
+                      vtx.SetValue(Point3dDebut,TolTang,Standard_False);
+                      vtx.SetParameters(pu1,pv1,pu2,pv2);
+                      vtx.SetParameter(1);
+                      wline->AddVertex(vtx);
+
+                      POn2S = PW.Line()->Value(wline->NbPnts());
+                      POn2S.Parameters(pu1,pv1,pu2,pv2);
+                      vtx.SetValue(Point3dFin,TolTang,Standard_False);
+                      vtx.SetParameters(pu1,pv1,pu2,pv2);
+                      vtx.SetParameter(wline->NbPnts());
+                      wline->AddVertex(vtx);
+                    }
+
+                    SLin.Append(wline);
+                    empt = Standard_False;
+                  }// imin<imax
+                }// !RejetLigne
+              }// PW.NbPoints()>2
+            }// done a True
+          }// dminiPointLigne > SeuildPointLigne
+        }// Abs || Abs
       }// HasStartPoint
     }// for ( pz ...
   }// for( z ...
@@ -961,11 +961,11 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
 // purpose  : 
 //==================================================================================
 Handle_IntPatch_Line IntPatch_PrmPrmIntersection::NewLine (const Handle(Adaptor3d_HSurface)&    Surf1,
-                                                          const Handle(Adaptor3d_HSurface)&    Surf2,
-                                                          const Standard_Integer NumLine,
-                                                          const Standard_Integer Low,
-                                                          const Standard_Integer High,
-                                                          const Standard_Integer NbPntsToInsert) const 
+                                                           const Handle(Adaptor3d_HSurface)&    Surf2,
+                                                           const Standard_Integer NumLine,
+                                                           const Standard_Integer Low,
+                                                           const Standard_Integer High,
+                                                           const Standard_Integer NbPntsToInsert) const 
 { 
   Standard_Integer NbPnts = NbPntsToInsert + High - Low;
   if(NumLine>NbLines() || NumLine<1  || Low>=High ) 
@@ -995,70 +995,70 @@ Handle_IntPatch_Line IntPatch_PrmPrmIntersection::NewLine (const Handle(Adaptor3
   U2(Low) = u2;
   V2(Low) = v2;
   AC(Low) =0.0;
-  
+
   IntPatch_ThePWalkingInter PW(Surf1,Surf2,0.000001,0.000001,0.001,0.001);
-  
+
   Standard_Integer i;
   for(i=Low+1; i<=High; i++)
-    {
-      const IntSurf_PntOn2S& Pointi=TheLine->Point(i);
-      Pointi.Parameters(u1,v1,u2,v2);
-      U1(i) = u1;
-      V1(i) = v1;
-      U2(i) = u2;
-      V2(i) = v2;
-    
-      Standard_Real du1=u1-U1(i-1);
-      Standard_Real dv1=v1-V1(i-1);
-    
-      AC(i) = AC(i-1) + Sqrt((du1*du1)+(dv1*dv1));
-    }
+  {
+    const IntSurf_PntOn2S& Pointi=TheLine->Point(i);
+    Pointi.Parameters(u1,v1,u2,v2);
+    U1(i) = u1;
+    V1(i) = v1;
+    U2(i) = u2;
+    V2(i) = v2;
+
+    Standard_Real du1=u1-U1(i-1);
+    Standard_Real dv1=v1-V1(i-1);
+
+    AC(i) = AC(i-1) + Sqrt((du1*du1)+(dv1*dv1));
+  }
 
   Handle(IntSurf_LineOn2S) ResultPntOn2SLine = new IntSurf_LineOn2S();
-  
+
   IntSurf_PntOn2S StartPOn2S;  
   TColStd_Array1OfReal StartParams(1,4);
-  
+
   ResultPntOn2SLine->Add(TheLine->Point(Low));
-  
+
   ds = AC(High) / (NbPnts-1);
   Standard_Integer Indice = Low;
-  
+
   Standard_Real dsmin = ds*0.3;
   Standard_Real smax  = AC(High);
 
   for(i=2,s=ds; (i<NbPnts)&&(s<smax); i++,s+=ds)
+  { 
+    while(AC(Indice+1) <= s)
     { 
-      while(AC(Indice+1) <= s)
-       { 
-         ResultPntOn2SLine->Add(TheLine->Point(Indice));
-         Indice++;
-       }
-      Standard_Real a = s - AC(Indice);
-      Standard_Real b = AC(Indice+1) - s;
-      Standard_Real nab = 1.0/(a+b);
-      //----------------------------------------------------------
-      //-- Verification :  Si Dist au prochain  point < dsmin   --
-      //--                 Si Dist au precedent point < dsmin   --
-      //--                                                      --
-      //----------------------------------------------------------
-      if((nab > ds)&&(a>dsmin)&&(b>dsmin))
-       {
-         StartParams(1) = (U1(Indice) * b   +  U1(Indice+1) * a) * nab;
-         StartParams(2) = (V1(Indice) * b   +  V1(Indice+1) * a) * nab;
-         StartParams(3) = (U2(Indice) * b   +  U2(Indice+1) * a) * nab;
-         StartParams(4) = (V2(Indice) * b   +  V2(Indice+1) * a) * nab;
-      
-         Standard_Boolean HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);
-         if(HasStartPoint)
-           ResultPntOn2SLine->Add(StartPOn2S);
-       }
-      else
-       s+=dsmin; 
+      ResultPntOn2SLine->Add(TheLine->Point(Indice));
+      Indice++;
+    }
+    Standard_Real a = s - AC(Indice);
+    Standard_Real b = AC(Indice+1) - s;
+    Standard_Real nab = 1.0/(a+b);
+    //----------------------------------------------------------
+    //-- Verification :  Si Dist au prochain  point < dsmin   --
+    //--                 Si Dist au precedent point < dsmin   --
+    //--                                                      --
+    //----------------------------------------------------------
+    if((nab > ds)&&(a>dsmin)&&(b>dsmin))
+    {
+      StartParams(1) = (U1(Indice) * b   +  U1(Indice+1) * a) * nab;
+      StartParams(2) = (V1(Indice) * b   +  V1(Indice+1) * a) * nab;
+      StartParams(3) = (U2(Indice) * b   +  U2(Indice+1) * a) * nab;
+      StartParams(4) = (V2(Indice) * b   +  V2(Indice+1) * a) * nab;
+
+      Standard_Boolean HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);
+      if(HasStartPoint)
+        ResultPntOn2SLine->Add(StartPOn2S);
     }
-  
+    else
+      s+=dsmin; 
+  }
+
   ResultPntOn2SLine->Add(TheLine->Point(High));
-  
+
   return(new IntPatch_WLine(ResultPntOn2SLine,Standard_False));
 }
 
@@ -1067,20 +1067,20 @@ Handle_IntPatch_Line IntPatch_PrmPrmIntersection::NewLine (const Handle(Adaptor3
 // purpose  : 
 //==================================================================================
 void SectionPointToParameters(const Intf_SectionPoint& Sp,
-                             const IntPatch_Polyhedron& Poly1,
-                             const IntPatch_Polyhedron& Poly2,
-                             Standard_Real& u1,
-                             Standard_Real& v1,
-                             Standard_Real& u2,
-                             Standard_Real& v2)
+                              const IntPatch_Polyhedron& Poly1,
+                              const IntPatch_Polyhedron& Poly2,
+                              Standard_Real& u1,
+                              Standard_Real& v1,
+                              Standard_Real& u2,
+                              Standard_Real& v2)
 {
   Intf_PIType       typ;
   Standard_Integer  Adr1,Adr2;
   Standard_Real     Param,u,v;
   gp_Pnt P(Sp.Pnt());
-  
+
   Standard_Integer Pt1,Pt2,Pt3;
-  
+
   Sp.InfoFirst(typ,Adr1,Adr2,Param);
   switch(typ) { 
   case Intf_VERTEX:   //-- Adr1 est le numero du vertex
@@ -1111,9 +1111,9 @@ void SectionPointToParameters(const Intf_SectionPoint& Sp,
       ca = (gp_Vec(PB,PC).Crossed(gp_Vec(PB,P))).Dot(Normale);
       cb = (gp_Vec(PC,PA).Crossed(gp_Vec(PC,P))).Dot(Normale);
       cabc = ca + cb + cc;
-      
+
       ca/=cabc;     cb/=cabc;       cc/=cabc;
-      
+
       u1 = ca * ua + cb * ub + cc * uc;
       v1 = ca * va + cb * vb + cc * vc;
       break;
@@ -1124,8 +1124,8 @@ void SectionPointToParameters(const Intf_SectionPoint& Sp,
       break;
     }
   }
-  
-  
+
+
   Sp.InfoSecond(typ,Adr1,Adr2,Param);
   switch(typ) { 
   case Intf_VERTEX:   //-- Adr1 est le numero du vertex
@@ -1156,9 +1156,9 @@ void SectionPointToParameters(const Intf_SectionPoint& Sp,
       ca = (gp_Vec(PB,PC).Crossed(gp_Vec(PB,P))).Dot(Normale);
       cb = (gp_Vec(PC,PA).Crossed(gp_Vec(PC,P))).Dot(Normale);
       cabc = ca + cb + cc;
-      
+
       ca/=cabc;     cb/=cabc;       cc/=cabc;
-      
+
       u2 = ca * ua + cb * ub + cc * uc;
       v2 = ca * va + cb * vb + cc * vc;
       break;
@@ -1176,12 +1176,12 @@ void SectionPointToParameters(const Intf_SectionPoint& Sp,
 // purpose  : 
 //==================================================================================
 void IntPatch_PrmPrmIntersection::RemplitLin(const Standard_Integer x1,
-                                            const Standard_Integer y1,
-                                            const Standard_Integer z1,
-                                            const Standard_Integer x2,
-                                            const Standard_Integer y2,
-                                            const Standard_Integer z2,
-                                            IntPatch_PrmPrmIntersection_T3Bits& Map) const 
+                                             const Standard_Integer y1,
+                                             const Standard_Integer z1,
+                                             const Standard_Integer x2,
+                                             const Standard_Integer y2,
+                                             const Standard_Integer z2,
+                                             IntPatch_PrmPrmIntersection_T3Bits& Map) const 
 {
   int xg,yg,zg;
   xg=x1-x2; if(xg<0) xg=-xg; 
@@ -1204,15 +1204,15 @@ void IntPatch_PrmPrmIntersection::RemplitLin(const Standard_Integer x1,
 // purpose  : 
 //==================================================================================
 void IntPatch_PrmPrmIntersection::RemplitTri(const Standard_Integer x1,
-                                            const Standard_Integer y1,
-                                            const Standard_Integer z1,
-                                            const Standard_Integer x2,
-                                            const Standard_Integer y2,
-                                            const Standard_Integer z2,
-                                            const Standard_Integer x3,
-                                            const Standard_Integer y3,
-                                            const Standard_Integer z3,
-                                            IntPatch_PrmPrmIntersection_T3Bits& Map) const 
+                                             const Standard_Integer y1,
+                                             const Standard_Integer z1,
+                                             const Standard_Integer x2,
+                                             const Standard_Integer y2,
+                                             const Standard_Integer z2,
+                                             const Standard_Integer x3,
+                                             const Standard_Integer y3,
+                                             const Standard_Integer z3,
+                                             IntPatch_PrmPrmIntersection_T3Bits& Map) const 
 { 
   if(x1==x2 && x1==x3 && y1==y2 && y1==y3 && z1==z2 && z1==z3) {
     if(DansGrille(x1) && DansGrille(y1) && DansGrille(z1)) { 
@@ -1255,15 +1255,15 @@ void IntPatch_PrmPrmIntersection::RemplitTri(const Standard_Integer x1,
 // purpose  : 
 //==================================================================================
 void IntPatch_PrmPrmIntersection::Remplit(const Standard_Integer a,
-                                         const Standard_Integer b,
-                                         const Standard_Integer c,
-                                         IntPatch_PrmPrmIntersection_T3Bits& Map) const 
+                                          const Standard_Integer b,
+                                          const Standard_Integer c,
+                                          IntPatch_PrmPrmIntersection_T3Bits& Map) const 
 { 
   int iax,iay,iaz,ibx,iby,ibz,icx,icy,icz;
   if(a!=-1) Map.Add(a);
   if(b!=-1) Map.Add(b);
   if(c!=-1) Map.Add(c);
-  
+
   if(a!=-1 && b!=-1 && c!=-1 ) { 
     IntegerGrille(a,iax,iay,iaz);
     IntegerGrille(b,ibx,iby,ibz);
@@ -1279,13 +1279,13 @@ void IntPatch_PrmPrmIntersection::Remplit(const Standard_Integer a,
 //purpose  : 
 //=======================================================================
 void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&    Surf1,
-                                          const Handle(Adaptor3d_TopolTool)& D1,
-                                          const Handle(Adaptor3d_HSurface)&    Surf2,
-                                          const Handle(Adaptor3d_TopolTool)& D2,
-                                          const Standard_Real   TolTangency,
-                                          const Standard_Real   Epsilon,
-                                          const Standard_Real   Deflection,
-                                          const Standard_Real   Increment,
+                                           const Handle(Adaptor3d_TopolTool)& D1,
+                                           const Handle(Adaptor3d_HSurface)&    Surf2,
+                                           const Handle(Adaptor3d_TopolTool)& D2,
+                                           const Standard_Real   TolTangency,
+                                           const Standard_Real   Epsilon,
+                                           const Standard_Real   Deflection,
+                                           const Standard_Real   Increment,
                                            IntSurf_ListOfPntOn2S& LOfPnts,
                                            const Standard_Boolean RestrictLine)
 {
@@ -1293,14 +1293,14 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
     done = Standard_True;
     return;
   }
-    
+
   empt = Standard_True;
   SLin.Clear();  
-  
+
   Standard_Real UminLig1,VminLig1,UmaxLig1,VmaxLig1;
   Standard_Real UminLig2,VminLig2,UmaxLig2,VmaxLig2;
   Standard_Real U1,U2,V1,V2;
-  
+
   UminLig1 = Surf1->FirstUParameter();
   VminLig1 = Surf1->FirstVParameter();
   UmaxLig1 = Surf1->LastUParameter();
@@ -1315,7 +1315,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
   Periods[1] = (Surf1->IsVPeriodic())? Surf1->VPeriod() : 0.;
   Periods[2] = (Surf2->IsUPeriodic())? Surf2->UPeriod() : 0.;
   Periods[3] = (Surf2->IsVPeriodic())? Surf2->VPeriod() : 0.;
-  
+
   IntSurf_ListIteratorOfListOfPntOn2S IterLOP1(LOfPnts);
 
   for(; IterLOP1.More(); IterLOP1.Next()){
@@ -1325,15 +1325,15 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
     if(V1>VmaxLig1) VmaxLig1=V1;
     if(U2>UmaxLig2) UmaxLig2=U2;
     if(V2>VmaxLig2) VmaxLig2=V2;
-    
+
     if(U1<UminLig1) UminLig1=U1;
     if(V1<VminLig1) VminLig1=V1;
     if(U2<UminLig2) UminLig2=U2;
     if(V2<VminLig2) VminLig2=V2; 
   }
-  
+
   Standard_Real SeuildPointLigne = 15.0 * Increment * Increment;
-  
+
   Standard_Integer NbLigCalculee = 0, ver;
   Standard_Real pu1,pu2,pv1,pv2, dminiPointLigne;
   Standard_Boolean HasStartPoint,RejetLigne;
@@ -1342,18 +1342,18 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
 
   TColStd_Array1OfReal StartParams(1,4);
   IntPatch_ThePWalkingInter PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,Increment);  
-    
+
   IntSurf_ListIteratorOfListOfPntOn2S IterLOP2(LOfPnts);
   for(; IterLOP2.More(); IterLOP2.Next() ){
-    
+
     IntSurf_PntOn2S cPnt = IterLOP2.Value();
     cPnt.Parameters(U1, V1, U2, V2);
-    
+
     StartParams(1) = U1;
     StartParams(2) = V1;
     StartParams(3) = U2;
     StartParams(4) = V2;
-    
+
     HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);
     dminiPointLigne = SeuildPointLigne + SeuildPointLigne;
     if(HasStartPoint) {
@@ -1367,11 +1367,15 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
           dminiPointLigne = 0.0;
         }
       }// for( l ...
-      
+
       if(dminiPointLigne > SeuildPointLigne) {
         PW.Perform(StartParams,UminLig1,VminLig1,UminLig2,VminLig2,UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2);
         if(PW.IsDone())        {
-          if(PW.NbPoints()>2) {
+          if(PW.NbPoints()>2)
+          {
+            //Try to extend the intersection line to boundary, if it is possibly
+            Standard_Boolean hasBeenAdded = PW.PutToBoundary(Surf1, Surf2);
+
             RejetLigne = Standard_False;
             Point3dDebut = PW.Value(1).Value();
             const IntSurf_PntOn2S& PointFin = PW.Value(PW.NbPoints());
@@ -1393,7 +1397,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                   RejetLigne = Standard_True; 
               }
             }
-            
+
             if(!RejetLigne) {
               IntSurf_TypeTrans trans1,trans2;
               Standard_Real locu,locv;
@@ -1415,14 +1419,14 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                 trans1 = IntSurf_In;
                 trans2 = IntSurf_Out;
               }
-              
+
               Standard_Real TolTang = TolTangency;
               Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
               if (RestrictLine){
-                IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
-                IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+                IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang,hasBeenAdded);
+                IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang,hasBeenAdded);
               }
-              
+
               if(wline->NbVertex() == 0) {
                 IntPatch_Point vtx;
                 IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
@@ -1431,7 +1435,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                 vtx.SetParameters(pu1,pv1,pu2,pv2);
                 vtx.SetParameter(1);
                 wline->AddVertex(vtx);
-                
+
                 POn2S = PW.Line()->Value(wline->NbPnts());
                 POn2S.Parameters(pu1,pv1,pu2,pv2);
                 vtx.SetValue(Point3dFin,TolTang,Standard_False);
@@ -1476,7 +1480,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                       }
                     }
                   }
-                  
+
                   if( VDMin != 0 ) {
                     const Handle(IntPatch_Line)& aSLine = SLin.Value(WLDMin);
                     const Handle(IntPatch_WLine)&  aWLine = (*((Handle(IntPatch_WLine)*)&aSLine));
@@ -1486,11 +1490,11 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                     Standard_Real u21 = 0., u22 = 0., v21 = 0., v22 = 0.;
                     wline->Point(ciVpar).Parameters(u11,v11,u12,v12);
                     aWLine->Point(tiVpar).Parameters(u21,v21,u22,v22);
-                    
+
                     Handle(IntSurf_LineOn2S) newL2s = new IntSurf_LineOn2S();
                     IntSurf_PntOn2S replacePnt = aWLine->Point(tiVpar);
                     Standard_Integer cNbP = wline->NbPnts();
-                    
+
                     TColStd_SequenceOfInteger VPold;
                     Standard_Integer iPo;
                     for( iPo = 1; iPo <= cnbV; iPo++ ) {
@@ -1498,16 +1502,16 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                       Standard_Integer IPo = (Standard_Integer) Po;
                       VPold.Append(IPo);
                     }
-                    
+
                     Standard_Boolean removeNext = Standard_False;
                     Standard_Boolean removePrev = Standard_False;
                     if( ciV == 1) {
                       Standard_Integer dPar = Abs( VPold.Value(ciV) - VPold.Value(ciV+1));
                       if(dPar > 10) {
-                               removeNext = Standard_True;
-                               for( iPo = (ciV+1); iPo <= cnbV; iPo++ )
-                                 VPold.SetValue(iPo, VPold.Value(iPo) - 1 );
-                             }
+                        removeNext = Standard_True;
+                        for( iPo = (ciV+1); iPo <= cnbV; iPo++ )
+                          VPold.SetValue(iPo, VPold.Value(iPo) - 1 );
+                      }
                     }
                     else if( ciV == cnbV) {
                       Standard_Integer dPar = Abs( VPold.Value(ciV) - VPold.Value(ciV-1));
@@ -1539,7 +1543,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                       } 
                     }
                     Standard_Integer pI = (Standard_Integer) ciVpar;
-                    
+
                     Standard_Integer iP;
                     for( iP = 1; iP <= cNbP; iP++) {
                       if( pI == iP )
@@ -1554,15 +1558,15 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                       else
                         newL2s->Add(wline->Point(iP));
                     }
-                    
+
                     IntPatch_Point newVtx;
                     gp_Pnt Pnt3dV = aWLine->Vertex(VDMin).Value();
                     newVtx.SetValue(Pnt3dV,TolTang,Standard_False);
                     newVtx.SetParameters(u21,v21,u22,v22);
                     newVtx.SetParameter(VPold.Value(ciV));
-                    
+
                     Handle(IntPatch_WLine) NWLine = new IntPatch_WLine(newL2s,Standard_False,trans1,trans2);
-                    
+
                     Standard_Integer iV;
                     for( iV = 1; iV <= cnbV; iV++ ) {
                       if( iV == ciV )
@@ -1573,12 +1577,12 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                         NWLine->AddVertex(theVtx);
                       }
                     }
-                    
+
                     wline = NWLine;
                   }
                 }
               }// SLin.Length > 0
-              
+
               AddWLine(SLin, wline, Deflection);
               empt = Standard_False;
             }// !RejetLigne
@@ -1595,75 +1599,73 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
 //purpose  : 
 //=======================================================================
 void IntPatch_PrmPrmIntersection::Perform(const Handle(Adaptor3d_HSurface)&    Surf1,
-                                         const Handle(Adaptor3d_TopolTool)& D1,
-                                         const Handle(Adaptor3d_HSurface)&    Surf2,
-                                         const Handle(Adaptor3d_TopolTool)& D2,
-                                         const Standard_Real   U1Depart,
-                                         const Standard_Real   V1Depart,
-                                         const Standard_Real   U2Depart,
-                                         const Standard_Real   V2Depart,
-                                         const Standard_Real   TolTangency,
-                                         const Standard_Real   Epsilon,
-                                         const Standard_Real   Deflection,
-                                         const Standard_Real   Increment) { 
-  
-  
-  
-//    Standard_Integer NbU1 = D1->NbSamplesU();
-//    Standard_Integer NbV1 = D1->NbSamplesV();
-//    Standard_Integer NbU2 = D2->NbSamplesU();
-//    Standard_Integer NbV2 = D2->NbSamplesV();
+                                          const Handle(Adaptor3d_TopolTool)& D1,
+                                          const Handle(Adaptor3d_HSurface)&    Surf2,
+                                          const Handle(Adaptor3d_TopolTool)& D2,
+                                          const Standard_Real   U1Depart,
+                                          const Standard_Real   V1Depart,
+                                          const Standard_Real   U2Depart,
+                                          const Standard_Real   V2Depart,
+                                          const Standard_Real   TolTangency,
+                                          const Standard_Real   Epsilon,
+                                          const Standard_Real   Deflection,
+                                          const Standard_Real   Increment)
+{
+  //    Standard_Integer NbU1 = D1->NbSamplesU();
+  //    Standard_Integer NbV1 = D1->NbSamplesV();
+  //    Standard_Integer NbU2 = D2->NbSamplesU();
+  //    Standard_Integer NbV2 = D2->NbSamplesV();
 
   //-- Traitement des Lignes de sections
   empt = Standard_True;
   done = Standard_True;
   SLin.Clear();  
-  
+
   //------------------------------------------------------------
 
   Standard_Real pu1,pu2,pv1,pv2;
-  
+
   TColStd_Array1OfReal StartParams(1,4);
-  
-//    Standard_Integer MaxOscill = NbU1;
-//    if(MaxOscill < NbU2) MaxOscill=NbU2;
-//    if(MaxOscill < NbV1) MaxOscill=NbV1;
-//    if(MaxOscill < NbV2) MaxOscill=NbV2;
-  
-//    Standard_Real nIncrement=Increment;
-//    if(MaxOscill>10) { 
-//  #ifdef DEB 
-//      cout<<"\n IntPatch_PrmPrmIntersection.gxx : Increment:"<<Increment<<" -> "<<Increment/(0.5*MaxOscill)<<endl;
-//  #endif
-//      nIncrement/=0.5*MaxOscill;
-//    }
-  
+
+  //    Standard_Integer MaxOscill = NbU1;
+  //    if(MaxOscill < NbU2) MaxOscill=NbU2;
+  //    if(MaxOscill < NbV1) MaxOscill=NbV1;
+  //    if(MaxOscill < NbV2) MaxOscill=NbV2;
+
+  //    Standard_Real nIncrement=Increment;
+  //    if(MaxOscill>10) { 
+  //  #ifdef DEB 
+  //      cout<<"\n IntPatch_PrmPrmIntersection.gxx : Increment:"<<Increment<<" -> "<<Increment/(0.5*MaxOscill)<<endl;
+  //  #endif
+  //      nIncrement/=0.5*MaxOscill;
+  //    }
+
   IntPatch_ThePWalkingInter PW(Surf1,Surf2,
-                              TolTangency,
-                              Epsilon,
-                              Deflection,
-                              Increment); //nIncrement);
-  
-  
+    TolTangency,
+    Epsilon,
+    Deflection,
+    Increment); //nIncrement);
+
+
   //Standard_Real    SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant
   //Standard_Real    incidence;
   //Standard_Real    dminiPointLigne;
-  
+
   Standard_Boolean HasStartPoint;//,RejetLigne;
-  
+
   IntSurf_PntOn2S StartPOn2S;
-  
+
   //Standard_Integer ver;
-  
+
   gp_Pnt Point3dDebut,Point3dFin;
-  
+
   //------------------------------------------------------------
-  
+
   StartParams(1) = U1Depart;
   StartParams(2) = V1Depart;
   StartParams(3) = U2Depart;
   StartParams(4) = V2Depart;
-  
+
   //-----------------------------------------------------------------------
   //-- Calcul du premier point de cheminement a partir du point approche --
   //-----------------------------------------------------------------------
@@ -1674,10 +1676,10 @@ void IntPatch_PrmPrmIntersection::Perform(const Handle(Adaptor3d_HSurface)&    S
     //-- On verifie qu il n appartient pas           --
     //--  a une ligne de cheminement deja calculee.  --
     //-------------------------------------------------
-    
+
     PW.Perform(StartParams);
     if(PW.IsDone()) {
-      
+
       Point3dDebut = PW.Value(1).Value();
       Point3dFin   = PW.Value(PW.NbPoints()).Value();
 
@@ -1694,43 +1696,43 @@ void IntPatch_PrmPrmIntersection::Perform(const Handle(Adaptor3d_HSurface)&    S
       Surf2->D1(locu,locv,ptbid,d1u,d1v);
       norm2 = d1u.Crossed(d1v);
       if (tgline.DotCross(norm2,norm1)>0.) {
-       trans1 = IntSurf_Out;
-       trans2 = IntSurf_In;
+        trans1 = IntSurf_Out;
+        trans2 = IntSurf_In;
       }
       else {
-       trans1 = IntSurf_In;
-       trans2 = IntSurf_Out;
+        trans1 = IntSurf_In;
+        trans2 = IntSurf_Out;
       }
-      
-      
-      
+
+
+
       Standard_Real TolTang = TolTangency;
       Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
       IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
       IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
-      
+
       //---------------
       if(wline->NbVertex() == 0) {
-       IntPatch_Point vtx;
-       IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
-       POn2S.Parameters(pu1,pv1,pu2,pv2);
-       vtx.SetValue(Point3dDebut,TolTang,Standard_False);
-       vtx.SetParameters(pu1,pv1,pu2,pv2);
-       vtx.SetParameter(1);
-       wline->AddVertex(vtx);
-       
-       POn2S = PW.Line()->Value(wline->NbPnts());
-       POn2S.Parameters(pu1,pv1,pu2,pv2);
-       vtx.SetValue(Point3dFin,TolTang,Standard_False);
-       vtx.SetParameters(pu1,pv1,pu2,pv2);
-       vtx.SetParameter(wline->NbPnts());
-       wline->AddVertex(vtx);
+        IntPatch_Point vtx;
+        IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
+        POn2S.Parameters(pu1,pv1,pu2,pv2);
+        vtx.SetValue(Point3dDebut,TolTang,Standard_False);
+        vtx.SetParameters(pu1,pv1,pu2,pv2);
+        vtx.SetParameter(1);
+        wline->AddVertex(vtx);
+
+        POn2S = PW.Line()->Value(wline->NbPnts());
+        POn2S.Parameters(pu1,pv1,pu2,pv2);
+        vtx.SetValue(Point3dFin,TolTang,Standard_False);
+        vtx.SetParameters(pu1,pv1,pu2,pv2);
+        vtx.SetParameter(wline->NbPnts());
+        wline->AddVertex(vtx);
       }
-      
+
       //---------------
       SLin.Append(wline);
       empt = Standard_False;
-      
+
     }
   }
 }
@@ -1739,8 +1741,8 @@ void IntPatch_PrmPrmIntersection::Perform(const Handle(Adaptor3d_HSurface)&    S
 // purpose  : 
 //==================================================================================
 void AdjustOnPeriodic(const Handle(Adaptor3d_HSurface)& Surf1,
-                     const Handle(Adaptor3d_HSurface)& Surf2,
-                     IntPatch_SequenceOfLine& aSLin)
+                      const Handle(Adaptor3d_HSurface)& Surf2,
+                      IntPatch_SequenceOfLine& aSLin)
 {
   Standard_Boolean bIsPeriodic[4], bModified, bIsNull, bIsPeriod;
   Standard_Integer i, j, k, aNbLines, aNbPx, aIndx, aIndq;
@@ -1789,8 +1791,8 @@ void AdjustOnPeriodic(const Handle(Adaptor3d_HSurface)& Surf1,
       aIndx=1;
       aIndq=2;
       if (j) {
-       aIndx=aNbPx;
-       aIndq=aNbPx-1;
+        aIndx=aNbPx;
+        aIndq=aNbPx-1;
       }
       //
       const IntSurf_PntOn2S& aPSx=aL->Value(aIndx);
@@ -1800,41 +1802,41 @@ void AdjustOnPeriodic(const Handle(Adaptor3d_HSurface)& Surf1,
       aPSq.Parameters(uq[0], uq[1], uq[2], uq[3]);
       //
       for (k=0; k<4; ++k) {
-       bIsNull=Standard_False;
-       bIsPeriod=Standard_False;
-       //
-       if (!bIsPeriodic[k]) {
-         continue;
-       }
-       //
-       if (fabs(ux[k])<aEps) {
-         bModified=Standard_True;
-         bIsNull=Standard_True;
-       }
-       //
-       else if (fabs(ux[k]-aPeriod[k])<aEps) {
-         bModified=Standard_True;
-         bIsPeriod=Standard_True;
-       }
-       //
-       if (bModified) {
-         du=fabs(ux[k]-uq[k]);
-         if (du > dPeriod[k]) {
-           if(bIsNull){
-             ux[k]=aPeriod[k];
-           }
-           if(bIsPeriod) {
-             ux[k]=0.;
-           }
-         }
-       }
+        bIsNull=Standard_False;
+        bIsPeriod=Standard_False;
+        //
+        if (!bIsPeriodic[k]) {
+          continue;
+        }
+        //
+        if (fabs(ux[k])<aEps) {
+          bModified=Standard_True;
+          bIsNull=Standard_True;
+        }
+        //
+        else if (fabs(ux[k]-aPeriod[k])<aEps) {
+          bModified=Standard_True;
+          bIsPeriod=Standard_True;
+        }
+        //
+        if (bModified) {
+          du=fabs(ux[k]-uq[k]);
+          if (du > dPeriod[k]) {
+            if(bIsNull){
+              ux[k]=aPeriod[k];
+            }
+            if(bIsPeriod) {
+              ux[k]=0.;
+            }
+          }
+        }
       }//for (k=0; k<4; ++k) 
       if (bModified) {
-       IntSurf_PntOn2S aPntOn2S;
-       //
-       aPntOn2S=aPSx;  
-       aPntOn2S.SetValue(ux[0], ux[1], ux[2], ux[3]);
-       aL->Value(aIndx, aPntOn2S);
+        IntSurf_PntOn2S aPntOn2S;
+        //
+        aPntOn2S=aPSx;  
+        aPntOn2S.SetValue(ux[0], ux[1], ux[2], ux[3]);
+        aL->Value(aIndx, aPntOn2S);
       }
     }//for (j=0; j<1; ++j) {
   }//for (i=1; i<=aNbLines; ++i)
@@ -1850,7 +1852,7 @@ IntSurf_PntOn2S MakeNewPoint(const IntSurf_PntOn2S& replacePnt,
 {
   IntSurf_PntOn2S NewPoint;
   NewPoint.SetValue(replacePnt.Value());
-  
+
   Standard_Real OldParams[4], NewParams[4];
   oldPnt.Parameters(OldParams[0], OldParams[1], OldParams[2], OldParams[3]);
   replacePnt.Parameters(NewParams[0], NewParams[1], NewParams[2], NewParams[3]);
@@ -1868,8 +1870,8 @@ IntSurf_PntOn2S MakeNewPoint(const IntSurf_PntOn2S& replacePnt,
       }
     }
 
-  NewPoint.SetValue(NewParams[0], NewParams[1], NewParams[2], NewParams[3]);
-  return NewPoint;
+    NewPoint.SetValue(NewParams[0], NewParams[1], NewParams[2], NewParams[3]);
+    return NewPoint;
 }
 
 //==================================================================================
@@ -1877,24 +1879,26 @@ IntSurf_PntOn2S MakeNewPoint(const IntSurf_PntOn2S& replacePnt,
 // purpose  : base SS Int. function
 //==================================================================================
 void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Surf1,
-                                          const Handle(Adaptor3d_TopolTool)& D1,
-                                          const Handle(Adaptor3d_HSurface)& Surf2,
-                                          const Handle(Adaptor3d_TopolTool)& D2,
-                                          const Standard_Real   TolTangency,
-                                          const Standard_Real   Epsilon,
-                                          const Standard_Real   Deflection,
-                                          const Standard_Real   Increment,
+                                           const Handle(Adaptor3d_TopolTool)& D1,
+                                           const Handle(Adaptor3d_HSurface)& Surf2,
+                                           const Handle(Adaptor3d_TopolTool)& D2,
+                                           const Standard_Real   TolTangency,
+                                           const Standard_Real   Epsilon,
+                                           const Standard_Real   Deflection,
+                                           const Standard_Real   Increment,
                                            const Standard_Boolean ClearFlag) 
 {
-  Standard_Integer NbU1, NbV1, NbU2, NbV2, Limit; 
+  Standard_Integer Limit = 2500;
+  Standard_Integer NbU1 = 10, NbV1 = 10, NbU2 = 10, NbV2 = 10;
   //
-  D1->SamplePnts(Deflection, 10, 10);
-  D2->SamplePnts(Deflection, 10, 10);
+  D1->SamplePnts(Deflection, NbU1, NbV1);
+  D2->SamplePnts(Deflection, NbU2, NbV2);
   //
   NbU1 = D1->NbSamplesU();
   NbV1 = D1->NbSamplesV();
   NbU2 = D2->NbSamplesU();
   NbV2 = D2->NbSamplesV();
+
   TColStd_Array1OfReal anUpars1(1, NbU1), aVpars1(1, NbV1);
   TColStd_Array1OfReal anUpars2(1, NbU2), aVpars2(1, NbV2);
   //
@@ -1908,25 +1912,30 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
   Periods[1] = (Surf1->IsVPeriodic())? Surf1->VPeriod() : 0.;
   Periods[2] = (Surf2->IsUPeriodic())? Surf2->UPeriod() : 0.;
   Periods[3] = (Surf2->IsVPeriodic())? Surf2->VPeriod() : 0.;
-  
+
   //---------------------------------------------
-  Limit = 2500;
-  if((NbU1*NbV1<=Limit && NbV2*NbU2<=Limit)) {  
+  if((NbU1*NbV1<=Limit && NbV2*NbU2<=Limit))
+  {
     empt = Standard_True;
-    if (ClearFlag){
+    if (ClearFlag)
+    {
       SLin.Clear();
     }
     //
     IntPolyh_Intersection* pInterference = NULL;
 
-    if ( D1->IsUniformSampling() || D2->IsUniformSampling() ) {
+    if ( D1->IsUniformSampling() || D2->IsUniformSampling() )
+    {
       pInterference = new IntPolyh_Intersection(Surf1,NbU1,NbV1,Surf2,NbU2,NbV2);
     }
-    else {
+    else
+    {
       pInterference = new IntPolyh_Intersection(Surf1, anUpars1, aVpars1, 
-                                               Surf2, anUpars2, aVpars2 );
+        Surf2, anUpars2, aVpars2 );
     }
-    if ( !pInterference ) {
+
+    if ( !pInterference )
+    {
       done = Standard_False;
       return;
     }
@@ -1934,411 +1943,490 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
     IntPolyh_Intersection& Interference = *pInterference;
     //
     done = Interference.IsDone();
-    if( !done ) {
-      if (pInterference) {
-       delete pInterference;
-       pInterference = NULL;
+    if( !done )
+    {
+      if (pInterference)
+      {
+        delete pInterference;
+        pInterference = NULL;
       }
+
       return;
     }
-    
+
     Standard_Integer nbLigSec = Interference.NbSectionLines();
     Standard_Integer nbTanZon = Interference.NbTangentZones();
     Standard_Real SeuildPointLigne = 15.0 * Increment * Increment;
 
     Standard_Integer NbLigCalculee = 0, ver;
-    Standard_Real U1,U2,V1,V2, pu1,pu2,pv1,pv2, incidence, dminiPointLigne;
-    Standard_Boolean HasStartPoint,RejetLigne;
+    Standard_Real pu1,pu2,pv1,pv2, incidence, dminiPointLigne;
+    Standard_Boolean HasStartPoint = Standard_False, RejectLine = Standard_False;
     IntSurf_PntOn2S StartPOn2S;
     gp_Pnt Point3dDebut,Point3dFin;
 
     TColStd_Array1OfReal StartParams(1,4);
     IntPatch_ThePWalkingInter PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,Increment);
 
-    if(nbLigSec>=1) {  
+    if(nbLigSec>=1)
+    {
       Standard_Integer *TabL = new Standard_Integer [nbLigSec+1];
-      Standard_Integer ls;
-      for(ls=1; ls<=nbLigSec; ++ls){
-       TabL[ls]=ls;
+      for(Standard_Integer ls=1; ls<=nbLigSec; ++ls)
+      {
+        TabL[ls]=ls;
       }
       //----------------------------------------1.1
-      Standard_Boolean triok;
-      do { 
-       Standard_Integer b, nb_B, nb_A, tyu;
-       //
-       triok=Standard_True;
-       for( b = 2; b <= nbLigSec; ++b ) { 
-         nb_B = Interference.NbPointsInLine(TabL[b]);
-         nb_A = Interference.NbPointsInLine(TabL[b-1]);
-         if( nb_B > nb_A ) { 
-           tyu=TabL[b]; 
-           TabL[b]=TabL[b-1];
-           TabL[b-1]=tyu;
-           triok=Standard_False;
-         }
-       }
-      } while(triok==Standard_False);
+      {
+        Standard_Boolean triok;
+        Standard_Integer nb_A, nb_B, tyu;
+        do
+        {
+          triok=Standard_True;
+          for(Standard_Integer b = 2; b <= nbLigSec; ++b )
+          {
+            nb_B = Interference.NbPointsInLine(TabL[b]);
+            nb_A = Interference.NbPointsInLine(TabL[b-1]);
+
+            if( nb_B > nb_A )
+            {
+              tyu=TabL[b];
+              TabL[b]=TabL[b-1];
+              TabL[b-1]=tyu;
+              triok=Standard_False;
+            }
+          }
+        }
+        while(triok==Standard_False);
+      }
+
       //----------------------------------------
       // 1.2 For the line "ls" get 2D-bounds U,V for surfaces 1,2
       //
-      for( ls = 1; ls <= nbLigSec; ++ls) {
-       Standard_Integer nbp, ilig, *TabPtDep;
-       //
-       nbp = Interference.NbPointsInLine(TabL[ls]);
-       if (!nbp) {
-         continue;
-       }
-       //
-       TabPtDep = new Standard_Integer [nbp+1];
-       for( ilig = 1; ilig <= nbp; ++ilig ) {
-         TabPtDep[ilig]=0;
-       }
-       //
-       Standard_Real UminLig1,VminLig1,UmaxLig1,VmaxLig1;
-       Standard_Real UminLig2,VminLig2,UmaxLig2,VmaxLig2;
-       Standard_Real _x,_y,_z;
-       //
-       Interference.GetLinePoint(TabL[ls], 1, 
-                                 _x,_y,_z, 
-                                 UminLig1, VminLig1, UminLig2, VminLig2, 
-                                 incidence);
-       
-       UmaxLig1=UminLig1;
-       VmaxLig1=VminLig1;
-       UmaxLig2=UminLig2;
-       VmaxLig2=VminLig2;
-       //
-       for( ilig = 2; ilig <= nbp; ilig++ ) { 
-         Interference.GetLinePoint(TabL[ls],ilig,_x,_y,_z,U1,V1,U2,V2,incidence);
-         //
-         if(U1>UmaxLig1) UmaxLig1=U1;
-         if(V1>VmaxLig1) VmaxLig1=V1;
-         if(U2>UmaxLig2) UmaxLig2=U2;
-         if(V2>VmaxLig2) VmaxLig2=V2;
-         //
-         if(U1<UminLig1) UminLig1=U1;
-         if(V1<VminLig1) VminLig1=V1;
-         if(U2<UminLig2) UminLig2=U2;
-         if(V2<VminLig2) VminLig2=V2;
-       }//for( ilig = 2; ilig <= nbp; ilig++ ) { 
-       //
-       //----------------------------------------
-       // 1.3
-       Standard_Integer nbps2 = (nbp>3)? (nbp/2) :  1;
-       Standard_Integer NombreDePointsDeDepartDuCheminement = 0;
-       Standard_Boolean lignetrouvee=Standard_False;
-       const Standard_Integer NbDePointsDeDepartDuChmLimit = 5;
-       //
-       do { 
-         NombreDePointsDeDepartDuCheminement++;
-         switch (NombreDePointsDeDepartDuCheminement) {
-         case 1:
-           nbps2 = (nbp > 1) ? nbp/2 : 1;
-           if(nbp<3) 
-             NombreDePointsDeDepartDuCheminement = NbDePointsDeDepartDuChmLimit;
-           break;
-         case 2:
-           nbps2 = 1;
-           break;
-         case 3:
-           nbps2 = nbp-1;
-           break;
-         case 4:
-           nbps2 = 3 * nbp / 4;
-           break;
-         case 5:
-           nbps2 = nbp / 4;
-           break;
-         default:
-           nbps2 = NombreDePointsDeDepartDuCheminement-3;
-           NombreDePointsDeDepartDuCheminement++;
-         }
-         //
-         if(TabPtDep[nbps2] == 0) {
-           TabPtDep[nbps2] = 1;
-           Interference.GetLinePoint(TabL[ls],nbps2,_x,_y,_z,U1,V1,U2,V2,incidence);
-                     
-           StartParams(1) = U1;
-           StartParams(2) = V1;
-           StartParams(3) = U2;
-           StartParams(4) = V2;
-
-           HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);
-           dminiPointLigne = SeuildPointLigne + SeuildPointLigne;
-           if(HasStartPoint) {
-             StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
-             NbLigCalculee = SLin.Length();
-             Standard_Integer l;
-             for( l = 1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++) { 
-               const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l));
-
-                if (IsPointOnLine(StartPOn2S, testwline, Deflection)) {
+      for(Standard_Integer ls = 1; ls <= nbLigSec; ++ls)
+      {
+        Standard_Integer nbp = Interference.NbPointsInLine(TabL[ls]);
+        if (!nbp)
+        {
+          continue;
+        }
+        //
+        Standard_Integer *TabPtDep = new Standard_Integer [nbp+1];
+        for(Standard_Integer ilig = 1; ilig <= nbp; ++ilig )
+        {
+          TabPtDep[ilig]=0;
+        }
+        //
+        Standard_Real UminLig1,VminLig1,UmaxLig1,VmaxLig1;
+        Standard_Real UminLig2,VminLig2,UmaxLig2,VmaxLig2;
+        Standard_Real _x,_y,_z;
+        //
+        Interference.GetLinePoint(TabL[ls], 1, _x, _y, _z,
+          UminLig1, VminLig1, UminLig2, VminLig2, 
+          incidence);
+
+        UmaxLig1=UminLig1;
+        VmaxLig1=VminLig1;
+        UmaxLig2=UminLig2;
+        VmaxLig2=VminLig2;
+        //
+        for(Standard_Integer ilig = 2; ilig <= nbp; ilig++ )
+        {
+          Standard_Real U1, U2, V1, V2;
+          Interference.GetLinePoint(TabL[ls],ilig,_x,_y,_z,U1,V1,U2,V2,incidence);
+          //
+          if(U1>UmaxLig1) UmaxLig1=U1;
+          if(V1>VmaxLig1) VmaxLig1=V1;
+          if(U2>UmaxLig2) UmaxLig2=U2;
+          if(V2>VmaxLig2) VmaxLig2=V2;
+          //
+          if(U1<UminLig1) UminLig1=U1;
+          if(V1<VminLig1) VminLig1=V1;
+          if(U2<UminLig2) UminLig2=U2;
+          if(V2<VminLig2) VminLig2=V2;
+        }//for( ilig = 2; ilig <= nbp; ilig++ ) { 
+        //
+        //----------------------------------------
+        // 1.3
+        Standard_Integer nbps2 = (nbp>3)? (nbp/2) :  1;
+        Standard_Integer NombreDePointsDeDepartDuCheminement = 0;
+        Standard_Boolean lignetrouvee=Standard_False;
+        const Standard_Integer NbDePointsDeDepartDuChmLimit = 5;
+        //
+        do
+        {
+          NombreDePointsDeDepartDuCheminement++;
+          switch (NombreDePointsDeDepartDuCheminement)
+          {
+          case 1:
+            nbps2 = (nbp > 1) ? nbp/2 : 1;
+            if(nbp<3) 
+              NombreDePointsDeDepartDuCheminement = NbDePointsDeDepartDuChmLimit;
+
+            break;
+          case 2:
+            nbps2 = 1;
+            break;
+          case 3:
+            nbps2 = nbp-1;
+            break;
+
+          case 4:
+            nbps2 = 3 * nbp / 4;
+            break;
+
+          case 5:
+            nbps2 = nbp / 4;
+            break;
+          default:
+            nbps2 = NombreDePointsDeDepartDuCheminement-3;
+            NombreDePointsDeDepartDuCheminement++;
+          }
+
+          //
+          if(TabPtDep[nbps2] == 0)
+          {
+            Standard_Real U1, U2, V1, V2;
+
+            TabPtDep[nbps2] = 1;
+            Interference.GetLinePoint(TabL[ls],nbps2,_x,_y,_z,U1,V1,U2,V2,incidence);
+
+            StartParams(1) = U1;
+            StartParams(2) = V1;
+            StartParams(3) = U2;
+            StartParams(4) = V2;
+
+            HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);
+            dminiPointLigne = SeuildPointLigne + SeuildPointLigne;
+            if(HasStartPoint)
+            {
+              StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
+              NbLigCalculee = SLin.Length();
+              Standard_Integer l;
+              for( l = 1; (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); l++)
+              {
+                const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l));
+
+                if (IsPointOnLine(StartPOn2S, testwline, Deflection))
+                {
                   dminiPointLigne = 0.0;
                 }
-             }// for( l ...
-
-             if(dminiPointLigne > SeuildPointLigne) {
-               PW.Perform(StartParams,UminLig1,VminLig1,UminLig2,VminLig2,UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2);
-               //
-               Standard_Boolean bPWIsDone;
-               Standard_Integer iPWNbPoints, aNbPointsVer;
-               Standard_Real aD11, aD12, aD21, aD22, aDx;
-               //
-               bPWIsDone=PW.IsDone();
-               if(bPWIsDone) {
-                 iPWNbPoints=PW.NbPoints();
-                 //
-                 if( iPWNbPoints > 2 ) {
-                   RejetLigne = Standard_False;
-                   Point3dDebut = PW.Value(1).Value();
-                   Point3dFin   = PW.Value(iPWNbPoints).Value();
-                   for( ver = 1; (!RejetLigne) && (ver<= NbLigCalculee); ++ver) { 
-                     const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
-                     //
-                     aNbPointsVer=verwline->NbPnts();
-                     if (aNbPointsVer<3) {
-                       continue;
-                     }
-                     //
-                     const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
-                     const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts());
-                     //xf
-                     const gp_Pnt& aP21=verPointDebut.Value();
-                     const gp_Pnt& aP22=verPointFin.Value();
-                     //
-                     aD11=Point3dDebut.Distance(aP21);
-                     aD12=Point3dDebut.Distance(aP22);
-                     aD21=Point3dFin.Distance(aP21);
-                     aD22=Point3dFin.Distance(aP22);
-                     //
-                     if((aD11<=TolTangency && aD22<=TolTangency) ||
-                        (aD12<=TolTangency && aD21<=TolTangency)) {
-                       Standard_Integer m, mx;
-                       //
-                       mx=aNbPointsVer/2;
-                       if (aNbPointsVer%2) {
-                         ++mx; 
-                       }
-                       //
-                       const gp_Pnt& aPx=verwline->Point(mx).Value();
-                       for(m=1; m<iPWNbPoints; ++m){
-                         const gp_Pnt& aP1=PW.Value(m).Value();
-                         const gp_Pnt& aP2=PW.Value(m+1).Value();
-                         gp_Vec aVec12(aP1, aP2);
-                         if (aVec12.SquareMagnitude()<1.e-20){
-                           continue;
-                         }
-                         //
-                         gp_Dir aDir12(aVec12);
-                         gp_Lin aLin12(aP1, aDir12);
-                         aDx=aLin12.Distance(aPx);
-                         //modified by NIZNHY-PKV Tue May 10 11:08:07 2011f
-                         if (aDx<=2.*Epsilon) {
-                         //if (aDx<=TolTangency) {
-                         //modified by NIZNHY-PKV Tue May 10 11:08:13 2011t  
-                           RejetLigne = Standard_True;
-                           break;
-                         }
-                       }//for(m=1; m<iPWNbPoints; ++m){
-                     }//if((aD11<=TolTangency && aD22<=TolTangency) ||...
-                   }// for( ver = 1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
-                   //
-                   if(!RejetLigne) {
-                     IntSurf_TypeTrans trans1,trans2;
-                     Standard_Real locu,locv;
-                     gp_Vec norm1,norm2,d1u,d1v;
-                     gp_Pnt ptbid;
-                     Standard_Integer indextg;
-                     gp_Vec tgline(PW.TangentAtLine(indextg));
-                     PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
-                     Surf1->D1(locu,locv,ptbid,d1u,d1v);
-                     norm1 = d1u.Crossed(d1v);
-                     PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
-                     Surf2->D1(locu,locv,ptbid,d1u,d1v);
-                     norm2 = d1u.Crossed(d1v);
-                     if( tgline.DotCross(norm2,norm1) >= 0. ) {
-                       trans1 = IntSurf_Out;
-                       trans2 = IntSurf_In;
-                     }
-                     else {
-                       trans1 = IntSurf_In;
-                       trans2 = IntSurf_Out;
-                     }
-
-                     Standard_Real TolTang = TolTangency;
-                     Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
-                     IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
-                     IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
-
-                     if(wline->NbVertex() == 0) {
-                       IntPatch_Point vtx;
-                       IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
-                       POn2S.Parameters(pu1,pv1,pu2,pv2);
-                       vtx.SetValue(Point3dDebut,TolTang,Standard_False);
-                       vtx.SetParameters(pu1,pv1,pu2,pv2);
-                       vtx.SetParameter(1);
-                       wline->AddVertex(vtx);
-                       
-                       POn2S = PW.Line()->Value(wline->NbPnts());
-                       POn2S.Parameters(pu1,pv1,pu2,pv2);
-                       vtx.SetValue(Point3dFin,TolTang,Standard_False);
-                       vtx.SetParameters(pu1,pv1,pu2,pv2);
-                       vtx.SetParameter(wline->NbPnts());
-                       wline->AddVertex(vtx);
-                     }
-                     
-                     lignetrouvee = Standard_True;
-
-                     Standard_Integer slinlen = SLin.Length();
-                     if( slinlen > 0 ) {
-                       Standard_Integer cnbV = wline->NbVertex();
-                       Standard_Integer ciV;
-                       for( ciV = 1; ciV <= cnbV; ciV++ ) {
-                         Standard_Real pntDMin = 1.e+100;
-                         Standard_Integer VDMin = 0;
-                         Standard_Integer WLDMin = 0;
-                         gp_Pnt cPV = wline->Vertex(ciV).Value();
-                         Standard_Integer iL;
-                         for( iL = 1; iL <= slinlen; iL++) {
-                           const Handle(IntPatch_Line)& aSLine = SLin.Value(iL);
-                           IntPatch_IType aType = aSLine->ArcType();
-                           if( aType != IntPatch_Walking)
-                             continue;
-                           const Handle(IntPatch_WLine)&  aWLine = (*((Handle(IntPatch_WLine)*)&aSLine));
-                           Standard_Integer tnbV = aWLine->NbVertex();
-                           Standard_Integer tiV;
-                           for( tiV = 1; tiV <= tnbV; tiV++ ) {
-                             gp_Pnt tPV = aWLine->Vertex(tiV).Value();
-                             Standard_Real tDistance = cPV.Distance(tPV);
-                             Standard_Real uRs1 = Surf1->Surface().UResolution(tDistance);
-                             Standard_Real vRs1 = Surf1->Surface().VResolution(tDistance);
-                             Standard_Real uRs2 = Surf2->Surface().UResolution(tDistance);
-                             Standard_Real vRs2 = Surf2->Surface().VResolution(tDistance);
-                             Standard_Real RmaxS1 = Max(uRs1,vRs1);
-                             Standard_Real RmaxS2 = Max(uRs2,vRs2);
-                             if(RmaxS1 < 1.e-4 && RmaxS2 < 1.e-4) {
-                               if( pntDMin > tDistance && tDistance > 1.e-9) {
-                                 pntDMin = tDistance;
-                                 VDMin = tiV;
-                                 WLDMin = iL;
-                               }
-                             }
-                           }
-                         }
-                         
-                         if( VDMin != 0 ) {
-                           const Handle(IntPatch_Line)& aSLine = SLin.Value(WLDMin);
-                           const Handle(IntPatch_WLine)&  aWLine = (*((Handle(IntPatch_WLine)*)&aSLine));
-                           Standard_Integer tiVpar = (Standard_Integer)aWLine->Vertex(VDMin).ParameterOnLine();
-                           Standard_Integer ciVpar = (Standard_Integer)wline->Vertex(ciV).ParameterOnLine();
-                           Standard_Real u11 = 0., u12 = 0., v11 = 0., v12 = 0.;
-                           Standard_Real u21 = 0., u22 = 0., v21 = 0., v22 = 0.;
-                           wline->Point(ciVpar).Parameters(u11,v11,u12,v12);
-                           aWLine->Point(tiVpar).Parameters(u21,v21,u22,v22);
-
-                           Handle(IntSurf_LineOn2S) newL2s = new IntSurf_LineOn2S();
-                           IntSurf_PntOn2S replacePnt = aWLine->Point(tiVpar);
-                           Standard_Integer cNbP = wline->NbPnts();
-
-                           TColStd_SequenceOfInteger VPold;
-                           Standard_Integer iPo;
-                           for( iPo = 1; iPo <= cnbV; iPo++ ) {
-                             Standard_Real Po = wline->Vertex(iPo).ParameterOnLine();
-                             Standard_Integer IPo = (Standard_Integer) Po;
-                             VPold.Append(IPo);
-                           }
-                           
-                           Standard_Boolean removeNext = Standard_False;
-                           Standard_Boolean removePrev = Standard_False;
-                           if( ciV == 1) {
-                             Standard_Integer dPar = Abs( VPold.Value(ciV) - VPold.Value(ciV+1));
-                             if(dPar > 10) {
-                               removeNext = Standard_True;
-                               for( iPo = (ciV+1); iPo <= cnbV; iPo++ )
-                                 VPold.SetValue(iPo, VPold.Value(iPo) - 1 );
-                             }
-                           }
-                           else if( ciV == cnbV) {
-                             Standard_Integer dPar = Abs( VPold.Value(ciV) - VPold.Value(ciV-1));
-                             if(dPar > 10) {
-                               removePrev = Standard_True;
-                               VPold.SetValue(ciV, VPold.Value(ciV) - 1 );
-                             }
-                           }
-                           else {
-                             Standard_Integer dParMi = Abs( VPold.Value(ciV) - VPold.Value(ciV-1));
-                             Standard_Integer dParMa = Abs( VPold.Value(ciV) - VPold.Value(ciV+1));
-                             if(dParMi > 10) {
-                               removePrev = Standard_True;
-                               VPold.SetValue(ciV, VPold.Value(ciV) - 1 );
-                             }
-                             if(dParMa > 10) {
-                               removeNext = Standard_True;
-                               for( iPo = (ciV+1); iPo <= cnbV; iPo++ ) {
-                                 if(dParMi > 10)
-                                   VPold.SetValue(iPo, VPold.Value(iPo) - 2 );
-                                 else
-                                   VPold.SetValue(iPo, VPold.Value(iPo) - 1 );
-                               }
-                             }
-                             else {
-                               if(dParMi > 10)
-                                 for( iPo = (ciV+1); iPo <= cnbV; iPo++ )
-                                   VPold.SetValue(iPo, VPold.Value(iPo) - 1 );
-                             } 
-                           }
-                           Standard_Integer pI = (Standard_Integer) ciVpar;
-
-                           Standard_Integer iP;
-                           for( iP = 1; iP <= cNbP; iP++) {
-                             if( pI == iP )
+              }// for( l ...
+
+              if(dminiPointLigne > SeuildPointLigne)
+              {
+                PW.Perform(StartParams, UminLig1, VminLig1, UminLig2, VminLig2,
+                  UmaxLig1, VmaxLig1, UmaxLig2, VmaxLig2);
+
+                //
+                Standard_Boolean bPWIsDone;
+                Standard_Integer iPWNbPoints, aNbPointsVer;
+                Standard_Real aD11, aD12, aD21, aD22, aDx;
+                //
+                bPWIsDone=PW.IsDone();
+
+                if(bPWIsDone)
+                {
+                  iPWNbPoints=PW.NbPoints();
+                  //
+                  if( iPWNbPoints > 2 )
+                  {
+                    //Try to extend the intersection line to boundary, if it is possibly
+                    Standard_Boolean hasBeenAdded = PW.PutToBoundary(Surf1, Surf2);
+
+                    const Standard_Integer aMinNbPoints = 40;
+                    if(iPWNbPoints < aMinNbPoints)
+                    {
+                      hasBeenAdded = 
+                        PW.SeekAdditionalPoints(Surf1, Surf2, aMinNbPoints) || hasBeenAdded;
+                      iPWNbPoints = PW.NbPoints();
+                    }
+                    
+                    RejectLine = Standard_False;
+                    Point3dDebut = PW.Value(1).Value();
+                    Point3dFin   = PW.Value(iPWNbPoints).Value();
+                    for( ver = 1; (!RejectLine) && (ver<= NbLigCalculee); ++ver)
+                    {
+                      const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
+                      //
+                      aNbPointsVer=verwline->NbPnts();
+                      if (aNbPointsVer<3)
+                      {
+                        continue;
+                      }
+                      //
+                      const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
+                      const IntSurf_PntOn2S& verPointFin = verwline->Point(verwline->NbPnts());
+                      //xf
+                      const gp_Pnt& aP21=verPointDebut.Value();
+                      const gp_Pnt& aP22=verPointFin.Value();
+                      //
+                      aD11=Point3dDebut.Distance(aP21);
+                      aD12=Point3dDebut.Distance(aP22);
+                      aD21=Point3dFin.Distance(aP21);
+                      aD22=Point3dFin.Distance(aP22);
+                      //
+                      if((aD11<=TolTangency && aD22<=TolTangency) ||
+                        (aD12<=TolTangency && aD21<=TolTangency))
+                      {
+                        Standard_Integer m, mx;
+                        //
+                        mx=aNbPointsVer/2;
+                        if (aNbPointsVer%2)
+                        {
+                          ++mx; 
+                        }
+                        //
+                        const gp_Pnt& aPx=verwline->Point(mx).Value();
+                        for(m=1; m<iPWNbPoints; ++m)
+                        {
+                          const gp_Pnt& aP1=PW.Value(m).Value();
+                          const gp_Pnt& aP2=PW.Value(m+1).Value();
+                          gp_Vec aVec12(aP1, aP2);
+                          if (aVec12.SquareMagnitude()<1.e-20)
+                          {
+                            continue;
+                          }
+
+                          //
+                          gp_Dir aDir12(aVec12);
+                          gp_Lin aLin12(aP1, aDir12);
+                          aDx=aLin12.Distance(aPx);
+
+                          //modified by NIZNHY-PKV Tue May 10 11:08:07 2011f
+                          if (aDx<=2.*Epsilon)
+                          {
+                            //if (aDx<=TolTangency) {
+                            //modified by NIZNHY-PKV Tue May 10 11:08:13 2011t
+
+                            RejectLine = Standard_True;
+                            break;
+                          }
+                        }//for(m=1; m<iPWNbPoints; ++m){
+                      }//if((aD11<=TolTangency && aD22<=TolTangency) ||...
+                    }// for( ver = 1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
+                    //
+
+                    if(!RejectLine)
+                    {
+                      IntSurf_TypeTrans trans1,trans2;
+                      Standard_Real locu,locv;
+                      gp_Vec norm1,norm2,d1u,d1v;
+                      gp_Pnt ptbid;
+                      Standard_Integer indextg;
+                      gp_Vec tgline(PW.TangentAtLine(indextg));
+                      PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
+                      Surf1->D1(locu,locv,ptbid,d1u,d1v);
+                      norm1 = d1u.Crossed(d1v);
+                      PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
+                      Surf2->D1(locu,locv,ptbid,d1u,d1v);
+                      norm2 = d1u.Crossed(d1v);
+                      if( tgline.DotCross(norm2,norm1) >= 0. )
+                      {
+                        trans1 = IntSurf_Out;
+                        trans2 = IntSurf_In;
+                      }
+                      else
+                      {
+                        trans1 = IntSurf_In;
+                        trans2 = IntSurf_Out;
+                      }
+
+                      Standard_Real TolTang = TolTangency;
+                      Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
+                      IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang,hasBeenAdded);
+                      IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang,hasBeenAdded);
+
+                      if(wline->NbVertex() == 0)
+                      {
+                        IntPatch_Point vtx;
+                        IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
+                        POn2S.Parameters(pu1,pv1,pu2,pv2);
+                        vtx.SetValue(Point3dDebut,TolTang,Standard_False);
+                        vtx.SetParameters(pu1,pv1,pu2,pv2);
+                        vtx.SetParameter(1);
+                        wline->AddVertex(vtx);
+
+                        POn2S = PW.Line()->Value(wline->NbPnts());
+                        POn2S.Parameters(pu1,pv1,pu2,pv2);
+                        vtx.SetValue(Point3dFin,TolTang,Standard_False);
+                        vtx.SetParameters(pu1,pv1,pu2,pv2);
+                        vtx.SetParameter(wline->NbPnts());
+                        wline->AddVertex(vtx);
+                      }
+
+                      lignetrouvee = Standard_True;
+
+                      Standard_Integer slinlen = SLin.Length();
+                      if( slinlen > 0 )
+                      {
+                        Standard_Integer cnbV = wline->NbVertex();
+                        Standard_Integer ciV;
+                        for( ciV = 1; ciV <= cnbV; ciV++ )
+                        {
+                          Standard_Real pntDMin = 1.e+100;
+                          Standard_Integer VDMin = 0;
+                          Standard_Integer WLDMin = 0;
+                          gp_Pnt cPV = wline->Vertex(ciV).Value();
+                          Standard_Integer iL;
+                          for( iL = 1; iL <= slinlen; iL++)
+                          {
+                            const Handle(IntPatch_Line)& aSLine = SLin.Value(iL);
+                            IntPatch_IType aType = aSLine->ArcType();
+                            if( aType != IntPatch_Walking)
+                              continue;
+                            const Handle(IntPatch_WLine)&  aWLine = (*((Handle(IntPatch_WLine)*)&aSLine));
+                            Standard_Integer tnbV = aWLine->NbVertex();
+                            Standard_Integer tiV;
+                            for( tiV = 1; tiV <= tnbV; tiV++ )
+                            {
+                              gp_Pnt tPV = aWLine->Vertex(tiV).Value();
+                              Standard_Real tDistance = cPV.Distance(tPV);
+                              Standard_Real uRs1 = Surf1->Surface().UResolution(tDistance);
+                              Standard_Real vRs1 = Surf1->Surface().VResolution(tDistance);
+                              Standard_Real uRs2 = Surf2->Surface().UResolution(tDistance);
+                              Standard_Real vRs2 = Surf2->Surface().VResolution(tDistance);
+                              Standard_Real RmaxS1 = Max(uRs1,vRs1);
+                              Standard_Real RmaxS2 = Max(uRs2,vRs2);
+                              if(RmaxS1 < 1.e-4 && RmaxS2 < 1.e-4)
+                              {
+                                if( pntDMin > tDistance && tDistance > 1.e-9)
+                                {
+                                  pntDMin = tDistance;
+                                  VDMin = tiV;
+                                  WLDMin = iL;
+                                }
+                              }
+                            }
+                          }
+
+                          if( VDMin != 0 )
+                          {
+                            const Handle(IntPatch_Line)& aSLine = SLin.Value(WLDMin);
+                            const Handle(IntPatch_WLine)&  aWLine = (*((Handle(IntPatch_WLine)*)&aSLine));
+                            Standard_Integer tiVpar = (Standard_Integer)aWLine->Vertex(VDMin).ParameterOnLine();
+                            Standard_Integer ciVpar = (Standard_Integer)wline->Vertex(ciV).ParameterOnLine();
+                            Standard_Real u11 = 0., u12 = 0., v11 = 0., v12 = 0.;
+                            Standard_Real u21 = 0., u22 = 0., v21 = 0., v22 = 0.;
+                            wline->Point(ciVpar).Parameters(u11,v11,u12,v12);
+                            aWLine->Point(tiVpar).Parameters(u21,v21,u22,v22);
+
+                            Handle(IntSurf_LineOn2S) newL2s = new IntSurf_LineOn2S();
+                            IntSurf_PntOn2S replacePnt = aWLine->Point(tiVpar);
+                            Standard_Integer cNbP = wline->NbPnts();
+
+                            TColStd_SequenceOfInteger VPold;
+                            Standard_Integer iPo;
+                            for( iPo = 1; iPo <= cnbV; iPo++ )
+                            {
+                              Standard_Real Po = wline->Vertex(iPo).ParameterOnLine();
+                              Standard_Integer IPo = (Standard_Integer) Po;
+                              VPold.Append(IPo);
+                            }
+
+                            Standard_Boolean removeNext = Standard_False;
+                            Standard_Boolean removePrev = Standard_False;
+                            if( ciV == 1)
+                            {
+                              Standard_Integer dPar = Abs( VPold.Value(ciV) - VPold.Value(ciV+1));
+                              if(dPar > 10)
+                              {
+                                removeNext = Standard_True;
+                                for( iPo = (ciV+1); iPo <= cnbV; iPo++ )
+                                  VPold.SetValue(iPo, VPold.Value(iPo) - 1 );
+                              }
+                            }
+                            else if( ciV == cnbV)
+                            {
+                              Standard_Integer dPar = Abs( VPold.Value(ciV) - VPold.Value(ciV-1));
+                              if(dPar > 10)
+                              {
+                                removePrev = Standard_True;
+                                VPold.SetValue(ciV, VPold.Value(ciV) - 1 );
+                              }
+                            }
+                            else
+                            {
+                              Standard_Integer dParMi = Abs( VPold.Value(ciV) - VPold.Value(ciV-1));
+                              Standard_Integer dParMa = Abs( VPold.Value(ciV) - VPold.Value(ciV+1));
+                              if(dParMi > 10)
+                              {
+                                removePrev = Standard_True;
+                                VPold.SetValue(ciV, VPold.Value(ciV) - 1 );
+                              }
+
+                              if(dParMa > 10)
+                              {
+                                removeNext = Standard_True;
+                                for( iPo = (ciV+1); iPo <= cnbV; iPo++ )
+                                {
+                                  if(dParMi > 10)
+                                    VPold.SetValue(iPo, VPold.Value(iPo) - 2 );
+                                  else
+                                    VPold.SetValue(iPo, VPold.Value(iPo) - 1 );
+                                }
+                              }
+                              else
+                              {
+                                if(dParMi > 10)
+                                  for( iPo = (ciV+1); iPo <= cnbV; iPo++ )
+                                    VPold.SetValue(iPo, VPold.Value(iPo) - 1 );
+                              } 
+                            }
+
+                            Standard_Integer pI = ciVpar;
+
+                            Standard_Integer iP;
+                            for( iP = 1; iP <= cNbP; iP++)
+                            {
+                              if( pI == iP )
                               {
                                 IntSurf_PntOn2S newPnt = MakeNewPoint(replacePnt, wline->Point(iP), Periods);
                                 newL2s->Add(newPnt);
                               }
-                             else if(removeNext && iP == (pI + 1))
-                               continue;
-                             else if(removePrev && iP == (pI - 1))
-                               continue;
-                             else
-                               newL2s->Add(wline->Point(iP));
-                           }
-
-                           IntPatch_Point newVtx;
-                           gp_Pnt Pnt3dV = aWLine->Vertex(VDMin).Value();
-                           newVtx.SetValue(Pnt3dV,TolTang,Standard_False);
-                           newVtx.SetParameters(u21,v21,u22,v22);
-                           newVtx.SetParameter(VPold.Value(ciV));
-
-                           Handle(IntPatch_WLine) NWLine = new IntPatch_WLine(newL2s,Standard_False,trans1,trans2);
-
-                           Standard_Integer iV;
-                           for( iV = 1; iV <= cnbV; iV++ ) {
-                             if( iV == ciV )
-                               NWLine->AddVertex(newVtx);
-                             else {
-                               IntPatch_Point theVtx = wline->Vertex(iV);
-                               theVtx.SetParameter(VPold.Value(iV));
-                               NWLine->AddVertex(theVtx);
-                             }
-                           }
-
-                           wline = NWLine;
-                         }
-                       }
-                     }// SLin.Length > 0
+                              else if(removeNext && iP == (pI + 1))
+                                continue;
+                              else if(removePrev && iP == (pI - 1))
+                                continue;
+                              else
+                                newL2s->Add(wline->Point(iP));
+                            }
+
+                            IntPatch_Point newVtx;
+                            gp_Pnt Pnt3dV = aWLine->Vertex(VDMin).Value();
+                            newVtx.SetValue(Pnt3dV,TolTang,Standard_False);
+                            newVtx.SetParameters(u21,v21,u22,v22);
+                            newVtx.SetParameter(VPold.Value(ciV));
+
+                            Handle(IntPatch_WLine) NWLine = new IntPatch_WLine(newL2s,Standard_False,trans1,trans2);
+
+                            Standard_Integer iV;
+                            for( iV = 1; iV <= cnbV; iV++ )
+                            {
+                              if( iV == ciV )
+                                NWLine->AddVertex(newVtx);
+                              else
+                              {
+                                IntPatch_Point theVtx = wline->Vertex(iV);
+                                theVtx.SetParameter(VPold.Value(iV));
+                                NWLine->AddVertex(theVtx);
+                              }
+                            }
+
+                            wline = NWLine;
+                          }//if( VDMin != 0 )
+                        }//for( ciV = 1; ciV <= cnbV; ciV++ )
+                      }// SLin.Length > 0
 
                       AddWLine(SLin, wline, Deflection);
-                     empt = Standard_False;
-                   }// !RejetLigne
-                 }// PW points > 2
-               }// done is True
-             }// dminiPointLigne > SeuildPointLigne
-           }// HasStartPoint
-         }// if TabPtDep[nbps2] == 0
-       } while(nbp>5 && !( (NombreDePointsDeDepartDuCheminement >= NbDePointsDeDepartDuChmLimit && lignetrouvee) || 
-                           (NombreDePointsDeDepartDuCheminement-3 >= nbp && (!lignetrouvee))));
-       delete [] TabPtDep;
+                      empt = Standard_False;
+                    }// !RejetLigne
+                  }// PW points > 2
+                }// done is True
+              }// dminiPointLigne > SeuildPointLigne
+            }// HasStartPoint
+          }// if TabPtDep[nbps2] == 0
+        } while(nbp>5 && !( (NombreDePointsDeDepartDuCheminement >= NbDePointsDeDepartDuChmLimit && lignetrouvee) || 
+          (NombreDePointsDeDepartDuCheminement-3 >= nbp && (!lignetrouvee))));
+        delete [] TabPtDep;
       }// for( ls ...
 
       delete [] TabL;
@@ -2353,182 +2441,206 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
     //--------------------------------------------------------------------
     Standard_Real UminLig1,VminLig1,UmaxLig1,VmaxLig1;
     Standard_Real UminLig2,VminLig2,UmaxLig2,VmaxLig2;
-    
+
     UminLig1=VminLig1=UminLig2=VminLig2=RealLast();
     UmaxLig1=VmaxLig1=UmaxLig2=VmaxLig2=-UminLig1;
 
     // NbPointsInTangentZone always == 1 (eap)
-    
+
     Standard_Integer z;
-    for( z=1; z <= nbTanZon; z++) { 
+    for( z=1; z <= nbTanZon; z++)
+    { 
       //Standard_Integer NbPointsInTangentZone=Interference.NbPointsInTangentZone(z);
       //for(Standard_Integer pz=1; pz<=NbPointsInTangentZone; pz++) {
-       Standard_Integer pz=1;
-       Standard_Real _x,_y,_z;
-       Interference.GetTangentZonePoint(z,pz,_x,_y,_z,U1,V1,U2,V2);
-
-       if(U1>UmaxLig1) UmaxLig1=U1;
-       if(V1>VmaxLig1) VmaxLig1=V1;
-       if(U2>UmaxLig2) UmaxLig2=U2;
-       if(V2>VmaxLig2) VmaxLig2=V2;
-       
-       if(U1<UminLig1) UminLig1=U1;
-       if(V1<VminLig1) VminLig1=V1;
-       if(U2<UminLig2) UminLig2=U2;
-       if(V2<VminLig2) VminLig2=V2;
+      Standard_Integer pz=1;
+      Standard_Real _x,_y,_z;
+      Standard_Real U1, U2, V1, V2;
+      Interference.GetTangentZonePoint(z,pz,_x,_y,_z,U1,V1,U2,V2);
+
+      if(U1>UmaxLig1) UmaxLig1=U1;
+      if(V1>VmaxLig1) VmaxLig1=V1;
+      if(U2>UmaxLig2) UmaxLig2=U2;
+      if(V2>VmaxLig2) VmaxLig2=V2;
+
+      if(U1<UminLig1) UminLig1=U1;
+      if(V1<VminLig1) VminLig1=V1;
+      if(U2<UminLig2) UminLig2=U2;
+      if(V2<VminLig2) VminLig2=V2;
       //}
     }
-    for(z=1; z <= nbTanZon; z++) {    
 
+    for(z=1; z <= nbTanZon; z++)
+    {
       //Standard_Integer NbPointsInTangentZone=Interference.NbPointsInTangentZone(z);
       //for(Standard_Integer pz=1; pz<=NbPointsInTangentZone; pz++) { 
-       Standard_Integer pz=1;
-       Standard_Real _x,_y,_z;
-       Interference.GetTangentZonePoint(z,pz,_x,_y,_z,U1,V1,U2,V2);
-
-       StartParams(1) = U1;
-       StartParams(2) = V1;
-       StartParams(3) = U2;
-       StartParams(4) = V2;
-       
-       //-----------------------------------------------------------------------
-       //-- Calcul du premier point de cheminement a partir du point approche --
-       //-----------------------------------------------------------------------
-       HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);   
-       if(HasStartPoint) { 
-         //-------------------------------------------------
-         //-- Un point a ete trouve                       --
-         //-- On verifie qu il n appartient pas           --
-         //--  a une ligne de cheminement deja calculee.  --
-         //-------------------------------------------------
-         StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
-         
-         NbLigCalculee = SLin.Length();
-         dminiPointLigne = SeuildPointLigne + SeuildPointLigne; 
-
-         for(Standard_Integer l=1; 
-             (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); 
-             l++) { 
-           const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l));
-
-            if (IsPointOnLine(StartPOn2S, testwline, Deflection)) {
-              dminiPointLigne = 0.0;
-            }
-         }
-
-         //-- Fin d exploration des lignes
-         if(dminiPointLigne > SeuildPointLigne) { 
-           //---------------------------------------------------
-           //-- Le point de depart du nouveau cheminement     --
-           //-- n est present dans aucune ligne deja calculee.--
-           //---------------------------------------------------
-           PW.Perform(StartParams,
-                        UminLig1,VminLig1,UminLig2,VminLig2,
-                        UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2);
-           if(PW.IsDone()) {
-             if(PW.NbPoints()>2) { 
-               //-----------------------------------------------
-               //-- Verification a posteriori : 
-               //-- On teste si le point de depart et de fin de 
-               //-- la ligne de cheminement est present dans une 
-               //-- autre ligne . 
-               //-----------------------------------------------
-               RejetLigne = Standard_False;
-               Point3dDebut = PW.Value(1).Value();
-                const IntSurf_PntOn2S& PointFin = PW.Value(PW.NbPoints());
-                Point3dFin   = PointFin.Value();
-               
-               for(ver=1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
-                 const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
-                 //-- Handle(IntPatch_WLine) verwline=Handle(IntPatch_WLine)::DownCast(SLin.Value(ver));
-
-                  // Check end point if it is on existing line.
-                  // Start point is checked before.
-                  if (IsPointOnLine(PointFin, verwline, Deflection)) {
-                    RejetLigne = Standard_True; 
-                    break;
+      Standard_Integer pz=1;
+      Standard_Real _x,_y,_z;
+      Standard_Real U1, U2, V1, V2;
+      Interference.GetTangentZonePoint(z,pz,_x,_y,_z,U1,V1,U2,V2);
+
+      StartParams(1) = U1;
+      StartParams(2) = V1;
+      StartParams(3) = U2;
+      StartParams(4) = V2;
+
+      //-----------------------------------------------------------------------
+      //-- Calcul du premier point de cheminement a partir du point approche --
+      //-----------------------------------------------------------------------
+      HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);    
+      if(HasStartPoint)
+      {
+        //-------------------------------------------------
+        //-- Un point a ete trouve                       --
+        //-- On verifie qu il n appartient pas           --
+        //--  a une ligne de cheminement deja calculee.  --
+        //-------------------------------------------------
+        StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
+
+        NbLigCalculee = SLin.Length();
+        dminiPointLigne = SeuildPointLigne + SeuildPointLigne; 
+
+        for(Standard_Integer l=1; 
+          (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); 
+          l++)
+        {
+          const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l));
+
+          if (IsPointOnLine(StartPOn2S, testwline, Deflection))
+          {
+            dminiPointLigne = 0.0;
+          }
+        }
+
+        //-- Fin d exploration des lignes
+        if(dminiPointLigne > SeuildPointLigne)
+        {
+          //---------------------------------------------------
+          //-- Le point de depart du nouveau cheminement     --
+          //-- n est present dans aucune ligne deja calculee.--
+          //---------------------------------------------------
+          PW.Perform(StartParams,UminLig1,VminLig1,UminLig2,VminLig2,
+            UmaxLig1,VmaxLig1,UmaxLig2,VmaxLig2);
+
+          if(PW.IsDone())
+          {
+            if(PW.NbPoints()>2)
+            { 
+              const Standard_Integer aMinNbPoints = 40;
+              if(PW.NbPoints() < aMinNbPoints)
+              {
+                PW.SeekAdditionalPoints(Surf1, Surf2, aMinNbPoints);
+              }
+
+              //-----------------------------------------------
+              //-- Verification a posteriori : 
+              //-- On teste si le point de depart et de fin de 
+              //-- la ligne de cheminement est present dans une 
+              //-- autre ligne . 
+              //-----------------------------------------------
+              RejectLine = Standard_False;
+              Point3dDebut = PW.Value(1).Value();
+              const IntSurf_PntOn2S& PointFin = PW.Value(PW.NbPoints());
+              Point3dFin   = PointFin.Value();
+
+              for(ver=1 ; (!RejectLine) && (ver<= NbLigCalculee) ; ver++)
+              {
+                const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
+                //-- Handle(IntPatch_WLine) verwline=Handle(IntPatch_WLine)::DownCast(SLin.Value(ver));
+
+                // Check end point if it is on existing line.
+                // Start point is checked before.
+                if (IsPointOnLine(PointFin, verwline, Deflection))
+                {
+                  RejectLine = Standard_True; 
+                  break;
+                }
+
+                const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
+                const IntSurf_PntOn2S& verPointFin   = verwline->Point(verwline->NbPnts());
+                if(Point3dDebut.Distance(verPointDebut.Value()) < TolTangency)
+                {
+                  RejectLine = Standard_True; 
+                }
+                else
+                {
+                  if(Point3dFin.Distance(verPointFin.Value()) < TolTangency)
+                  {
+                    RejectLine = Standard_True; 
                   }
+                }
+              }
 
-                 const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
-                 const IntSurf_PntOn2S& verPointFin   = verwline->Point(verwline->NbPnts());
-                 if(Point3dDebut.Distance(verPointDebut.Value()) < TolTangency) { 
-                   RejetLigne = Standard_True; 
-                 }
-                 else { 
-                   if(Point3dFin.Distance(verPointFin.Value()) < TolTangency) { 
-                     RejetLigne = Standard_True; 
-                   }
-                 }
-               }
-               
-               if(!RejetLigne) { 
-
-                 IntSurf_TypeTrans trans1,trans2;
-                 Standard_Real locu,locv;
-                 gp_Vec norm1,norm2,d1u,d1v;
-                 gp_Pnt ptbid;
-                 Standard_Integer indextg;
-                 gp_Vec tgline(PW.TangentAtLine(indextg));
-                 PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
-                 Surf1->D1(locu,locv,ptbid,d1u,d1v);
-                 norm1 = d1u.Crossed(d1v);
-                 PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
-                 Surf2->D1(locu,locv,ptbid,d1u,d1v);
-                 norm2 = d1u.Crossed(d1v);
-                 if (tgline.DotCross(norm2,norm1)>0.) {
-                   trans1 = IntSurf_Out;
-                   trans2 = IntSurf_In;
-                 }
-                 else {
-                   trans1 = IntSurf_In;
-                   trans2 = IntSurf_Out;
-                 }
-                 
-                 
-                 
-                 Standard_Real TolTang = TolTangency;
-                 Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
-                 IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
-                 IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
-                 
-                 //---------------
-                    if(wline->NbVertex() == 0) {
-                     IntPatch_Point vtx;
-                     IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
-                     POn2S.Parameters(pu1,pv1,pu2,pv2);
-                     vtx.SetValue(Point3dDebut,TolTang,Standard_False);
-                     vtx.SetParameters(pu1,pv1,pu2,pv2);
-                     vtx.SetParameter(1);
-                     wline->AddVertex(vtx);
-                     
-                     POn2S = PW.Line()->Value(wline->NbPnts());
-                     POn2S.Parameters(pu1,pv1,pu2,pv2);
-                     vtx.SetValue(Point3dFin,TolTang,Standard_False);
-                     vtx.SetParameters(pu1,pv1,pu2,pv2);
-                     vtx.SetParameter(wline->NbPnts());
-                     wline->AddVertex(vtx);
-                   }
-                   
-                 //---------------
-                  AddWLine(SLin, wline, Deflection);
-                 empt = Standard_False;
-                 
-               }
-               else { 
-                 //-- cout<<" ----- REJET DE LIGNE (POINT DE DEPART) ----- "<<endl;
-               }
-               //------------------------------------------------------------          
-             }
-           }  //--  le cheminement a reussi (done a True)
-         }  //--  le point approche ne renvoie pas sur une ligne existante
-       } //-- Si HasStartPoint
+              if(!RejectLine)
+              { 
+                IntSurf_TypeTrans trans1,trans2;
+                Standard_Real locu,locv;
+                gp_Vec norm1,norm2,d1u,d1v;
+                gp_Pnt ptbid;
+                Standard_Integer indextg;
+                gp_Vec tgline(PW.TangentAtLine(indextg));
+                PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
+                Surf1->D1(locu,locv,ptbid,d1u,d1v);
+                norm1 = d1u.Crossed(d1v);
+                PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
+                Surf2->D1(locu,locv,ptbid,d1u,d1v);
+                norm2 = d1u.Crossed(d1v);
+                if (tgline.DotCross(norm2,norm1)>0.)
+                {
+                  trans1 = IntSurf_Out;
+                  trans2 = IntSurf_In;
+                }
+                else
+                {
+                  trans1 = IntSurf_In;
+                  trans2 = IntSurf_Out;
+                }
+
+                Standard_Real TolTang = TolTangency;
+                Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
+                IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+                IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+
+                //---------------
+                if(wline->NbVertex() == 0)
+                {
+                  IntPatch_Point vtx;
+                  IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
+                  POn2S.Parameters(pu1,pv1,pu2,pv2);
+                  vtx.SetValue(Point3dDebut,TolTang,Standard_False);
+                  vtx.SetParameters(pu1,pv1,pu2,pv2);
+                  vtx.SetParameter(1);
+                  wline->AddVertex(vtx);
+
+                  POn2S = PW.Line()->Value(wline->NbPnts());
+                  POn2S.Parameters(pu1,pv1,pu2,pv2);
+                  vtx.SetValue(Point3dFin,TolTang,Standard_False);
+                  vtx.SetParameters(pu1,pv1,pu2,pv2);
+                  vtx.SetParameter(wline->NbPnts());
+                  wline->AddVertex(vtx);
+                }
+
+                //---------------
+                AddWLine(SLin, wline, Deflection);
+                empt = Standard_False;
+              }
+              else
+              {
+                //-- cout<<" ----- REJET DE LIGNE (POINT DE DEPART) ----- "<<endl;
+              }
+              //------------------------------------------------------------           
+            }
+          }  //--  le cheminement a reussi (done a True)
+        }  //--  le point approche ne renvoie pas sur une ligne existante
+      } //-- Si HasStartPoint
       //} //-- Boucle Sur les Points de la Tangent Zone
     } //-- Boucle sur Les Tangent Zones
 
-    if ( pInterference ) {
+    if ( pInterference )
+    {
       delete pInterference;
       pInterference = NULL;
     }
+
     return;
   }// if((NbU1*NbV1<=Limit && NbV2*NbU2<=Limit)) {  
 
@@ -2537,20 +2649,20 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
   empt = Standard_True;
   done = Standard_True;
   SLin.Clear();  
-  
+
   Standard_Integer NbLigCalculee = 0;
   Standard_Real U1,U2,V1,V2;
   Standard_Real pu1,pu2,pv1,pv2;
-  
+
   TColStd_Array1OfReal StartParams(1,4);
   Standard_Integer MaxOscill = NbU1;
   if(MaxOscill < NbU2) MaxOscill=NbU2;
   if(MaxOscill < NbV1) MaxOscill=NbV1;
   if(MaxOscill < NbV2) MaxOscill=NbV2;
-  
+
   Standard_Real nIncrement=Increment;
   //if(MaxOscill>10)
-    //nIncrement/=0.5*MaxOscill;
+  //nIncrement/=0.5*MaxOscill;
 
   IntPatch_ThePWalkingInter PW(Surf1,Surf2,TolTangency,Epsilon,Deflection,nIncrement);
   Standard_Real    SeuildPointLigne = 15.0 * Increment * Increment; //-- 10 est insuffisant
@@ -2571,138 +2683,148 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
     StartParams(2) = V1;
     StartParams(3) = U2;
     StartParams(4) = V2;
-    
+
     //-----------------------------------------------------------------------
     //-- Calcul du premier point de cheminement a partir du point approche --
     //-----------------------------------------------------------------------
     HasStartPoint = PW.PerformFirstPoint(StartParams,StartPOn2S);      
-    if(HasStartPoint) { 
+    if(HasStartPoint)
+    { 
       //-------------------------------------------------
       //-- Un point a ete trouve                       --
       //-- On verifie qu il n appartient pas           --
       //--  a une ligne de cheminement deja calculee.  --
       //-------------------------------------------------
       StartPOn2S.Parameters(pu1,pv1,pu2,pv2);
-      
+
       NbLigCalculee = SLin.Length();
       dminiPointLigne = SeuildPointLigne + SeuildPointLigne; 
-      
+
       for(Standard_Integer l=1; 
-         (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); 
-         l++) { 
+        (l <= NbLigCalculee) && (dminiPointLigne >= SeuildPointLigne); 
+        l++)
+      {
         const Handle(IntPatch_WLine)& testwline = *((Handle(IntPatch_WLine)*)&SLin.Value(l));
 
-        if (IsPointOnLine(StartPOn2S, testwline, Deflection)) {
+        if (IsPointOnLine(StartPOn2S, testwline, Deflection))
+        {
           dminiPointLigne = 0.0;
         }
       }
 
       //-- Fin d exploration des lignes
-      if(dminiPointLigne > SeuildPointLigne) { 
-       //---------------------------------------------------
-       //-- Le point de depart du nouveau cheminement     --
-       //-- n est present dans aucune ligne deja calculee.--
-       //---------------------------------------------------
-       PW.Perform(StartParams);
-       if(PW.IsDone()) {
-         if(PW.NbPoints()>2) { 
-           //-----------------------------------------------
-           //-- Verification a posteriori : 
-           //-- On teste si le point de depart et de fin de 
-           //-- la ligne de cheminement est present dans une 
-           //-- autre ligne . 
-           //-----------------------------------------------
-           RejetLigne = Standard_False;
-           Point3dDebut = PW.Value(1).Value();
+      if(dminiPointLigne > SeuildPointLigne)
+      { 
+        //---------------------------------------------------
+        //-- Le point de depart du nouveau cheminement     --
+        //-- n est present dans aucune ligne deja calculee.--
+        //---------------------------------------------------
+        PW.Perform(StartParams);
+        if(PW.IsDone())
+        {
+          if(PW.NbPoints()>2)
+          {
+            //-----------------------------------------------
+            //-- Verification a posteriori : 
+            //-- On teste si le point de depart et de fin de 
+            //-- la ligne de cheminement est present dans une 
+            //-- autre ligne . 
+            //-----------------------------------------------
+            RejetLigne = Standard_False;
+            Point3dDebut = PW.Value(1).Value();
             const IntSurf_PntOn2S& PointFin = PW.Value(PW.NbPoints());
             Point3dFin   = PointFin.Value();
-           
-           for(ver=1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++) { 
-             const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
-             //-- Handle(IntPatch_WLine) verwline=Handle(IntPatch_WLine)::DownCast(SLin.Value(ver));
+
+            for(ver=1 ; (!RejetLigne) && (ver<= NbLigCalculee) ; ver++)
+            {
+              const Handle(IntPatch_WLine)& verwline = *((Handle(IntPatch_WLine)*)&SLin.Value(ver));
+              //-- Handle(IntPatch_WLine) verwline=Handle(IntPatch_WLine)::DownCast(SLin.Value(ver));
 
               // Check end point if it is on existing line.
               // Start point is checked before.
-              if (IsPointOnLine(PointFin, verwline, Deflection)) {
+              if (IsPointOnLine(PointFin, verwline, Deflection))
+              {
                 RejetLigne = Standard_True; 
                 break;
               }
 
-             const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
-             const IntSurf_PntOn2S& verPointFin   = verwline->Point(verwline->NbPnts());
-             if(Point3dDebut.Distance(verPointDebut.Value()) < TolTangency) { 
-               RejetLigne = Standard_True; 
-             }
-             else { 
-               if(Point3dFin.Distance(verPointFin.Value()) < TolTangency) { 
-                 RejetLigne = Standard_True; 
-               }
-             }
-           }
-           
-           if(!RejetLigne) { 
-             
-             IntSurf_TypeTrans trans1,trans2;
-             Standard_Real locu,locv;
-             gp_Vec norm1,norm2,d1u,d1v;
-             gp_Pnt ptbid;
-             Standard_Integer indextg;
-             gp_Vec tgline(PW.TangentAtLine(indextg));
-             PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
-             Surf1->D1(locu,locv,ptbid,d1u,d1v);
-             norm1 = d1u.Crossed(d1v);
-             PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
-             Surf2->D1(locu,locv,ptbid,d1u,d1v);
-             norm2 = d1u.Crossed(d1v);
-             if (tgline.DotCross(norm2,norm1)>0.) {
-               trans1 = IntSurf_Out;
-               trans2 = IntSurf_In;
-             }
-             else {
-               trans1 = IntSurf_In;
-               trans2 = IntSurf_Out;
-             }
-             
-             
-             
-             Standard_Real TolTang = TolTangency;
-             Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
-             IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
-             IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
-             
-             //---------------
-             if(wline->NbVertex() == 0) {
-               IntPatch_Point vtx;
-               const IntSurf_PntOn2S& POn2Sf = PW.Line()->Value(1);
-               POn2Sf.Parameters(pu1,pv1,pu2,pv2);
-               vtx.SetValue(Point3dDebut,TolTang,Standard_False);
-               vtx.SetParameters(pu1,pv1,pu2,pv2);
-               vtx.SetParameter(1);
-               wline->AddVertex(vtx);
-               
-               const IntSurf_PntOn2S& POn2Sl = PW.Line()->Value(wline->NbPnts());
-               POn2Sl.Parameters(pu1,pv1,pu2,pv2);
-               vtx.SetValue(Point3dFin,TolTang,Standard_False);
-               vtx.SetParameters(pu1,pv1,pu2,pv2);
-               vtx.SetParameter(wline->NbPnts());
-               wline->AddVertex(vtx);
-             }
-             
-             //---------------
+              const IntSurf_PntOn2S& verPointDebut = verwline->Point(1);
+              const IntSurf_PntOn2S& verPointFin   = verwline->Point(verwline->NbPnts());
+              if(Point3dDebut.Distance(verPointDebut.Value()) < TolTangency)
+              {
+                RejetLigne = Standard_True; 
+              }
+              else
+              {
+                if(Point3dFin.Distance(verPointFin.Value()) < TolTangency)
+                {
+                  RejetLigne = Standard_True; 
+                }
+              }
+            }
+
+            if(!RejetLigne)
+            {
+              IntSurf_TypeTrans trans1,trans2;
+              Standard_Real locu,locv;
+              gp_Vec norm1,norm2,d1u,d1v;
+              gp_Pnt ptbid;
+              Standard_Integer indextg;
+              gp_Vec tgline(PW.TangentAtLine(indextg));
+              PW.Line()->Value(indextg).ParametersOnS1(locu,locv);
+              Surf1->D1(locu,locv,ptbid,d1u,d1v);
+              norm1 = d1u.Crossed(d1v);
+              PW.Line()->Value(indextg).ParametersOnS2(locu,locv);
+              Surf2->D1(locu,locv,ptbid,d1u,d1v);
+              norm2 = d1u.Crossed(d1v);
+              if (tgline.DotCross(norm2,norm1)>0.)
+              {
+                trans1 = IntSurf_Out;
+                trans2 = IntSurf_In;
+              }
+              else {
+                trans1 = IntSurf_In;
+                trans2 = IntSurf_Out;
+              }
+
+              Standard_Real TolTang = TolTangency;
+              Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
+              IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+              IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+
+              //---------------
+              if(wline->NbVertex() == 0)
+              {
+                IntPatch_Point vtx;
+                const IntSurf_PntOn2S& POn2Sf = PW.Line()->Value(1);
+                POn2Sf.Parameters(pu1,pv1,pu2,pv2);
+                vtx.SetValue(Point3dDebut,TolTang,Standard_False);
+                vtx.SetParameters(pu1,pv1,pu2,pv2);
+                vtx.SetParameter(1);
+                wline->AddVertex(vtx);
+
+                const IntSurf_PntOn2S& POn2Sl = PW.Line()->Value(wline->NbPnts());
+                POn2Sl.Parameters(pu1,pv1,pu2,pv2);
+                vtx.SetValue(Point3dFin,TolTang,Standard_False);
+                vtx.SetParameters(pu1,pv1,pu2,pv2);
+                vtx.SetParameter(wline->NbPnts());
+                wline->AddVertex(vtx);
+              }
+
+              //---------------
               AddWLine(SLin, wline, Deflection);
-             empt = Standard_False;
-             
-           }
-           else { 
-             //-- cout<<" ----- REJET DE LIGNE (POINT DE DEPART) ----- "<<endl;
-           }
-           //------------------------------------------------------------              
-         }
-       }  //--  le cheminement a reussi (done a True)
+              empt = Standard_False;
+            }
+            else
+            { 
+              //-- cout<<" ----- REJET DE LIGNE (POINT DE DEPART) ----- "<<endl;
+            }
+            //------------------------------------------------------------             
+          }
+        }  //--  le cheminement a reussi (done a True)
       }  //--  le point approche ne renvoie pas sur une ligne existante
     } //-- Si HasStartPoint
   } //-- Boucle sur Les Tangent Zones
-    
 }
 //modified by NIZNHY-PKV Wed May 25 09:39:07 2011f
 //=======================================================================
@@ -2710,7 +2832,7 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
 //purpose  : 
 //=======================================================================
 class IntPatch_InfoPD {
- public:
+public:
   //----------------------------------------C-tor
   IntPatch_InfoPD(const Standard_Integer aNBI) {
     Standard_Integer aNBI2, i, j;
@@ -2726,12 +2848,12 @@ class IntPatch_InfoPD {
     //
     for (i=0; i<myNBI; ++i) {
       for (j=0; j<myNBI; ++j) {
-       xP1DS2(i, j)=0;
-       xP2DS1(i, j)=0;
-       xIP1(i, j)=0;
-       xIP2(i, j)=0;
-       xP1(i, j).SetCoord(0., 0., 0.);
-       xP2(i, j).SetCoord(0., 0., 0.);
+        xP1DS2(i, j)=0;
+        xP2DS1(i, j)=0;
+        xIP1(i, j)=0;
+        xIP2(i, j)=0;
+        xP1(i, j).SetCoord(0., 0., 0.);
+        xP2(i, j).SetCoord(0., 0., 0.);
       }
     }
   };
@@ -2746,8 +2868,8 @@ class IntPatch_InfoPD {
   };
   //---------------------------------------- Index
   Standard_Integer Index(const Standard_Integer i,
-                        const Standard_Integer j) const { 
-    return i*myNBI+j;
+    const Standard_Integer j) const { 
+      return i*myNBI+j;
   };
   //---------------------------------------- NBI
   Standard_Integer NBI() const { 
@@ -2755,35 +2877,35 @@ class IntPatch_InfoPD {
   };
   //----------------------------------------xP1DS2
   char& xP1DS2(const Standard_Integer i,
-              const Standard_Integer j) { 
-    return myP1DS2[Index(i,j)];
+    const Standard_Integer j) { 
+      return myP1DS2[Index(i,j)];
   };
   //----------------------------------------xP2DS1
   char& xP2DS1(const Standard_Integer i,
-              const Standard_Integer j) { 
-    return myP2DS1[Index(i,j)];
+    const Standard_Integer j) { 
+      return myP2DS1[Index(i,j)];
   };
   //----------------------------------------xIP1
   Standard_Integer& xIP1(const Standard_Integer i,
-                        const Standard_Integer j) { 
-    return myIP1[Index(i,j)];
+    const Standard_Integer j) { 
+      return myIP1[Index(i,j)];
   };
   //----------------------------------------xIP2
   Standard_Integer& xIP2(const Standard_Integer i,
-                        const Standard_Integer j) { 
-    return myIP2[Index(i,j)];
+    const Standard_Integer j) { 
+      return myIP2[Index(i,j)];
   };
   //----------------------------------------xP1
   gp_Pnt& xP1(const Standard_Integer i,
-             const Standard_Integer j) { 
-    return myP1[Index(i,j)];
+    const Standard_Integer j) { 
+      return myP1[Index(i,j)];
   };
   //----------------------------------------xP1
   gp_Pnt& xP2(const Standard_Integer i,
-             const Standard_Integer j) { 
-    return myP2[Index(i,j)];
+    const Standard_Integer j) { 
+      return myP2[Index(i,j)];
   };
- protected:
+protected:
   Standard_Integer myNBI;
   char *myP1DS2;
   char *myP2DS1;
@@ -2798,12 +2920,12 @@ class IntPatch_InfoPD {
 // purpose  : 
 //==================================================================================
 void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S,
-                                             const Handle(Adaptor3d_HSurface)& S1,
-                                             const Standard_Integer SU_1,
-                                             const Standard_Integer SV_1,
-                                             const Handle(Adaptor3d_HSurface)& S2,
-                                             const Standard_Integer SU_2,
-                                             const Standard_Integer SV_2) const 
+                                              const Handle(Adaptor3d_HSurface)& S1,
+                                              const Standard_Integer SU_1,
+                                              const Standard_Integer SV_1,
+                                              const Handle(Adaptor3d_HSurface)& S2,
+                                              const Standard_Integer SU_2,
+                                              const Standard_Integer SV_2) const 
 { 
   Standard_Integer i, j, xNBI;
   //modified by NIZNHY-PKV Tue May 24 11:37:38 2011f
@@ -2812,7 +2934,7 @@ void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S
   //modified by NIZNHY-PKV Wed May 25 06:47:12 2011t
   Standard_Integer iC15, SU1, SV1, SU2, SV2;
   Standard_Real U0, U1, V0, V1, U, V;
-  Standard_Real resu0,resu1,resv0,resv1;
+  Standard_Real resu0,resv0;
   Standard_Real  du1,du2,dv1,dv2, dmaxOn1, dmaxOn2;
   Standard_Real x0,y0,z0, x1,y1,z1,d;
   Bnd_Box Box1, Box2;
@@ -2842,8 +2964,6 @@ void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S
   V1 = S1->LastVParameter();
   //
   resu0=U0;
-  resu1=U1;
-  resv1=V1;
   resv0=V0;
   //
   dmaxOn1 = 0.0;
@@ -2856,13 +2976,13 @@ void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S
       aIPD.xP1(i, j)= S1->Value(U,V);
       Box1.Add(aIPD.xP1(i, j));
       if(i>0 && j>0) { 
-       aIPD.xP1(i, j)    .Coord(x0,y0,z0);
-       aIPD.xP1(i-1, j-1).Coord(x1,y1,z1);
-       //
-       d=Abs(x1-x0)+Abs(y1-y0)+Abs(z1-z0);
-       if(d>dmaxOn1) {
-         dmaxOn1 = d;
-       }
+        aIPD.xP1(i, j)    .Coord(x0,y0,z0);
+        aIPD.xP1(i-1, j-1).Coord(x1,y1,z1);
+        //
+        d=Abs(x1-x0)+Abs(y1-y0)+Abs(z1-z0);
+        if(d>dmaxOn1) {
+          dmaxOn1 = d;
+        }
       }
     }
   }
@@ -2880,12 +3000,12 @@ void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S
       aIPD.xP2(i, j) = S2->Value(U,V);
       Box2.Add(aIPD.xP2(i, j));
       if(i>0 && j>0) { 
-       aIPD.xP2(i, j)    .Coord(x0,y0,z0);
-       aIPD.xP2(i-1, j-1).Coord(x1,y1,z1);
-       d =  Abs(x1-x0)+Abs(y1-y0)+Abs(z1-z0);
-       if(d>dmaxOn2) {
-         dmaxOn2 = d;
-       }
+        aIPD.xP2(i, j)    .Coord(x0,y0,z0);
+        aIPD.xP2(i-1, j-1).Coord(x1,y1,z1);
+        d =  Abs(x1-x0)+Abs(y1-y0)+Abs(z1-z0);
+        if(d>dmaxOn2) {
+          dmaxOn2 = d;
+        }
       }
     }
   }
@@ -2893,7 +3013,7 @@ void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S
   //--------
   //
   if(Box1.IsOut(Box2)) {
-    
+
     return;
   }
   //
@@ -2969,13 +3089,13 @@ void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S
       aIPD.xP1DS2(i, j) = (char)CodeReject(x20,y20,z20,x21,y21,z21,P.X(),P.Y(),P.Z());
       int ix = (int)((P.X()-x0  + dx2 )/dx);
       if(DansGrille(ix)) { 
-       int iy = (int)((P.Y()-y0 + dy2)/dy);
-       if(DansGrille(iy)) {
-         int iz = (int)((P.Z()-z0 + dz2)/dz);
-         if(DansGrille(iz)) {
-           aIPD.xIP1(i, j) = GrilleInteger(ix,iy,iz);
-         }
-       }
+        int iy = (int)((P.Y()-y0 + dy2)/dy);
+        if(DansGrille(iy)) {
+          int iz = (int)((P.Z()-z0 + dz2)/dz);
+          if(DansGrille(iz)) {
+            aIPD.xIP1(i, j) = GrilleInteger(ix,iy,iz);
+          }
+        }
       }
     }
   }
@@ -2987,13 +3107,13 @@ void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S
       aIPD.xP2DS1(i, j) = (char)CodeReject(x10,y10,z10,x11,y11,z11,P.X(),P.Y(),P.Z());
       int ix = (int)((P.X()-x0 + dx2)/dx);
       if(DansGrille(ix)) { 
-       int iy = (int)((P.Y()-y0 + dy2)/dy);
-       if(DansGrille(iy)) {
-         int iz = (int)((P.Z()-z0 + dz2)/dz);
-         if(DansGrille(iz)) {
-           aIPD.xIP2(i, j) =  GrilleInteger(ix,iy,iz);
-         }
-       }
+        int iy = (int)((P.Y()-y0 + dy2)/dy);
+        if(DansGrille(iy)) {
+          int iz = (int)((P.Z()-z0 + dz2)/dz);
+          if(DansGrille(iz)) {
+            aIPD.xIP2(i, j) =  GrilleInteger(ix,iy,iz);
+          }
+        }
       }
     }
   }
@@ -3001,18 +3121,18 @@ void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S
   for(i=0;i<SU1-1;i+=1) {
     for(j=0;j<SV1-1;j+=1) { 
       if(!((aIPD.xP1DS2(i, j) & aIPD.xP1DS2(i+1, j)) || 
-          (aIPD.xP1DS2(i, j) & aIPD.xP1DS2(i+1, j+1)))){
-       Remplit(aIPD.xIP1(i, j),
-               aIPD.xIP1(i+1, j),
-               aIPD.xIP1(i+1, j+1),
-               M1);
+        (aIPD.xP1DS2(i, j) & aIPD.xP1DS2(i+1, j+1)))){
+          Remplit(aIPD.xIP1(i, j),
+            aIPD.xIP1(i+1, j),
+            aIPD.xIP1(i+1, j+1),
+            M1);
       }
       if(!((aIPD.xP1DS2(i, j) & aIPD.xP1DS2(i, j+1)) || 
-          (aIPD.xP1DS2(i, j) & aIPD.xP1DS2(i+1, j+1)))) {
-       Remplit(aIPD.xIP1(i, j),
-               aIPD.xIP1(i, j+1),
-               aIPD.xIP1(i+1, j+1),
-               M1);    
+        (aIPD.xP1DS2(i, j) & aIPD.xP1DS2(i+1, j+1)))) {
+          Remplit(aIPD.xIP1(i, j),
+            aIPD.xIP1(i, j+1),
+            aIPD.xIP1(i+1, j+1),
+            M1);       
       }
     }
   }    
@@ -3020,18 +3140,18 @@ void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S
   for(i=0;i<SU2-1;i+=1) {
     for(j=0;j<SV2-1;j+=1) { 
       if(!((aIPD.xP2DS1(i, j) & aIPD.xP2DS1(i+1, j)) ||
-          (aIPD.xP2DS1(i, j) & aIPD.xP2DS1(i+1, j+1)))){
-       Remplit(aIPD.xIP2(i, j),
-               aIPD.xIP2(i+1, j),
-               aIPD.xIP2(i+1, j+1),
-               M2);
+        (aIPD.xP2DS1(i, j) & aIPD.xP2DS1(i+1, j+1)))){
+          Remplit(aIPD.xIP2(i, j),
+            aIPD.xIP2(i+1, j),
+            aIPD.xIP2(i+1, j+1),
+            M2);
       }
       if(!((aIPD.xP2DS1(i, j) & aIPD.xP2DS1(i, j+1)) || 
-          (aIPD.xP2DS1(i, j) & aIPD.xP2DS1(i+1, j+1)))){
-       Remplit(aIPD.xIP2(i, j),
-               aIPD.xIP2(i, j+1),
-               aIPD.xIP2(i+1, j+1),
-               M2);    
+        (aIPD.xP2DS1(i, j) & aIPD.xP2DS1(i+1, j+1)))){
+          Remplit(aIPD.xIP2(i, j),
+            aIPD.xIP2(i, j+1),
+            aIPD.xIP2(i+1, j+1),
+            M2);       
       }
     }
   }    
@@ -3053,30 +3173,30 @@ void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S
       int nb=0;
       int LIM=3;
       if(   DansGrille(i-1) && DansGrille(j-1) && DansGrille(k-1) 
-        && DansGrille(i+1) && DansGrille(j+1) && DansGrille(k+1)) { 
-       int si,sj,sk;
-       for(si=-1; si<= 1 && nb<LIM; si++) { 
-         for(sj=-1; sj<= 1 && nb<LIM; sj++) { 
-           for(sk=-1; sk<= 1 && nb<LIM; sk++) { 
-             long unsigned lu=GrilleInteger(i+si,j+sj,k+sk);
-             if(M1.Val(lu) && M2.Val(lu)) { 
-               nb++;
-             }
-           }
-         }
-       }
-       if(nb>=LIM) { 
-         for(si=-1; si<= 1; si++) { 
-           for(sj=-1; sj<= 1; sj++) { 
-             for(sk=-1; sk<= 1; sk++) { 
-               if(si || sj || sk) { 
-                 long unsigned lu=GrilleInteger(i+si,j+sj,k+sk);
-                 M1.Raz(lu);
-               }
-             }
-           }
-         }
-       }
+        && DansGrille(i+1) && DansGrille(j+1) && DansGrille(k+1)) { 
+          int si,sj,sk;
+          for(si=-1; si<= 1 && nb<LIM; si++) { 
+            for(sj=-1; sj<= 1 && nb<LIM; sj++) { 
+              for(sk=-1; sk<= 1 && nb<LIM; sk++) { 
+                long unsigned lu=GrilleInteger(i+si,j+sj,k+sk);
+                if(M1.Val(lu) && M2.Val(lu)) { 
+                  nb++;
+                }
+              }
+            }
+          }
+          if(nb>=LIM) { 
+            for(si=-1; si<= 1; si++) { 
+              for(sj=-1; sj<= 1; sj++) { 
+                for(sk=-1; sk<= 1; sk++) { 
+                  if(si || sj || sk) { 
+                    long unsigned lu=GrilleInteger(i+si,j+sj,k+sk);
+                    M1.Raz(lu);
+                  }
+                }
+              }
+            }
+          }
       }
       //
       gp_Pnt P(dx*i + x0, dy*j + y0, dz*k+z0);
@@ -3085,113 +3205,113 @@ void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S
       Standard_Integer nv1=0, nv2=0;
       int nbsur1 = 0;
       for(nu=0;nu1<0 && nu<SU1;nu++) { 
-       for(nv=0;nu1<0 && nv<SV1;nv++) { 
-         if( aIPD.xIP1(nu, nv) ==(Standard_Integer) newind )  { 
-           nbsur1++;
-           aIPD.xIP1(nu, nv)=indicepointtraite;
-           nu1=nu; nv1=nv;
-         }
-       }
+        for(nv=0;nu1<0 && nv<SV1;nv++) { 
+          if( aIPD.xIP1(nu, nv) ==(Standard_Integer) newind )  { 
+            nbsur1++;
+            aIPD.xIP1(nu, nv)=indicepointtraite;
+            nu1=nu; nv1=nv;
+          }
+        }
       }
       if(nu1>=0) { 
-       int nbsur2 = 0;
-       for(nu=0;nu2<0 && nu<SU2;nu++) { 
-         for(nv=0;nu2<0 && nv<SV2;nv++) { 
-           if( aIPD.xIP2(nu, nv)==(Standard_Integer) newind )  { 
-             nbsur2++;
-             aIPD.xIP2(nu, nv)=indicepointtraite;
-             nu2=nu; nv2=nv;
-           }
-         }
-       }
+        int nbsur2 = 0;
+        for(nu=0;nu2<0 && nu<SU2;nu++) { 
+          for(nv=0;nu2<0 && nv<SV2;nv++) { 
+            if( aIPD.xIP2(nu, nv)==(Standard_Integer) newind )  { 
+              nbsur2++;
+              aIPD.xIP2(nu, nv)=indicepointtraite;
+              nu2=nu; nv2=nv;
+            }
+          }
+        }
       }
       if(nu1>=0 && nu2>=0) { 
-       IntSurf_PntOn2S POn2S;
-       POn2S.SetValue(P, 
-                      S1->FirstUParameter()+nu1*du1,
-                      S1->FirstVParameter()+nv1*dv1,
-                      S2->FirstUParameter()+nu2*du2,
-                      S2->FirstVParameter()+nv2*dv2);
-       LineOn2S->Add(POn2S);
-       Compt++;
+        IntSurf_PntOn2S POn2S;
+        POn2S.SetValue(P, 
+          S1->FirstUParameter()+nu1*du1,
+          S1->FirstVParameter()+nv1*dv1,
+          S2->FirstUParameter()+nu2*du2,
+          S2->FirstVParameter()+nv2*dv2);
+        LineOn2S->Add(POn2S);
+        Compt++;
       }
       else { 
-       //-- aucun point du triangle n a ete trouve assez proche
-       //-- on recherche les 3 points les plus proches de P 
-       //-- dans chacun des tableaux 
-                 Standard_Real Dist3[3],u3[3] = { 0.0, 0.0, 0.0 },v3[3] = { 0.0, 0.0, 0.0 };
-       Dist3[0]=Dist3[1]=Dist3[2]=RealLast();
-       for(U=resu0,i=0; i<SU1; i++,U+=du1) { 
-         for(V=resv0,j=0; j<SV1; V+=dv1,j++) {       
-           //-- On place les 3 meilleures valeurs dans Dist1,Dist2,Dist3
-           Standard_Real t = aIPD.xP1(i, j).SquareDistance(P);
-           //-- On remplace la plus grande valeur ds Dist[.] par la val courante
-           if(Dist3[0]<Dist3[1]) { 
-             Standard_Real z;
-             z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
-             z=u3[0]; u3[0]=u3[1]; u3[1]=z;
-             z=v3[0]; v3[0]=v3[1]; v3[1]=z;
-           }
-           if(Dist3[1]<Dist3[2]) { 
-             Standard_Real z;
-             z=Dist3[1]; Dist3[1]=Dist3[2]; Dist3[2]=z;
-             z=u3[1]; u3[1]=u3[2]; u3[2]=z;
-             z=v3[1]; v3[1]=v3[2]; v3[2]=z;
-           }
-           if(Dist3[0]<Dist3[1]) { 
-             Standard_Real z;
-             z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
-             z=u3[0]; u3[0]=u3[1]; u3[1]=z;
-             z=v3[0]; v3[0]=v3[1]; v3[1]=z;
-           }
-           //-- la plus grande valeur est dans Dist3[0]
-           if(t<Dist3[0]) { 
-             Dist3[0]=t; u3[0]=U; v3[0]=V;
-           }
-         }
-       }
-       //
-       Standard_Real U1_3 = (u3[0]+u3[1]+u3[2])/3.0;
-       Standard_Real V1_3 = (v3[0]+v3[1]+v3[2])/3.0;
-       
-       Dist3[0]=Dist3[1]=Dist3[2]=RealLast();
-       for(U=U0,i=0; i<SU2; i++,U+=du2) { 
-         for(V=V0,j=0; j<SV2; V+=dv2,j++) {       
-           //-- On place les 3 meilleures valeurs dans Dist1,Dist2,Dist3
-           Standard_Real t = aIPD.xP2(i, j).SquareDistance(P);
-           //-- On remplace la plus grande valeur ds Dist3[.] par la val courante
-           if(Dist3[0]<Dist3[1]) { 
-             Standard_Real z;
-             z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
-             z=u3[0]; u3[0]=u3[1]; u3[1]=z;
-             z=v3[0]; v3[0]=v3[1]; v3[1]=z;
-           }
-           if(Dist3[1]<Dist3[2]) { 
-             Standard_Real z;
-             z=Dist3[1]; Dist3[1]=Dist3[2]; Dist3[2]=z;
-             z=u3[1]; u3[1]=u3[2]; u3[2]=z;
-             z=v3[1]; v3[1]=v3[2]; v3[2]=z;
-           }
-           if(Dist3[0]<Dist3[1]) { 
-             Standard_Real z;
-             z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
-             z=u3[0]; u3[0]=u3[1]; u3[1]=z;
-             z=v3[0]; v3[0]=v3[1]; v3[1]=z;
-           }
-           //-- la plus grande valeur est dans Dist3[0]
-           if(t<Dist3[0]) { 
-             Dist3[0]=t; u3[0]=U; v3[0]=V;
-           }
-         }
-       }
-       //
-       Standard_Real U2_3 = (u3[0]+u3[1]+u3[2])/3.0;
-       Standard_Real V2_3 = (v3[0]+v3[1]+v3[2])/3.0;
-       //
-       IntSurf_PntOn2S POn2S;
-       POn2S.SetValue(P,U1_3,V1_3,U2_3,V2_3);
-       LineOn2S->Add(POn2S);
-       Compt++;        
+        //-- aucun point du triangle n a ete trouve assez proche
+        //-- on recherche les 3 points les plus proches de P 
+        //-- dans chacun des tableaux 
+        Standard_Real Dist3[3],u3[3] = { 0.0, 0.0, 0.0 },v3[3] = { 0.0, 0.0, 0.0 };
+        Dist3[0]=Dist3[1]=Dist3[2]=RealLast();
+        for(U=resu0,i=0; i<SU1; i++,U+=du1) { 
+          for(V=resv0,j=0; j<SV1; V+=dv1,j++) {       
+            //-- On place les 3 meilleures valeurs dans Dist1,Dist2,Dist3
+            Standard_Real t = aIPD.xP1(i, j).SquareDistance(P);
+            //-- On remplace la plus grande valeur ds Dist[.] par la val courante
+            if(Dist3[0]<Dist3[1]) { 
+              Standard_Real z;
+              z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
+              z=u3[0]; u3[0]=u3[1]; u3[1]=z;
+              z=v3[0]; v3[0]=v3[1]; v3[1]=z;
+            }
+            if(Dist3[1]<Dist3[2]) { 
+              Standard_Real z;
+              z=Dist3[1]; Dist3[1]=Dist3[2]; Dist3[2]=z;
+              z=u3[1]; u3[1]=u3[2]; u3[2]=z;
+              z=v3[1]; v3[1]=v3[2]; v3[2]=z;
+            }
+            if(Dist3[0]<Dist3[1]) { 
+              Standard_Real z;
+              z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
+              z=u3[0]; u3[0]=u3[1]; u3[1]=z;
+              z=v3[0]; v3[0]=v3[1]; v3[1]=z;
+            }
+            //-- la plus grande valeur est dans Dist3[0]
+            if(t<Dist3[0]) { 
+              Dist3[0]=t; u3[0]=U; v3[0]=V;
+            }
+          }
+        }
+        //
+        Standard_Real U1_3 = (u3[0]+u3[1]+u3[2])/3.0;
+        Standard_Real V1_3 = (v3[0]+v3[1]+v3[2])/3.0;
+
+        Dist3[0]=Dist3[1]=Dist3[2]=RealLast();
+        for(U=U0,i=0; i<SU2; i++,U+=du2) { 
+          for(V=V0,j=0; j<SV2; V+=dv2,j++) {       
+            //-- On place les 3 meilleures valeurs dans Dist1,Dist2,Dist3
+            Standard_Real t = aIPD.xP2(i, j).SquareDistance(P);
+            //-- On remplace la plus grande valeur ds Dist3[.] par la val courante
+            if(Dist3[0]<Dist3[1]) { 
+              Standard_Real z;
+              z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
+              z=u3[0]; u3[0]=u3[1]; u3[1]=z;
+              z=v3[0]; v3[0]=v3[1]; v3[1]=z;
+            }
+            if(Dist3[1]<Dist3[2]) { 
+              Standard_Real z;
+              z=Dist3[1]; Dist3[1]=Dist3[2]; Dist3[2]=z;
+              z=u3[1]; u3[1]=u3[2]; u3[2]=z;
+              z=v3[1]; v3[1]=v3[2]; v3[2]=z;
+            }
+            if(Dist3[0]<Dist3[1]) { 
+              Standard_Real z;
+              z=Dist3[0]; Dist3[0]=Dist3[1]; Dist3[1]=z;
+              z=u3[0]; u3[0]=u3[1]; u3[1]=z;
+              z=v3[0]; v3[0]=v3[1]; v3[1]=z;
+            }
+            //-- la plus grande valeur est dans Dist3[0]
+            if(t<Dist3[0]) { 
+              Dist3[0]=t; u3[0]=U; v3[0]=V;
+            }
+          }
+        }
+        //
+        Standard_Real U2_3 = (u3[0]+u3[1]+u3[2])/3.0;
+        Standard_Real V2_3 = (v3[0]+v3[1]+v3[2])/3.0;
+        //
+        IntSurf_PntOn2S POn2S;
+        POn2S.SetValue(P,U1_3,V1_3,U2_3,V2_3);
+        LineOn2S->Add(POn2S);
+        Compt++;       
       }
     }
   }
@@ -3214,62 +3334,62 @@ Standard_Boolean IsPointOnLine(const IntSurf_PntOn2S        &thePOn2S,
   thePOn2S.Parameters(pu1, pv1, pu2, pv2);
 
   if ((theWLine->IsOutSurf1Box(gp_Pnt2d(pu1, pv1)) == Standard_False) &&
-      (theWLine->IsOutSurf2Box(gp_Pnt2d(pu2, pv2)) == Standard_False) &&
-      (theWLine->IsOutBox(thePOn2S.Value())        == Standard_False)) {
-    const Standard_Integer NbPntOn2SOnLine = theWLine->NbPnts();
-    Standard_Integer ll;
-
-    for (ll=1; ll < NbPntOn2SOnLine && !isOnLine; ll++) {
-      const gp_Pnt &Pa     = theWLine->Point(ll).Value();
-      const gp_Pnt &Pb     = theWLine->Point(ll+1).Value();
-      const gp_Pnt &PStart = thePOn2S.Value();
-      const gp_Vec  AM(Pa, PStart);
-      const gp_Vec  MB(PStart,Pb);
-      const Standard_Real AMMB = AM.Dot(MB);
-
-      if(AMMB > 0.0) {
-        gp_Dir ABN(Pb.X() - Pa.X(), Pb.Y() - Pa.Y(), Pb.Z() - Pa.Z());
-        Standard_Real lan =  ABN.X()*AM.X() + ABN.Y()*AM.Y() + ABN.Z()*AM.Z();
-        gp_Vec AH(lan*ABN.X(), lan*ABN.Y(), lan*ABN.Z());
-        gp_Vec HM(AM.X() - AH.X(), AM.Y() - AH.Y(), AM.Z() - AH.Z());
-        Standard_Real d = 0.0;
-  
-        if(HM.X() < Deflection) {
-          d += HM.X()*HM.X();
-
-          if(HM.Y() < Deflection) {
-            d += HM.Y()*HM.Y();
-
-            if(HM.Z() < Deflection) {
-              d += HM.Z()*HM.Z();
+    (theWLine->IsOutSurf2Box(gp_Pnt2d(pu2, pv2)) == Standard_False) &&
+    (theWLine->IsOutBox(thePOn2S.Value())        == Standard_False)) {
+      const Standard_Integer NbPntOn2SOnLine = theWLine->NbPnts();
+      Standard_Integer ll;
+
+      for (ll=1; ll < NbPntOn2SOnLine && !isOnLine; ll++) {
+        const gp_Pnt &Pa     = theWLine->Point(ll).Value();
+        const gp_Pnt &Pb     = theWLine->Point(ll+1).Value();
+        const gp_Pnt &PStart = thePOn2S.Value();
+        const gp_Vec  AM(Pa, PStart);
+        const gp_Vec  MB(PStart,Pb);
+        const Standard_Real AMMB = AM.Dot(MB);
+
+        if(AMMB > 0.0) {
+          gp_Dir ABN(Pb.X() - Pa.X(), Pb.Y() - Pa.Y(), Pb.Z() - Pa.Z());
+          Standard_Real lan =  ABN.X()*AM.X() + ABN.Y()*AM.Y() + ABN.Z()*AM.Z();
+          gp_Vec AH(lan*ABN.X(), lan*ABN.Y(), lan*ABN.Z());
+          gp_Vec HM(AM.X() - AH.X(), AM.Y() - AH.Y(), AM.Z() - AH.Z());
+          Standard_Real d = 0.0;
+
+          if(HM.X() < Deflection) {
+            d += HM.X()*HM.X();
+
+            if(HM.Y() < Deflection) {
+              d += HM.Y()*HM.Y();
+
+              if(HM.Z() < Deflection) {
+                d += HM.Z()*HM.Z();
+              } else {
+                d = Deflection2;
+              }
             } else {
               d = Deflection2;
             }
           } else {
             d = Deflection2;
           }
-        } else {
-          d = Deflection2;
-        }
 
-        if(d < Deflection2) {
-          isOnLine = Standard_True;
-        }
-      } else {
-        Standard_Real dab = Pa.SquareDistance(Pb);
-        Standard_Real dap = Pa.SquareDistance(PStart);
-
-        if(dap < dab) {
-          isOnLine = Standard_True;
+          if(d < Deflection2) {
+            isOnLine = Standard_True;
+          }
         } else {
-          Standard_Real dbp = Pb.SquareDistance(PStart);
+          Standard_Real dab = Pa.SquareDistance(Pb);
+          Standard_Real dap = Pa.SquareDistance(PStart);
 
-          if(dbp < dab) {
+          if(dap < dab) {
             isOnLine = Standard_True;
+          } else {
+            Standard_Real dbp = Pb.SquareDistance(PStart);
+
+            if(dbp < dab) {
+              isOnLine = Standard_True;
+            }
           }
         }
       }
-    }
   }
 
   return isOnLine;
@@ -3292,7 +3412,7 @@ void AddWLine(IntPatch_SequenceOfLine      &theLines,
   while (i <= aNbLines) {
     Handle(IntPatch_WLine) aWLine =
       Handle(IntPatch_WLine)::DownCast(theLines.Value(i));
-    
+
     isToRemove = Standard_False;
 
     if (aWLine.IsNull() == Standard_False) {
index 29e0ad0d5f261f743d3c696df71231927caa8c6f..5746f7647e24f4f42921ffbc2c776863ce1b11a3 100644 (file)
@@ -34,7 +34,8 @@ is
                     Domain    : TopolTool from Adaptor3d; 
                     OtherSurf : HSurface from Adaptor3d; 
                     OnFirst   : Boolean from Standard ;
-                    Tol       : Real from Standard)
+                    Tol       : Real from Standard;
+                    hasBeenAdded: Boolean from Standard = Standard_False)
 
        raises DomainError from Standard;
        --- The exception is raised if the Line from is neither
index 6665afc51aa93bc4f1bab7535b9a8976116eff43..026de15bd1be8dcad06b814892922dd3a4a53fc1 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -445,7 +445,8 @@ void IntPatch_RstInt::PutVertexOnLine (Handle(IntPatch_Line)& L,
                                       const Handle(Adaptor3d_TopolTool)& Domain,
                                       const Handle(Adaptor3d_HSurface)& OtherSurf,
                                       const Standard_Boolean OnFirst,
-                                      const Standard_Real Tol )
+                                      const Standard_Real Tol,
+               const Standard_Boolean hasBeenAdded)
  {
 
 // Domain est le domaine de restriction de la surface Surf.
@@ -699,13 +700,15 @@ void IntPatch_RstInt::PutVertexOnLine (Handle(IntPatch_Line)& L,
              (!Domain->Has3d() && Standard_Integer(nptCh)+1 < Nbptlin);
            if (!isNptLow && !IsSegment2dSmall(Brise,UMinAr,UMaxAr,tolU,tolV)) {
              // treat both ends
-             Standard_Real UMinChP,UMaxChP,UMinArP,UMaxArP;
-             UMinChP = IntegerPart(UMinCh); UMinArP = IntegerPart(UMinAr);
-             UMaxChP = IntegerPart(UMaxCh); UMaxArP = IntegerPart(UMaxAr);
-             Standard_Integer irangCh1,irangCh2,irangAr1,irangAr2;
-             irangCh1 = Standard_Integer(UMinChP)+1; irangCh2 = Standard_Integer(UMaxChP)+1;
-             irangAr1 = Standard_Integer(UMinArP)+1; irangAr2 = Standard_Integer(UMaxArP)+1;
-             UMinChP = UMinCh - UMinChP; UMinArP = UMinAr - UMinArP;
+             Standard_Real UMinChP,UMinArP,UMaxArP;
+             UMinChP = IntegerPart(UMinCh);
+              UMinArP = IntegerPart(UMinAr);
+              UMaxArP = IntegerPart(UMaxAr);
+             Standard_Integer irangAr1,irangAr2;
+             irangAr1 = Standard_Integer(UMinArP)+1;
+              irangAr2 = Standard_Integer(UMaxArP)+1;
+             UMinChP = UMinCh - UMinChP;
+              UMinArP = UMinAr - UMinArP;
              //UMaxChP = UMaxCh - UMaxChP; UMaxArP = UMaxAr - UMaxArP;
              const Standard_Real eps = 1e-10;
 //           Standard_Boolean isChExtr1 = irangCh1==1 && UMinChP<eps;
@@ -1227,7 +1230,7 @@ void IntPatch_RstInt::PutVertexOnLine (Handle(IntPatch_Line)& L,
 */
 
     wlin->SetPeriod(pu1,pv1,pu2,pv2);
-    wlin->ComputeVertexParameters(Tol);
+    wlin->ComputeVertexParameters(Tol, hasBeenAdded);
   }
   else {
 #ifdef DEB
index d22d273ea6441d7d22797af88f8729a237573e14..c3624cc7554e55e00357d6ac3f050efd85c336c7 100644 (file)
@@ -236,7 +236,9 @@ is
        is static;
 
 
-    ComputeVertexParameters(me: mutable; Tol: Real from Standard)
+    ComputeVertexParameters(me: mutable;
+                            Tol: Real from Standard;
+                            hasBeenAdded: Boolean from Standard = Standard_False)
     
        ---Purpose: Set the parameters of all the vertex on the line.
        --          if a vertex is already in the line, 
index 6faaf1849ff56f9552273f25ccf0c0d3a753f8f1..181639ee05f33157a18ebbb1e6dc397c4122b9ba 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -238,8 +238,9 @@ inline Standard_Boolean CompareVerticesOnS2(const IntPatch_Point& vtx1, const In
 {return CompareVerticesOnSurf (vtx1, vtx2, Standard_False);}
 
 
-void IntPatch_WLine::ComputeVertexParameters(const Standard_Real RTol) { 
-
+void IntPatch_WLine::ComputeVertexParameters( const Standard_Real RTol,
+                                              const Standard_Boolean hasBeenAdded)
+{
   // MSV Oct 15, 2001: use tolerance of vertex instead of RTol where 
   //                   it is possible
 
@@ -247,9 +248,6 @@ void IntPatch_WLine::ComputeVertexParameters(const Standard_Real RTol) {
   Standard_Integer indicevertexonline;
   Standard_Real    indicevertex;
 
-  Standard_Real ParamMinOnLine,ParamMaxOnLine;
-  if(fipt) { ParamMinOnLine = Vertex(indf).ParameterOnLine(); } else { ParamMinOnLine = -100000.0; } 
-  if(lapt) { ParamMaxOnLine = Vertex(indl).ParameterOnLine(); } else { ParamMaxOnLine =  100000.0; } 
   Standard_Boolean APointDeleted = Standard_False;
   //----------------------------------------------------------
   //--     F i l t r e   s u r   r e s t r i c t i o n s   --
@@ -466,9 +464,9 @@ void IntPatch_WLine::ComputeVertexParameters(const Standard_Real RTol) {
   Standard_Real dmini = Precision::Confusion();
   dmini*=dmini;
   for(i=2; i<=nbponline; i++) { 
-    //const IntSurf_PntOn2S& aPntOn2S1=curv->Value(i-1);
-    //const IntSurf_PntOn2S& aPntOn2S2=curv->Value(i);
-    Standard_Real d = (curv->Value(i-1).Value()).SquareDistance((curv->Value(i).Value()));
+    const IntSurf_PntOn2S& aPnt1=curv->Value(i-1);
+    const IntSurf_PntOn2S& aPnt2=curv->Value(i);
+    Standard_Real d = (aPnt1.Value()).SquareDistance((aPnt2.Value()));
     if(d < dmini) { 
       curv->RemovePoint(i);
       nbponline--;
@@ -476,10 +474,10 @@ void IntPatch_WLine::ComputeVertexParameters(const Standard_Real RTol) {
       //-- On recadre les Vertex si besoin 
       //-- 
       for(j=1; j<=nbvtx; j++) { 
-       indicevertex = svtx.Value(j).ParameterOnLine();
-       if(indicevertex >= i) {
-         svtx.ChangeValue(j).SetParameter(indicevertex-1.0);
-       }
+        indicevertex = svtx.Value(j).ParameterOnLine();
+        if(indicevertex >= i) {
+          svtx.ChangeValue(j).SetParameter(indicevertex-1.0);
+        }
       }
       //modified by NIZNHY-PKV Mon Feb 11 09:28:02 2002 f
       i--;
@@ -490,7 +488,30 @@ void IntPatch_WLine::ComputeVertexParameters(const Standard_Real RTol) {
   for(i=1; i<=nbvtx; i++) {
     const gp_Pnt& P    = svtx.Value(i).Value();
     Standard_Real vTol = svtx.Value(i).Tolerance();
-    indicevertex = svtx.Value(i).ParameterOnLine();
+    
+    if(hasBeenAdded)
+    {
+      if(nbvtx == 2)
+      {
+        if(i == nbvtx)
+        {
+          indicevertex = curv->NbPoints();
+        }
+        else
+        {
+          indicevertex = svtx.Value(i).ParameterOnLine();
+        }
+      }
+      else
+      {
+        indicevertex = svtx.Value(i).ParameterOnLine();
+      }
+    }
+    else
+    {
+      indicevertex = svtx.Value(i).ParameterOnLine();
+    }
+    
     indicevertexonline = (Standard_Integer)indicevertex;
     //--------------------------------------------------
     //-- On Compare le vertex avec les points de la ligne
index 5d58450d8c254c0e9f34978b8b5e770eaab76dcf..af39b6dcb4eb8300b94a36f86e091fc9fe227a3c 100644 (file)
@@ -2187,7 +2187,7 @@ void CalculPtsInterTriEdgeCoplanaires2(const Standard_Integer TriSurfID,
     Standard_Real p2p = Per.Dot(PE2);
     Standard_Real p0p = Per.Dot(PT1);
     ///The edge are PT1 are projected on the perpendicular of the side in the plane of the triangle
-    if ( ( (p1p>=p0p)&&(p0p>=p2p) )||( (p1p<=p0p)&&(p0p<=p2p) ) ) {
+    if ( fabs(p1p-p2p) > gp::Resolution() && ( (p1p>=p0p)&&(p0p>=p2p) )||( (p1p<=p0p)&&(p0p<=p2p) ) ) {
       Standard_Real lambda=(p1p-p0p)/(p1p-p2p);
       if (lambda<-MyConfusionPrecision) {
 
index 1734bc70968d9721f30da3f8ad838994a626de7c..9117d57f411fd3801236b45606d584f4eb17b0f9 100644 (file)
@@ -563,6 +563,10 @@ static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1,
         aP2S.SetValue(aU2,aV2,aU1,aV1);
       }
     }
+    //
+    Standard_Boolean anAproxTmp = myApprox1;
+    myApprox1 = myApprox2;
+    myApprox2 = anAproxTmp;
   }
 
 
@@ -3568,15 +3572,15 @@ gp_Pnt2d AdjustByNeighbour(const gp_Pnt2d&     theaNeighbourPoint,
 // purpose:
 // ------------------------------------------------------------------------------------------------
 Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine,
-                                     const Handle(GeomAdaptor_HSurface)&            theSurface1, 
-                                     const Handle(GeomAdaptor_HSurface)&            theSurface2,
-                                     const TopoDS_Face&                             theFace1,
-                                     const TopoDS_Face&                             theFace2,
-                                     const IntTools_LineConstructor&                theLConstructor,
-                                     const Standard_Boolean                         theAvoidLConstructor,
-                                     IntPatch_SequenceOfLine&                       theNewLines,
-                                     Standard_Real&                                 theReachedTol3d,
-                                     const Handle(BOPInt_Context)& aContext) 
+                                      const Handle(GeomAdaptor_HSurface)&            theSurface1, 
+                                      const Handle(GeomAdaptor_HSurface)&            theSurface2,
+                                      const TopoDS_Face&                             theFace1,
+                                      const TopoDS_Face&                             theFace2,
+                                      const IntTools_LineConstructor&                theLConstructor,
+                                      const Standard_Boolean                         theAvoidLConstructor,
+                                      IntPatch_SequenceOfLine&                       theNewLines,
+                                      Standard_Real&                                 theReachedTol3d,
+                                      const Handle(BOPInt_Context)& aContext) 
 {
 
   Standard_Boolean bRet, bAvoidLineConstructor;
@@ -3607,7 +3611,7 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine,
   Handle(TColgp_HArray1OfPnt2d) aTanZoneS2;
   Handle(TColStd_HArray1OfReal) aTanZoneRadius;
   Standard_Integer aNbZone = ComputeTangentZones( theSurface1, theSurface2, theFace1, theFace2,
-                                                aTanZoneS1, aTanZoneS2, aTanZoneRadius, aContext);
+                                                 aTanZoneS1, aTanZoneS2, aTanZoneRadius, aContext);
   
   //
   nblines=0;
@@ -3633,83 +3637,83 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine,
       Handle(GeomAdaptor_HSurface) aGASurface = (!i) ? theSurface1 : theSurface2;
       aGASurface->ChangeSurface().Surface()->Bounds(umin, umax, vmin, vmax);
       if(!i) {
-       aPoint.ParametersOnS1(U, V);
+        aPoint.ParametersOnS1(U, V);
       }
       else {
-       aPoint.ParametersOnS2(U, V);
+        aPoint.ParametersOnS2(U, V);
       }
       // U, V
       for(j = 0; j < 2; j++) {
-       isperiodic = (!j) ? aGASurface->IsUPeriodic() : aGASurface->IsVPeriodic();
-       if(!isperiodic){
-         continue;
-       }
-       //
-       if (!j) {
-         aResolution=aGASurface->UResolution(aTol);
-         aPeriod=aGASurface->UPeriod();
-         alowerboundary=umin;
-         aupperboundary=umax;
-         aParameter=U;
-       }
-       else {
-         aResolution=aGASurface->VResolution(aTol);
-         aPeriod=aGASurface->VPeriod();
-         alowerboundary=vmin;
-         aupperboundary=vmax;
-         aParameter=V;
-       }
-       
-       anoffset = 0.;
-       anAdjustPar = AdjustPeriodic(aParameter, 
-                                    alowerboundary, 
-                                    aupperboundary, 
-                                    aPeriod, 
-                                    anoffset);
-       //
-       bIsOnFirstBoundary = Standard_True;// ?
-       bIsPointOnBoundary=
-         IsPointOnBoundary(anAdjustPar, 
-                           alowerboundary, 
-                           aupperboundary,
-                           aResolution, 
-                           bIsOnFirstBoundary);
-       //
-       if(bIsPointOnBoundary) {
-         bIsCurrentPointOnBoundary = Standard_True;
-         break;
-       }
-       else {
-         // check if a point belong to a tangent zone. Begin
-         Standard_Integer zIt = 0;
-         for ( zIt = 1; zIt <= aNbZone; zIt++ ) {
-           gp_Pnt2d aPZone = (i == 0) ? aTanZoneS1->Value(zIt) : aTanZoneS2->Value(zIt);
-           Standard_Real aZoneRadius = aTanZoneRadius->Value(zIt);
-
-           if ( IsInsideTanZone(gp_Pnt2d( U, V ), aPZone, aZoneRadius, aGASurface ) ) {
-             // set boundary flag to split the curve by a tangent zone
-             bIsPointOnBoundary = Standard_True;
-             bIsCurrentPointOnBoundary = Standard_True;
-             if ( theReachedTol3d < aZoneRadius ) {
-               theReachedTol3d = aZoneRadius;
-             }
-             break;
-           }
-         }
-       }
+        isperiodic = (!j) ? aGASurface->IsUPeriodic() : aGASurface->IsVPeriodic();
+        if(!isperiodic){
+          continue;
+        }
+        //
+        if (!j) {
+          aResolution=aGASurface->UResolution(aTol);
+          aPeriod=aGASurface->UPeriod();
+          alowerboundary=umin;
+          aupperboundary=umax;
+          aParameter=U;
+        }
+        else {
+          aResolution=aGASurface->VResolution(aTol);
+          aPeriod=aGASurface->VPeriod();
+          alowerboundary=vmin;
+          aupperboundary=vmax;
+          aParameter=V;
+        }
+        
+        anoffset = 0.;
+        anAdjustPar = AdjustPeriodic(aParameter, 
+                                       alowerboundary, 
+                                       aupperboundary, 
+                                       aPeriod,
+                                       anoffset);
+        //
+        bIsOnFirstBoundary = Standard_True;// ?
+        bIsPointOnBoundary=
+          IsPointOnBoundary(anAdjustPar, 
+                            alowerboundary, 
+                            aupperboundary,
+                            aResolution, 
+                            bIsOnFirstBoundary);
+        //
+        if(bIsPointOnBoundary) {
+          bIsCurrentPointOnBoundary = Standard_True;
+          break;
+        }
+        else {
+          // check if a point belong to a tangent zone. Begin
+          Standard_Integer zIt = 0;
+          for ( zIt = 1; zIt <= aNbZone; zIt++ ) {
+            gp_Pnt2d aPZone = (i == 0) ? aTanZoneS1->Value(zIt) : aTanZoneS2->Value(zIt);
+            Standard_Real aZoneRadius = aTanZoneRadius->Value(zIt);
+
+            if ( IsInsideTanZone(gp_Pnt2d( U, V ), aPZone, aZoneRadius, aGASurface ) ) {
+              // set boundary flag to split the curve by a tangent zone
+              bIsPointOnBoundary = Standard_True;
+              bIsCurrentPointOnBoundary = Standard_True;
+              if ( theReachedTol3d < aZoneRadius ) {
+                theReachedTol3d = aZoneRadius;
+              }
+              break;
+            }
+          }
+        }
       }//for(j = 0; j < 2; j++) {
 
       if(bIsCurrentPointOnBoundary){
-       break;
+        break;
       }
     }//for(i = 0; i < 2; ++i) {
     //
     if((bIsCurrentPointOnBoundary != bIsPrevPointOnBoundary)) {
       if(!aListOfPointIndex.IsEmpty()) {
-       nblines++;
-       anArrayOfLines.SetValue(nblines, aListOfPointIndex);
-       anArrayOfLineType.SetValue(nblines, bIsPrevPointOnBoundary);
-       aListOfPointIndex.Clear();
+        nblines++;
+        anArrayOfLines.SetValue(nblines, aListOfPointIndex);
+        anArrayOfLineType.SetValue(nblines, bIsPrevPointOnBoundary);
+        aListOfPointIndex.Clear();
       }
       bIsPrevPointOnBoundary = bIsCurrentPointOnBoundary;
     }
@@ -3737,376 +3741,381 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine,
       continue;
     }
     const TColStd_ListOfInteger& aListOfIndex = anArrayOfLines.Value(i);
-    if(aListOfIndex.Extent() < 2) {
-      continue;
-    }
     TColStd_ListOfInteger aListOfFLIndex;
 
     for(j = 0; j < 2; j++) {
       Standard_Integer aneighbourindex = (j == 0) ? (i - 1) : (i + 1);
 
       if((aneighbourindex < 1) || (aneighbourindex > nblines))
-       continue;
+        continue;
 
       if(anArrayOfLineType.Value(aneighbourindex) == 0)
-       continue;
+        continue;
       const TColStd_ListOfInteger& aNeighbour = anArrayOfLines.Value(aneighbourindex);
       Standard_Integer anIndex = (j == 0) ? aNeighbour.Last() : aNeighbour.First();
       const IntSurf_PntOn2S& aPoint = theWLine->Point(anIndex);
 
       IntSurf_PntOn2S aNewP = aPoint;
-      
+      if(aListOfIndex.Extent() < 2) {
+        aSeqOfPntOn2S->Add(aNewP);
+        aListOfFLIndex.Append(aSeqOfPntOn2S->NbPoints());
+        continue;
+      }
+      //
+      Standard_Integer iFirst = aListOfIndex.First();
+      Standard_Integer iLast  = aListOfIndex.Last();
+      //
       for(Standard_Integer surfit = 0; surfit < 2; surfit++) {
 
-       Handle(GeomAdaptor_HSurface) aGASurface = (surfit == 0) ? theSurface1 : theSurface2;
-       Standard_Real umin=0., umax=0., vmin=0., vmax=0.;
-       aGASurface->ChangeSurface().Surface()->Bounds(umin, umax, vmin, vmax);
-       Standard_Real U=0., V=0.;
-
-       if(surfit == 0)
-         aNewP.ParametersOnS1(U, V);
-       else
-         aNewP.ParametersOnS2(U, V);
-       Standard_Integer nbboundaries = 0;
-
-       Standard_Boolean bIsNearBoundary = Standard_False;
-       Standard_Integer aZoneIndex = 0;
-       Standard_Integer bIsUBoundary = Standard_False; // use if nbboundaries == 1
-       Standard_Integer bIsFirstBoundary = Standard_False; // use if nbboundaries == 1
-       
-
-       for(Standard_Integer parit = 0; parit < 2; parit++) {
-         Standard_Boolean isperiodic = (parit == 0) ? aGASurface->IsUPeriodic() : aGASurface->IsVPeriodic();
+        Handle(GeomAdaptor_HSurface) aGASurface = (surfit == 0) ? theSurface1 : theSurface2;
+        Standard_Real umin=0., umax=0., vmin=0., vmax=0.;
+        aGASurface->ChangeSurface().Surface()->Bounds(umin, umax, vmin, vmax);
+        Standard_Real U=0., V=0.;
 
-         Standard_Real aResolution = (parit == 0) ? aGASurface->UResolution(aTol) : aGASurface->VResolution(aTol);
-         Standard_Real alowerboundary = (parit == 0) ? umin : vmin;
-         Standard_Real aupperboundary = (parit == 0) ? umax : vmax;
+        if(surfit == 0)
+          aNewP.ParametersOnS1(U, V);
+        else
+          aNewP.ParametersOnS2(U, V);
+        Standard_Integer nbboundaries = 0;
 
-         Standard_Real aParameter = (parit == 0) ? U : V;
-         Standard_Boolean bIsOnFirstBoundary = Standard_True;
-  
-         if(!isperiodic) {
-           bIsPointOnBoundary=
-             IsPointOnBoundary(aParameter, alowerboundary, aupperboundary, aResolution, bIsOnFirstBoundary);
-           if(bIsPointOnBoundary) {
-             bIsUBoundary = (parit == 0);
-             bIsFirstBoundary = bIsOnFirstBoundary;
-             nbboundaries++;
-           }
-         }
-         else {
-           Standard_Real aPeriod     = (parit == 0) ? aGASurface->UPeriod() : aGASurface->VPeriod();
-           Standard_Real anoffset = 0.;
-           Standard_Real anAdjustPar = AdjustPeriodic(aParameter, alowerboundary, aupperboundary, aPeriod, anoffset);
-
-           bIsPointOnBoundary=
-             IsPointOnBoundary(anAdjustPar, alowerboundary, aupperboundary, aResolution, bIsOnFirstBoundary);
-           if(bIsPointOnBoundary) {
-             bIsUBoundary = (parit == 0);
-             bIsFirstBoundary = bIsOnFirstBoundary;
-             nbboundaries++;
-           }
-           else {
-             //check neighbourhood of boundary
-             Standard_Real anEpsilon = aResolution * 100.;
-             Standard_Real aPart = ( aupperboundary - alowerboundary ) * 0.1;
-             anEpsilon = ( anEpsilon > aPart ) ? aPart : anEpsilon;
-               
-             bIsNearBoundary = IsPointOnBoundary(anAdjustPar, alowerboundary, aupperboundary, 
-                                                 anEpsilon, bIsOnFirstBoundary);
-
-           }
-         }
-       }
+        Standard_Boolean bIsNearBoundary = Standard_False;
+        Standard_Integer aZoneIndex = 0;
+        Standard_Integer bIsUBoundary = Standard_False; // use if nbboundaries == 1
+        Standard_Integer bIsFirstBoundary = Standard_False; // use if nbboundaries == 1
+        
 
-       // check if a point belong to a tangent zone. Begin
-       for ( Standard_Integer zIt = 1; zIt <= aNbZone; zIt++ ) {
-         gp_Pnt2d aPZone = (surfit == 0) ? aTanZoneS1->Value(zIt) : aTanZoneS2->Value(zIt);
-         Standard_Real aZoneRadius = aTanZoneRadius->Value(zIt);
-
-         Standard_Integer aneighbourpointindex1 = (j == 0) ? aListOfIndex.First() : aListOfIndex.Last();
-         const IntSurf_PntOn2S& aNeighbourPoint = theWLine->Point(aneighbourpointindex1);
-         Standard_Real nU1, nV1;
-           
-         if(surfit == 0)
-           aNeighbourPoint.ParametersOnS1(nU1, nV1);
-         else
-           aNeighbourPoint.ParametersOnS2(nU1, nV1);
-         gp_Pnt2d ap1(nU1, nV1);
-         gp_Pnt2d ap2 = AdjustByNeighbour( ap1, gp_Pnt2d( U, V ), aGASurface );
-
-
-         if ( IsInsideTanZone( ap2, aPZone, aZoneRadius, aGASurface ) ) {
-           aZoneIndex = zIt;
-           bIsNearBoundary = Standard_True;
-           if ( theReachedTol3d < aZoneRadius ) {
-             theReachedTol3d = aZoneRadius;
-           }
-         }
-       }
-       // check if a point belong to a tangent zone. End
-       Standard_Boolean bComputeLineEnd = Standard_False;
+        for(Standard_Integer parit = 0; parit < 2; parit++) {
+          Standard_Boolean isperiodic = (parit == 0) ? aGASurface->IsUPeriodic() : aGASurface->IsVPeriodic();
 
-       if(nbboundaries == 2) {
-         //xf
-         bComputeLineEnd = Standard_True;
-         //xt
-       }
-       else if(nbboundaries == 1) {
-         Standard_Boolean isperiodic = (bIsUBoundary) ? aGASurface->IsUPeriodic() : aGASurface->IsVPeriodic();
-
-         if(isperiodic) {
-           Standard_Real alowerboundary = (bIsUBoundary) ? umin : vmin;
-           Standard_Real aupperboundary = (bIsUBoundary) ? umax : vmax;
-           Standard_Real aPeriod     = (bIsUBoundary) ? aGASurface->UPeriod() : aGASurface->VPeriod();
-           Standard_Real aParameter = (bIsUBoundary) ? U : V;
-           Standard_Real anoffset = 0.;
-           Standard_Real anAdjustPar = AdjustPeriodic(aParameter, alowerboundary, aupperboundary, aPeriod, anoffset);
-
-           Standard_Real adist = (bIsFirstBoundary) ? fabs(anAdjustPar - alowerboundary) : fabs(anAdjustPar - aupperboundary);
-           Standard_Real anotherPar = (bIsFirstBoundary) ? (aupperboundary - adist) : (alowerboundary + adist);
-           anotherPar += anoffset;
-           Standard_Integer aneighbourpointindex = (j == 0) ? aListOfIndex.First() : aListOfIndex.Last();
-           const IntSurf_PntOn2S& aNeighbourPoint = theWLine->Point(aneighbourpointindex);
-           Standard_Real nU1, nV1;
-
-           if(surfit == 0)
-             aNeighbourPoint.ParametersOnS1(nU1, nV1);
-           else
-             aNeighbourPoint.ParametersOnS2(nU1, nV1);
-           
-           Standard_Real adist1 = (bIsUBoundary) ? fabs(nU1 - U) : fabs(nV1 - V);
-           Standard_Real adist2 = (bIsUBoundary) ? fabs(nU1 - anotherPar) : fabs(nV1 - anotherPar);
-           bComputeLineEnd = Standard_True;
-           Standard_Boolean bCheckAngle1 = Standard_False;
-           Standard_Boolean bCheckAngle2 = Standard_False;
-           gp_Vec2d aNewVec;
-           Standard_Real anewU = (bIsUBoundary) ? anotherPar : U;
-           Standard_Real anewV = (bIsUBoundary) ? V : anotherPar;
-
-           if(((adist1 - adist2) > Precision::PConfusion()) && 
-              (adist2 < (aPeriod / 4.))) {
-             bCheckAngle1 = Standard_True;
-             aNewVec = gp_Vec2d(gp_Pnt2d(nU1, nV1), gp_Pnt2d(anewU, anewV));
-
-             if(aNewVec.SquareMagnitude() < (gp::Resolution() * gp::Resolution())) {
-               aNewP.SetValue((surfit == 0), anewU, anewV);
-               bCheckAngle1 = Standard_False;
-             }
-           }
-           else if(adist1 < (aPeriod / 4.)) {
-             bCheckAngle2 = Standard_True;
-             aNewVec = gp_Vec2d(gp_Pnt2d(nU1, nV1), gp_Pnt2d(U, V));
+          Standard_Real aResolution = (parit == 0) ? aGASurface->UResolution(aTol) : aGASurface->VResolution(aTol);
+          Standard_Real alowerboundary = (parit == 0) ? umin : vmin;
+          Standard_Real aupperboundary = (parit == 0) ? umax : vmax;
 
-             if(aNewVec.SquareMagnitude() < (gp::Resolution() * gp::Resolution())) {
-               bCheckAngle2 = Standard_False;
-             }
-           }
-
-           if(bCheckAngle1 || bCheckAngle2) {
-             // assume there are at least two points in line (see "if" above)
-             Standard_Integer anindexother = aneighbourpointindex;
+          Standard_Real aParameter = (parit == 0) ? U : V;
+          Standard_Boolean bIsOnFirstBoundary = Standard_True;
+  
+          if(!isperiodic) {
+            bIsPointOnBoundary=
+              IsPointOnBoundary(aParameter, alowerboundary, aupperboundary, aResolution, bIsOnFirstBoundary);
+            if(bIsPointOnBoundary) {
+              bIsUBoundary = (parit == 0);
+              bIsFirstBoundary = bIsOnFirstBoundary;
+              nbboundaries++;
+            }
+          }
+          else {
+            Standard_Real aPeriod     = (parit == 0) ? aGASurface->UPeriod() : aGASurface->VPeriod();
+            Standard_Real anoffset = 0.;
+            Standard_Real anAdjustPar = AdjustPeriodic(aParameter, alowerboundary, aupperboundary, aPeriod, anoffset);
+
+            bIsPointOnBoundary=
+              IsPointOnBoundary(anAdjustPar, alowerboundary, aupperboundary, aResolution, bIsOnFirstBoundary);
+            if(bIsPointOnBoundary) {
+              bIsUBoundary = (parit == 0);
+              bIsFirstBoundary = bIsOnFirstBoundary;
+              nbboundaries++;
+            }
+            else {
+            //check neighbourhood of boundary
+            Standard_Real anEpsilon = aResolution * 100.;
+            Standard_Real aPart = ( aupperboundary - alowerboundary ) * 0.1;
+            anEpsilon = ( anEpsilon > aPart ) ? aPart : anEpsilon;
+            
+              bIsNearBoundary = IsPointOnBoundary(anAdjustPar, alowerboundary, aupperboundary, 
+                                                  anEpsilon, bIsOnFirstBoundary);
 
-             while((anindexother <= aListOfIndex.Last()) && (anindexother >= aListOfIndex.First())) {
-               anindexother = (j == 0) ? (anindexother + 1) : (anindexother - 1);
-               const IntSurf_PntOn2S& aPrevNeighbourPoint = theWLine->Point(anindexother);
-               Standard_Real nU2, nV2;
-               
-               if(surfit == 0)
-                 aPrevNeighbourPoint.ParametersOnS1(nU2, nV2);
-               else
-                 aPrevNeighbourPoint.ParametersOnS2(nU2, nV2);
-               gp_Vec2d aVecOld(gp_Pnt2d(nU2, nV2), gp_Pnt2d(nU1, nV1));
-
-               if(aVecOld.SquareMagnitude() <= (gp::Resolution() * gp::Resolution())) {
-                 continue;
-               }
-               else {
-                 Standard_Real anAngle = aNewVec.Angle(aVecOld);
-
-                 if((fabs(anAngle) < (M_PI * 0.25)) && (aNewVec.Dot(aVecOld) > 0.)) {
-
-                   if(bCheckAngle1) {
-                     Standard_Real U1, U2, V1, V2;
-                     IntSurf_PntOn2S atmppoint = aNewP;
-                     atmppoint.SetValue((surfit == 0), anewU, anewV);
-                     atmppoint.Parameters(U1, V1, U2, V2);
-                     gp_Pnt P1 = theSurface1->Value(U1, V1);
-                     gp_Pnt P2 = theSurface2->Value(U2, V2);
-                     gp_Pnt P0 = aPoint.Value();
-
-                     if(P0.IsEqual(P1, aTol) &&
-                        P0.IsEqual(P2, aTol) &&
-                        P1.IsEqual(P2, aTol)) {
-                       bComputeLineEnd = Standard_False;
-                       aNewP.SetValue((surfit == 0), anewU, anewV);
-                     }
-                   }
-
-                   if(bCheckAngle2) {
-                     bComputeLineEnd = Standard_False;
-                   }
-                 }
-                 break;
-               }
-             } // end while(anindexother...)
-           }
-         }
-       }
-       else if ( bIsNearBoundary ) {
-         bComputeLineEnd = Standard_True;
-       }
+            }
+          }
+        }
 
-       if(bComputeLineEnd) {
-
-         gp_Pnt2d anewpoint;
-         Standard_Boolean found = Standard_False;
-
-         if ( bIsNearBoundary ) {
-           // re-compute point near natural boundary or near tangent zone
-           Standard_Real u1, v1, u2, v2;
-           aNewP.Parameters( u1, v1, u2, v2 );
-           if(surfit == 0)
-             anewpoint = gp_Pnt2d( u1, v1 );
-           else
-             anewpoint = gp_Pnt2d( u2, v2 );
-           
-           Standard_Integer aneighbourpointindex1 = (j == 0) ? aListOfIndex.First() : aListOfIndex.Last();
-           const IntSurf_PntOn2S& aNeighbourPoint = theWLine->Point(aneighbourpointindex1);
-           Standard_Real nU1, nV1;
-           
-           if(surfit == 0)
-             aNeighbourPoint.ParametersOnS1(nU1, nV1);
-           else
-             aNeighbourPoint.ParametersOnS2(nU1, nV1);
-           gp_Pnt2d ap1(nU1, nV1);
-           gp_Pnt2d ap2;
-
-
-           if ( aZoneIndex ) {
-             // exclude point from a tangent zone
-             anewpoint = AdjustByNeighbour( ap1, anewpoint, aGASurface );
-             gp_Pnt2d aPZone = (surfit == 0) ? aTanZoneS1->Value(aZoneIndex) : aTanZoneS2->Value(aZoneIndex);
-             Standard_Real aZoneRadius = aTanZoneRadius->Value(aZoneIndex);
-
-             if ( FindPoint(ap1, anewpoint, umin, umax, vmin, vmax, 
-                            aPZone, aZoneRadius, aGASurface, ap2) ) {
-               anewpoint = ap2;
-               found = Standard_True;
-             }
-           }
-           else if ( aGASurface->IsUPeriodic() || aGASurface->IsVPeriodic() ) {
-             // re-compute point near boundary if shifted on a period
-             ap2 = AdjustByNeighbour( ap1, anewpoint, aGASurface );
+        // check if a point belong to a tangent zone. Begin
+        for ( Standard_Integer zIt = 1; zIt <= aNbZone; zIt++ ) {
+          gp_Pnt2d aPZone = (surfit == 0) ? aTanZoneS1->Value(zIt) : aTanZoneS2->Value(zIt);
+          Standard_Real aZoneRadius = aTanZoneRadius->Value(zIt);
+
+          Standard_Integer aneighbourpointindex1 = (j == 0) ? iFirst : iLast;
+          const IntSurf_PntOn2S& aNeighbourPoint = theWLine->Point(aneighbourpointindex1);
+          Standard_Real nU1, nV1;
+            
+          if(surfit == 0)
+            aNeighbourPoint.ParametersOnS1(nU1, nV1);
+          else
+            aNeighbourPoint.ParametersOnS2(nU1, nV1);
+          gp_Pnt2d ap1(nU1, nV1);
+          gp_Pnt2d ap2 = AdjustByNeighbour( ap1, gp_Pnt2d( U, V ), aGASurface );
+
+
+          if ( IsInsideTanZone( ap2, aPZone, aZoneRadius, aGASurface ) ) {
+            aZoneIndex = zIt;
+            bIsNearBoundary = Standard_True;
+            if ( theReachedTol3d < aZoneRadius ) {
+              theReachedTol3d = aZoneRadius;
+            }
+          }
+        }
+        // check if a point belong to a tangent zone. End
+        Standard_Boolean bComputeLineEnd = Standard_False;
 
-             if ( ( ap2.X() < umin ) || ( ap2.X() > umax ) ||
-                 ( ap2.Y() < vmin ) || ( ap2.Y() > vmax ) ) {
-               found = FindPoint(ap1, ap2, umin, umax, vmin, vmax, anewpoint);
-             }
-             else {
-               anewpoint = ap2;
-               aNewP.SetValue( (surfit == 0), anewpoint.X(), anewpoint.Y() );
-             }
-           }
-         }
-         else {
+        if(nbboundaries == 2) {
+          //xf
+          bComputeLineEnd = Standard_True;
+          //xt
+        }
+        else if(nbboundaries == 1) {
+          Standard_Boolean isperiodic = (bIsUBoundary) ? aGASurface->IsUPeriodic() : aGASurface->IsVPeriodic();
+
+          if(isperiodic) {
+            Standard_Real alowerboundary = (bIsUBoundary) ? umin : vmin;
+            Standard_Real aupperboundary = (bIsUBoundary) ? umax : vmax;
+            Standard_Real aPeriod     = (bIsUBoundary) ? aGASurface->UPeriod() : aGASurface->VPeriod();
+            Standard_Real aParameter = (bIsUBoundary) ? U : V;
+            Standard_Real anoffset = 0.;
+            Standard_Real anAdjustPar = AdjustPeriodic(aParameter, alowerboundary, aupperboundary, aPeriod, anoffset);
+
+            Standard_Real adist = (bIsFirstBoundary) ? fabs(anAdjustPar - alowerboundary) : fabs(anAdjustPar - aupperboundary);
+            Standard_Real anotherPar = (bIsFirstBoundary) ? (aupperboundary - adist) : (alowerboundary + adist);
+            anotherPar += anoffset;
+            Standard_Integer aneighbourpointindex = (j == 0) ? aListOfIndex.First() : aListOfIndex.Last();
+            const IntSurf_PntOn2S& aNeighbourPoint = theWLine->Point(aneighbourpointindex);
+            Standard_Real nU1, nV1;
+
+            if(surfit == 0)
+              aNeighbourPoint.ParametersOnS1(nU1, nV1);
+            else
+              aNeighbourPoint.ParametersOnS2(nU1, nV1);
+            
+            Standard_Real adist1 = (bIsUBoundary) ? fabs(nU1 - U) : fabs(nV1 - V);
+            Standard_Real adist2 = (bIsUBoundary) ? fabs(nU1 - anotherPar) : fabs(nV1 - anotherPar);
+            bComputeLineEnd = Standard_True;
+            Standard_Boolean bCheckAngle1 = Standard_False;
+            Standard_Boolean bCheckAngle2 = Standard_False;
+            gp_Vec2d aNewVec;
+            Standard_Real anewU = (bIsUBoundary) ? anotherPar : U;
+            Standard_Real anewV = (bIsUBoundary) ? V : anotherPar;
+
+            if(((adist1 - adist2) > Precision::PConfusion()) && 
+               (adist2 < (aPeriod / 4.))) {
+              bCheckAngle1 = Standard_True;
+              aNewVec = gp_Vec2d(gp_Pnt2d(nU1, nV1), gp_Pnt2d(anewU, anewV));
+
+              if(aNewVec.SquareMagnitude() < (gp::Resolution() * gp::Resolution())) {
+                aNewP.SetValue((surfit == 0), anewU, anewV);
+                bCheckAngle1 = Standard_False;
+              }
+            }
+            else if(adist1 < (aPeriod / 4.)) {
+              bCheckAngle2 = Standard_True;
+              aNewVec = gp_Vec2d(gp_Pnt2d(nU1, nV1), gp_Pnt2d(U, V));
 
-           Standard_Integer aneighbourpointindex1 = (j == 0) ? aListOfIndex.First() : aListOfIndex.Last();
-           const IntSurf_PntOn2S& aNeighbourPoint = theWLine->Point(aneighbourpointindex1);
-           Standard_Real nU1, nV1;
-
-           if(surfit == 0)
-             aNeighbourPoint.ParametersOnS1(nU1, nV1);
-           else
-             aNeighbourPoint.ParametersOnS2(nU1, nV1);
-           gp_Pnt2d ap1(nU1, nV1);
-           gp_Pnt2d ap2(nU1, nV1);
-           Standard_Integer aneighbourpointindex2 = aneighbourpointindex1;
-
-           while((aneighbourpointindex2 <= aListOfIndex.Last()) && (aneighbourpointindex2 >= aListOfIndex.First())) {
-             aneighbourpointindex2 = (j == 0) ? (aneighbourpointindex2 + 1) : (aneighbourpointindex2 - 1);
-             const IntSurf_PntOn2S& aPrevNeighbourPoint = theWLine->Point(aneighbourpointindex2);
-             Standard_Real nU2, nV2;
-
-             if(surfit == 0)
-               aPrevNeighbourPoint.ParametersOnS1(nU2, nV2);
-             else
-               aPrevNeighbourPoint.ParametersOnS2(nU2, nV2);
-             ap2.SetX(nU2);
-             ap2.SetY(nV2);
+              if(aNewVec.SquareMagnitude() < (gp::Resolution() * gp::Resolution())) {
+                bCheckAngle2 = Standard_False;
+              }
+            }
 
-             if(ap1.SquareDistance(ap2) > (gp::Resolution() * gp::Resolution())) {
-               break;
-             }
-           }  
-           found = FindPoint(ap2, ap1, umin, umax, vmin, vmax, anewpoint);
-         }
+            if(bCheckAngle1 || bCheckAngle2) {
+              // assume there are at least two points in line (see "if" above)
+              Standard_Integer anindexother = aneighbourpointindex;
+
+              while((anindexother <= iLast) && (anindexother >= iFirst)) {
+                anindexother = (j == 0) ? (anindexother + 1) : (anindexother - 1);
+                const IntSurf_PntOn2S& aPrevNeighbourPoint = theWLine->Point(anindexother);
+                Standard_Real nU2, nV2;
+                
+                if(surfit == 0)
+                  aPrevNeighbourPoint.ParametersOnS1(nU2, nV2);
+                else
+                  aPrevNeighbourPoint.ParametersOnS2(nU2, nV2);
+                gp_Vec2d aVecOld(gp_Pnt2d(nU2, nV2), gp_Pnt2d(nU1, nV1));
+
+                if(aVecOld.SquareMagnitude() <= (gp::Resolution() * gp::Resolution())) {
+                  continue;
+                }
+                else {
+                  Standard_Real anAngle = aNewVec.Angle(aVecOld);
+
+                  if((fabs(anAngle) < (M_PI * 0.25)) && (aNewVec.Dot(aVecOld) > 0.)) {
+
+                    if(bCheckAngle1) {
+                      Standard_Real U1, U2, V1, V2;
+                      IntSurf_PntOn2S atmppoint = aNewP;
+                      atmppoint.SetValue((surfit == 0), anewU, anewV);
+                      atmppoint.Parameters(U1, V1, U2, V2);
+                      gp_Pnt P1 = theSurface1->Value(U1, V1);
+                      gp_Pnt P2 = theSurface2->Value(U2, V2);
+                      gp_Pnt P0 = aPoint.Value();
+
+                      if(P0.IsEqual(P1, aTol) &&
+                         P0.IsEqual(P2, aTol) &&
+                         P1.IsEqual(P2, aTol)) {
+                        bComputeLineEnd = Standard_False;
+                        aNewP.SetValue((surfit == 0), anewU, anewV);
+                      }
+                    }
+
+                    if(bCheckAngle2) {
+                      bComputeLineEnd = Standard_False;
+                    }
+                  }
+                  break;
+                }
+              } // end while(anindexother...)
+            }
+          }
+        }
+        else if ( bIsNearBoundary ) {
+          bComputeLineEnd = Standard_True;
+        }
 
-         if(found) {
-           // check point
-           Standard_Real aCriteria = BRep_Tool::Tolerance(theFace1) + BRep_Tool::Tolerance(theFace2);
-           GeomAPI_ProjectPointOnSurf& aProjector = 
-             (surfit == 0) ? aContext->ProjPS(theFace2) : aContext->ProjPS(theFace1);
-           Handle(GeomAdaptor_HSurface) aSurface = (surfit == 0) ? theSurface1 : theSurface2;
+        if(bComputeLineEnd) {
+
+          gp_Pnt2d anewpoint;
+          Standard_Boolean found = Standard_False;
+
+          if ( bIsNearBoundary ) {
+            // re-compute point near natural boundary or near tangent zone
+            Standard_Real u1, v1, u2, v2;
+            aNewP.Parameters( u1, v1, u2, v2 );
+            if(surfit == 0)
+              anewpoint = gp_Pnt2d( u1, v1 );
+            else
+              anewpoint = gp_Pnt2d( u2, v2 );
+            
+            Standard_Integer aneighbourpointindex1 = (j == 0) ? iFirst : iLast;
+            const IntSurf_PntOn2S& aNeighbourPoint = theWLine->Point(aneighbourpointindex1);
+            Standard_Real nU1, nV1;
+            
+            if(surfit == 0)
+              aNeighbourPoint.ParametersOnS1(nU1, nV1);
+            else
+              aNeighbourPoint.ParametersOnS2(nU1, nV1);
+            gp_Pnt2d ap1(nU1, nV1);
+            gp_Pnt2d ap2;
+
+
+            if ( aZoneIndex ) {
+              // exclude point from a tangent zone
+              anewpoint = AdjustByNeighbour( ap1, anewpoint, aGASurface );
+              gp_Pnt2d aPZone = (surfit == 0) ? aTanZoneS1->Value(aZoneIndex) : aTanZoneS2->Value(aZoneIndex);
+              Standard_Real aZoneRadius = aTanZoneRadius->Value(aZoneIndex);
+
+              if ( FindPoint(ap1, anewpoint, umin, umax, vmin, vmax, 
+                             aPZone, aZoneRadius, aGASurface, ap2) ) {
+                anewpoint = ap2;
+                found = Standard_True;
+              }
+            }
+            else if ( aGASurface->IsUPeriodic() || aGASurface->IsVPeriodic() ) {
+              // re-compute point near boundary if shifted on a period
+              ap2 = AdjustByNeighbour( ap1, anewpoint, aGASurface );
 
-           Handle(GeomAdaptor_HSurface) aSurfaceOther = (surfit == 0) ? theSurface2 : theSurface1;
+              if ( ( ap2.X() < umin ) || ( ap2.X() > umax ) ||
+                  ( ap2.Y() < vmin ) || ( ap2.Y() > vmax ) ) {
+                found = FindPoint(ap1, ap2, umin, umax, vmin, vmax, anewpoint);
+              }
+              else {
+                anewpoint = ap2;
+                aNewP.SetValue( (surfit == 0), anewpoint.X(), anewpoint.Y() );
+              }
+            }
+          }
+          else {
 
-           gp_Pnt aP3d = aSurface->Value(anewpoint.X(), anewpoint.Y());
-           aProjector.Perform(aP3d);
+            Standard_Integer aneighbourpointindex1 = (j == 0) ? iFirst : iLast;
+            const IntSurf_PntOn2S& aNeighbourPoint = theWLine->Point(aneighbourpointindex1);
+            Standard_Real nU1, nV1;
+
+            if(surfit == 0)
+              aNeighbourPoint.ParametersOnS1(nU1, nV1);
+            else
+              aNeighbourPoint.ParametersOnS2(nU1, nV1);
+            gp_Pnt2d ap1(nU1, nV1);
+            gp_Pnt2d ap2(nU1, nV1);
+            Standard_Integer aneighbourpointindex2 = aneighbourpointindex1;
+
+            while((aneighbourpointindex2 <= iLast) && (aneighbourpointindex2 >= iFirst)) {
+              aneighbourpointindex2 = (j == 0) ? (aneighbourpointindex2 + 1) : (aneighbourpointindex2 - 1);
+              const IntSurf_PntOn2S& aPrevNeighbourPoint = theWLine->Point(aneighbourpointindex2);
+              Standard_Real nU2, nV2;
+
+              if(surfit == 0)
+                aPrevNeighbourPoint.ParametersOnS1(nU2, nV2);
+              else
+                aPrevNeighbourPoint.ParametersOnS2(nU2, nV2);
+              ap2.SetX(nU2);
+              ap2.SetY(nV2);
+
+              if(ap1.SquareDistance(ap2) > (gp::Resolution() * gp::Resolution())) {
+                break;
+              }
+            }  
+            found = FindPoint(ap2, ap1, umin, umax, vmin, vmax, anewpoint);
+          }
 
-           if(aProjector.IsDone()) {
-             if(aProjector.LowerDistance() < aCriteria) {
-               Standard_Real foundU = U, foundV = V;
-               aProjector.LowerDistanceParameters(foundU, foundV);
+          if(found) {
+            // check point
+            Standard_Real aCriteria = BRep_Tool::Tolerance(theFace1) + BRep_Tool::Tolerance(theFace2);
+            GeomAPI_ProjectPointOnSurf& aProjector = 
+              (surfit == 0) ? aContext->ProjPS(theFace2) : aContext->ProjPS(theFace1);
+            Handle(GeomAdaptor_HSurface) aSurface = (surfit == 0) ? theSurface1 : theSurface2;
+
+            Handle(GeomAdaptor_HSurface) aSurfaceOther = (surfit == 0) ? theSurface2 : theSurface1;
+
+            gp_Pnt aP3d = aSurface->Value(anewpoint.X(), anewpoint.Y());
+            aProjector.Perform(aP3d);
+
+            if(aProjector.IsDone()) {
+              if(aProjector.LowerDistance() < aCriteria) {
+                Standard_Real foundU = U, foundV = V;
+                aProjector.LowerDistanceParameters(foundU, foundV);
+
+                //Correction of projected coordinates. Begin
+                //Note, it may be shifted on a period
+                Standard_Integer aneindex1 = (j == 0) ? iFirst : iLast;
+                const IntSurf_PntOn2S& aNeighbourPoint = theWLine->Point(aneindex1);
+                Standard_Real nUn, nVn;
+                
+                if(surfit == 0)
+                  aNeighbourPoint.ParametersOnS2(nUn, nVn);
+                else
+                  aNeighbourPoint.ParametersOnS1(nUn, nVn);
+                gp_Pnt2d aNeighbour2d(nUn, nVn);
+                gp_Pnt2d anAdjustedPoint = AdjustByNeighbour( aNeighbour2d, gp_Pnt2d(foundU, foundV), aSurfaceOther );
+                foundU = anAdjustedPoint.X();
+                foundV = anAdjustedPoint.Y();
+
+                if ( ( anAdjustedPoint.X() < umin ) && ( anAdjustedPoint.X() > umax ) &&
+                    ( anAdjustedPoint.Y() < vmin ) && ( anAdjustedPoint.Y() > vmax ) ) {
+                  // attempt to roughly re-compute point
+                  foundU = ( foundU < umin ) ? umin : foundU;
+                  foundU = ( foundU > umax ) ? umax : foundU;
+                  foundV = ( foundV < vmin ) ? vmin : foundV;
+                  foundV = ( foundV > vmax ) ? vmax : foundV;
+
+                  GeomAPI_ProjectPointOnSurf& aProjector2 = 
+                    (surfit == 0) ? aContext->ProjPS(theFace1) : aContext->ProjPS(theFace2);
+
+                  aP3d = aSurfaceOther->Value(foundU, foundV);
+                  aProjector2.Perform(aP3d);
+                  
+                  if(aProjector2.IsDone()) {
+                    if(aProjector2.LowerDistance() < aCriteria) {
+                      Standard_Real foundU2 = anewpoint.X(), foundV2 = anewpoint.Y();
+                      aProjector2.LowerDistanceParameters(foundU2, foundV2);
+                      anewpoint.SetX(foundU2);
+                      anewpoint.SetY(foundV2);
+                    }
+                  }
+                }
+                //Correction of projected coordinates. End
 
-               //Correction of projected coordinates. Begin
-               //Note, it may be shifted on a period
-               Standard_Integer aneindex1 = (j == 0) ? aListOfIndex.First() : aListOfIndex.Last();
-               const IntSurf_PntOn2S& aNeighbourPoint = theWLine->Point(aneindex1);
-               Standard_Real nUn, nVn;
-               
-               if(surfit == 0)
-                 aNeighbourPoint.ParametersOnS2(nUn, nVn);
-               else
-                 aNeighbourPoint.ParametersOnS1(nUn, nVn);
-               gp_Pnt2d aNeighbour2d(nUn, nVn);
-               gp_Pnt2d anAdjustedPoint = AdjustByNeighbour( aNeighbour2d, gp_Pnt2d(foundU, foundV), aSurfaceOther );
-               foundU = anAdjustedPoint.X();
-               foundV = anAdjustedPoint.Y();
-
-               if ( ( anAdjustedPoint.X() < umin ) && ( anAdjustedPoint.X() > umax ) &&
-                   ( anAdjustedPoint.Y() < vmin ) && ( anAdjustedPoint.Y() > vmax ) ) {
-                 // attempt to roughly re-compute point
-                 foundU = ( foundU < umin ) ? umin : foundU;
-                 foundU = ( foundU > umax ) ? umax : foundU;
-                 foundV = ( foundV < vmin ) ? vmin : foundV;
-                 foundV = ( foundV > vmax ) ? vmax : foundV;
-
-                 GeomAPI_ProjectPointOnSurf& aProjector2 = 
-                   (surfit == 0) ? aContext->ProjPS(theFace1) : aContext->ProjPS(theFace2);
-
-                 aP3d = aSurfaceOther->Value(foundU, foundV);
-                 aProjector2.Perform(aP3d);
-                 
-                 if(aProjector2.IsDone()) {
-                   if(aProjector2.LowerDistance() < aCriteria) {
-                     Standard_Real foundU2 = anewpoint.X(), foundV2 = anewpoint.Y();
-                     aProjector2.LowerDistanceParameters(foundU2, foundV2);
-                     anewpoint.SetX(foundU2);
-                     anewpoint.SetY(foundV2);
-                   }
-                 }
-               }
-               //Correction of projected coordinates. End
-
-               if(surfit == 0)
-                 aNewP.SetValue(aP3d, anewpoint.X(), anewpoint.Y(), foundU, foundV);
-               else
-                 aNewP.SetValue(aP3d, foundU, foundV, anewpoint.X(), anewpoint.Y());
-             }
-           }
-         }
-       }
+                if(surfit == 0)
+                  aNewP.SetValue(aP3d, anewpoint.X(), anewpoint.Y(), foundU, foundV);
+                else
+                  aNewP.SetValue(aP3d, foundU, foundV, anewpoint.X(), anewpoint.Y());
+              }
+            }
+          }
+        }
       }
       aSeqOfPntOn2S->Add(aNewP);
       aListOfFLIndex.Append(aSeqOfPntOn2S->NbPoints());
@@ -4141,146 +4150,153 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine,
     //
     for(i = 1; i <= nblines; i++) {
       if(anArrayOfLineType.Value(i) != 0) {
-       continue;
+        continue;
       }
       const TColStd_ListOfInteger& aListOfIndex = anArrayOfLines.Value(i);
-
-      if(aListOfIndex.Extent() < 2) {
-       continue;
-      }
       const TColStd_ListOfInteger& aListOfFLIndex = anArrayOfLineEnds.Value(i);
       Standard_Boolean bhasfirstpoint = (aListOfFLIndex.Extent() == 2);
       Standard_Boolean bhaslastpoint = (aListOfFLIndex.Extent() == 2);
 
       if(!bhasfirstpoint && !aListOfFLIndex.IsEmpty()) {
-       bhasfirstpoint = (i != 1);
+        bhasfirstpoint = (i != 1);
       }
 
       if(!bhaslastpoint && !aListOfFLIndex.IsEmpty()) {
-       bhaslastpoint = (i != nblines);
+        bhaslastpoint = (i != nblines);
       }
-      Standard_Boolean bIsFirstInside = ((ifprm >= aListOfIndex.First()) && (ifprm <= aListOfIndex.Last()));
-      Standard_Boolean bIsLastInside =  ((ilprm >= aListOfIndex.First()) && (ilprm <= aListOfIndex.Last()));
+      
+      Standard_Integer iFirst = aListOfIndex.First();
+      Standard_Integer iLast  = aListOfIndex.Last();
+      Standard_Boolean bIsFirstInside = ((ifprm >= iFirst) && (ifprm <= iLast));
+      Standard_Boolean bIsLastInside =  ((ilprm >= iFirst) && (ilprm <= iLast));
 
       if(!bIsFirstInside && !bIsLastInside) {
-       if((ifprm < aListOfIndex.First()) && (ilprm > aListOfIndex.Last())) {
-         // append whole line, and boundaries if neccesary
-         if(bhasfirstpoint) {
-           const IntSurf_PntOn2S& aP = aSeqOfPntOn2S->Value(aListOfFLIndex.First());
-           aLineOn2S->Add(aP);
-         }
-         TColStd_ListIteratorOfListOfInteger anIt(aListOfIndex);
+        if((ifprm < iFirst) && (ilprm > iLast)) {
+          // append whole line, and boundaries if neccesary
+          if(bhasfirstpoint) {
+            pit = aListOfFLIndex.First();
+            const IntSurf_PntOn2S& aP = aSeqOfPntOn2S->Value(pit);
+            aLineOn2S->Add(aP);
+          }
+          TColStd_ListIteratorOfListOfInteger anIt(aListOfIndex);
 
-         for(; anIt.More(); anIt.Next()) {
-           const IntSurf_PntOn2S& aP = theWLine->Point(anIt.Value());
-           aLineOn2S->Add(aP);
-         }
+          for(; anIt.More(); anIt.Next()) {
+            pit = anIt.Value();
+            const IntSurf_PntOn2S& aP = theWLine->Point(pit);
+            aLineOn2S->Add(aP);
+          }
 
-         if(bhaslastpoint) {
-           const IntSurf_PntOn2S& aP = aSeqOfPntOn2S->Value(aListOfFLIndex.Last());
-           aLineOn2S->Add(aP);
-         }
+          if(bhaslastpoint) {
+            pit = aListOfFLIndex.Last();
+            const IntSurf_PntOn2S& aP = aSeqOfPntOn2S->Value(pit);
+            aLineOn2S->Add(aP);
+          }
 
-         // check end of split line (end is almost always)
-         Standard_Integer aneighbour = i + 1;
-         Standard_Boolean bIsEndOfLine = Standard_True;
+          // check end of split line (end is almost always)
+          Standard_Integer aneighbour = i + 1;
+          Standard_Boolean bIsEndOfLine = Standard_True;
 
-         if(aneighbour <= nblines) {
-           const TColStd_ListOfInteger& aListOfNeighbourIndex = anArrayOfLines.Value(aneighbour);
+          if(aneighbour <= nblines) {
+            const TColStd_ListOfInteger& aListOfNeighbourIndex = anArrayOfLines.Value(aneighbour);
 
-           if((anArrayOfLineType.Value(aneighbour) != 0) &&
-              (aListOfNeighbourIndex.IsEmpty())) {
-             bIsEndOfLine = Standard_False;
-           }
-         }
+            if((anArrayOfLineType.Value(aneighbour) != 0) &&
+               (aListOfNeighbourIndex.IsEmpty())) {
+              bIsEndOfLine = Standard_False;
+            }
+          }
 
-         if(bIsEndOfLine) {
-           if(aLineOn2S->NbPoints() > 1) {
-             Handle(IntPatch_WLine) aNewWLine = 
-               new IntPatch_WLine(aLineOn2S, Standard_False);
-             theNewLines.Append(aNewWLine);
-           }
-           aLineOn2S = new IntSurf_LineOn2S();
-         }
-       }
-       continue;
+          if(bIsEndOfLine) {
+            if(aLineOn2S->NbPoints() > 1) {
+              Handle(IntPatch_WLine) aNewWLine = 
+                new IntPatch_WLine(aLineOn2S, Standard_False);
+              theNewLines.Append(aNewWLine);
+            }
+            aLineOn2S = new IntSurf_LineOn2S();
+          }
+        }
+        continue;
       }
       // end if(!bIsFirstInside && !bIsLastInside)
 
       if(bIsFirstInside && bIsLastInside) {
-       // append inside points between ifprm and ilprm
-       TColStd_ListIteratorOfListOfInteger anIt(aListOfIndex);
-
-       for(; anIt.More(); anIt.Next()) {
-         if((anIt.Value() < ifprm) || (anIt.Value() > ilprm))
-           continue;
-         const IntSurf_PntOn2S& aP = theWLine->Point(anIt.Value());
-         aLineOn2S->Add(aP);
-       }
+        // append inside points between ifprm and ilprm
+        TColStd_ListIteratorOfListOfInteger anIt(aListOfIndex);
+
+        for(; anIt.More(); anIt.Next()) {
+          pit = anIt.Value();
+          if((pit < ifprm) || (pit > ilprm))
+            continue;
+          const IntSurf_PntOn2S& aP = theWLine->Point(pit);
+          aLineOn2S->Add(aP);
+        }
       }
       else {
 
-       if(bIsFirstInside) {
-         // append points from ifprm to last point + boundary point
-         TColStd_ListIteratorOfListOfInteger anIt(aListOfIndex);
-
-         for(; anIt.More(); anIt.Next()) {
-           if(anIt.Value() < ifprm)
-             continue;
-           const IntSurf_PntOn2S& aP = theWLine->Point(anIt.Value());
-           aLineOn2S->Add(aP);
-         }
-
-         if(bhaslastpoint) {
-           const IntSurf_PntOn2S& aP = aSeqOfPntOn2S->Value(aListOfFLIndex.Last());
-           aLineOn2S->Add(aP);
-         }
-         // check end of split line (end is almost always)
-         Standard_Integer aneighbour = i + 1;
-         Standard_Boolean bIsEndOfLine = Standard_True;
+        if(bIsFirstInside) {
+          // append points from ifprm to last point + boundary point
+          TColStd_ListIteratorOfListOfInteger anIt(aListOfIndex);
 
-         if(aneighbour <= nblines) {
-           const TColStd_ListOfInteger& aListOfNeighbourIndex = anArrayOfLines.Value(aneighbour);
+          for(; anIt.More(); anIt.Next()) {
+            pit = anIt.Value();
+            if(pit < ifprm)
+              continue;
+            const IntSurf_PntOn2S& aP = theWLine->Point(pit);
+            aLineOn2S->Add(aP);
+          }
 
-           if((anArrayOfLineType.Value(aneighbour) != 0) &&
-              (aListOfNeighbourIndex.IsEmpty())) {
-             bIsEndOfLine = Standard_False;
-           }
-         }
+          if(bhaslastpoint) {
+            pit = aListOfFLIndex.Last();
+            const IntSurf_PntOn2S& aP = aSeqOfPntOn2S->Value(pit);
+            aLineOn2S->Add(aP);
+          }
+          // check end of split line (end is almost always)
+          Standard_Integer aneighbour = i + 1;
+          Standard_Boolean bIsEndOfLine = Standard_True;
 
-         if(bIsEndOfLine) {
-           if(aLineOn2S->NbPoints() > 1) {
-             Handle(IntPatch_WLine) aNewWLine = 
-               new IntPatch_WLine(aLineOn2S, Standard_False);
-             theNewLines.Append(aNewWLine);
-           }
-           aLineOn2S = new IntSurf_LineOn2S();
-         }
-       }
-       // end if(bIsFirstInside)
+          if(aneighbour <= nblines) {
+            const TColStd_ListOfInteger& aListOfNeighbourIndex = anArrayOfLines.Value(aneighbour);
 
-       if(bIsLastInside) {
-         // append points from first boundary point to ilprm
-         if(bhasfirstpoint) {
-           const IntSurf_PntOn2S& aP = aSeqOfPntOn2S->Value(aListOfFLIndex.First());
-           aLineOn2S->Add(aP);
-         }
-         TColStd_ListIteratorOfListOfInteger anIt(aListOfIndex);
+            if((anArrayOfLineType.Value(aneighbour) != 0) &&
+               (aListOfNeighbourIndex.IsEmpty())) {
+              bIsEndOfLine = Standard_False;
+            }
+          }
 
-         for(; anIt.More(); anIt.Next()) {
-           if(anIt.Value() > ilprm)
-             continue;
-           const IntSurf_PntOn2S& aP = theWLine->Point(anIt.Value());
-           aLineOn2S->Add(aP);
-         }
-       }
-       //end if(bIsLastInside)
+          if(bIsEndOfLine) {
+            if(aLineOn2S->NbPoints() > 1) {
+              Handle(IntPatch_WLine) aNewWLine = 
+                new IntPatch_WLine(aLineOn2S, Standard_False);
+              theNewLines.Append(aNewWLine);
+            }
+            aLineOn2S = new IntSurf_LineOn2S();
+          }
+        }
+        // end if(bIsFirstInside)
+
+        if(bIsLastInside) {
+          // append points from first boundary point to ilprm
+          if(bhasfirstpoint) {
+            pit = aListOfFLIndex.First();
+            const IntSurf_PntOn2S& aP = aSeqOfPntOn2S->Value(pit);
+            aLineOn2S->Add(aP);
+          }
+          TColStd_ListIteratorOfListOfInteger anIt(aListOfIndex);
+
+          for(; anIt.More(); anIt.Next()) {
+            pit = anIt.Value();
+            if(pit > ilprm)
+              continue;
+            const IntSurf_PntOn2S& aP = theWLine->Point(pit);
+            aLineOn2S->Add(aP);
+          }
+        }
+        //end if(bIsLastInside)
       }
     }
 
     if(aLineOn2S->NbPoints() > 1) {
       Handle(IntPatch_WLine) aNewWLine = 
-       new IntPatch_WLine(aLineOn2S, Standard_False);
+        new IntPatch_WLine(aLineOn2S, Standard_False);
       theNewLines.Append(aNewWLine);
     }
   }
index 1ea39992b0269f7da6d73dfa988f0cfdc21b1249..ac2993ea366ddf7e0e7f08d9cee2adee146978a0 100644 (file)
@@ -130,26 +130,29 @@ void IntTools_LineConstructor::Perform(const Handle(IntPatch_Line)& L)
          }
        }
        else {
-         const IntSurf_PntOn2S& Pfirst = WLine->Point((Standard_Integer)(firstp));
-         Pfirst.Parameters(u1,v1,u2,v2);
-         Recadre(myHS1,myHS2,u1,v1,u2,v2);
-         TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
-         if(in1 !=  TopAbs_OUT) {  //-- !=ON donne Pb 
-           TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
-           if(in2 != TopAbs_OUT) { //-- !=ON  
-             const IntSurf_PntOn2S& Plast = WLine->Point((Standard_Integer)(lastp));
-             Plast.Parameters(u1,v1,u2,v2);
-             Recadre(myHS1,myHS2,u1,v1,u2,v2);
-             in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
-             if(in1 !=  TopAbs_OUT) {  //-- !=ON donne Pb 
-               in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
-               if(in2 != TopAbs_OUT) {
-                 seqp.Append(firstp);
-                 seqp.Append(lastp);
-               }
-             }
-           }
-         }
+          TopAbs_State in1, in2;
+          //
+          const IntSurf_PntOn2S& Pfirst = WLine->Point((Standard_Integer)(firstp));
+          const IntSurf_PntOn2S& Plast = WLine->Point((Standard_Integer)(lastp));
+          //
+          Pfirst.Parameters(u1,v1,u2,v2);
+          Recadre(myHS1,myHS2,u1,v1,u2,v2);
+          in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
+          in2 = (in1 == TopAbs_OUT) ? TopAbs_OUT : 
+            myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
+          //
+          if (in2 == TopAbs_OUT) {
+            Plast.Parameters(u1,v1,u2,v2);
+            Recadre(myHS1,myHS2,u1,v1,u2,v2);
+            in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
+            in2 = (in1 == TopAbs_OUT) ? TopAbs_OUT : 
+              myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
+          }
+          //
+          if (in2 != TopAbs_OUT) {
+            seqp.Append(firstp);
+            seqp.Append(lastp);
+          }
        }
       }
     }
index 1d0ef2fba6fb6d0db59fed8c63a1afe8b43001dc..61c59a09b8276b8a53411ba9ce01fa74c9cb9a2c 100644 (file)
@@ -32,7 +32,8 @@ uses XY                  from gp,
      PntOn2S             from IntSurf,
      LineOn2S            from IntSurf,
      Dir                 from gp,
-     Dir2d               from gp
+     Dir2d               from gp,
+     Pnt                 from gp
      
      
 raises OutOfRange from Standard,
@@ -248,14 +249,63 @@ is
        is static;
 
     AddAPoint ( me    : in out  ; 
-               line  : in  out  LineOn2S  from  IntSurf  ;     
-               POn2S :          PntOn2S   from  IntSurf  ) ;
-       ---C++: inline
-               
+    line  : in  out  LineOn2S  from  IntSurf  ;     
+    POn2S :          PntOn2S   from  IntSurf  ) ;
+    ---C++: inline
+    
     ExtendLineInCommonZone(me: in out; theChoixIso: ConstIsoparametric  from IntImp;
-                                      theDirectionFlag: Boolean from Standard)
-       returns Boolean from Standard
-       is private;
+theDirectionFlag: Boolean from Standard)
+    returns Boolean from Standard
+    is private;
+  
+  DistanceMinimizeByGradient( me    : in out;
+                              theASurf1 , theASurf2  : ThePSurface ;
+                              theU1, theV1, theU2, theV2: out Real from Standard;
+                              theStep0U1V1: Real from Standard = 1.0e-6;
+                              theStep0U2V2: Real from Standard = 1.0e-6)
+    returns Boolean from Standard
+    is private;
+    -- Finds one intersection point of two given surfaces with given 
+    --  initial point.
+  
+  DistanceMinimizeByExtrema(me          : in out;
+                            theASurf1   : ThePSurface ;
+                            theP0       : Pnt from gp;
+                            theU0, theV0: out Real from Standard;
+                            theStep0U: Real from Standard = 1.0;
+                            theStep0V: Real from Standard = 1.0)
+    returns Boolean from Standard
+    is private;
+    -- Finds one intersection point of two given surfaces with given 
+    --  initial point.
+  
+  SeekPointOnBoundary(me    : in out;
+                      theASurf1 , theASurf2  : ThePSurface ;
+                      theU1, theV1, theU2, theV2: Real from Standard;
+                      isTheFirst : Boolean from Standard)
+    returns Boolean from Standard
+    is private;
+    -- Unites and correctly coordinates of work of
+    -- "DistanceMinimizeByGradient" and "DistanceMinimizeByExtrema" functions.
+  
+  
+  PutToBoundary( me    : in out;
+                 theASurf1 , theASurf2  : ThePSurface)
+    -- Tries to extend existing intersection line 
+    --  (as set of points) to surface's boundaries,
+    --  if it is possibly.
+    --  If line is scienter far from boundaries
+    --  or is (almost) parralel with some boundary,
+    --  extending is not required.
+    returns Boolean from Standard;
+
+
+  SeekAdditionalPoints( me    : in out;
+                        theASurf1 , theASurf2  : ThePSurface;
+                        theMinNbPoints : Integer from Standard)
+    returns Boolean from Standard;
+    -- Unites and correctly coordinates of work of
+    -- "DistanceMinimizeByGradient" and "DistanceMinimizeByExtrema" functions.
 
 fields
 
index d5c8ebb32e0d432e57d141b6ec5e9cae8359a1ff..85e62228f8eccfa58e2bf5a6b5567477fd027647 100644 (file)
@@ -19,6 +19,8 @@
 #include <Precision.hxx>
 #include <math_FunctionSetRoot.hxx>
 
+#include <Geom_Surface.hxx>
+
 //#define KELARG 20.0
 
 //==================================================================================
 // during change of isos 
 //==================================================================================
 void ComputePasInit(Standard_Real *pasuv,
-                   Standard_Real Um1,Standard_Real UM1,
-                   Standard_Real Vm1,Standard_Real VM1,
-                   Standard_Real Um2,Standard_Real UM2,
-                   Standard_Real Vm2,Standard_Real VM2,
-                   Standard_Real _Um1,Standard_Real _UM1,
-                   Standard_Real _Vm1,Standard_Real _VM1,
-                   Standard_Real _Um2,Standard_Real _UM2,
-                   Standard_Real _Vm2,Standard_Real _VM2,
-                   const ThePSurface& ,
-                   const ThePSurface& ,
-                   const Standard_Real Increment) 
+                    Standard_Real Um1,Standard_Real UM1,
+                    Standard_Real Vm1,Standard_Real VM1,
+                    Standard_Real Um2,Standard_Real UM2,
+                    Standard_Real Vm2,Standard_Real VM2,
+                    Standard_Real _Um1,Standard_Real _UM1,
+                    Standard_Real _Vm1,Standard_Real _VM1,
+                    Standard_Real _Um2,Standard_Real _UM2,
+                    Standard_Real _Vm2,Standard_Real _VM2,
+                    const ThePSurface& ,
+                    const ThePSurface& ,
+                    const Standard_Real Increment) 
 { 
   Standard_Real du1=Abs(UM1-Um1);
   Standard_Real dv1=Abs(VM1-Vm1);
   Standard_Real du2=Abs(UM2-Um2);
   Standard_Real dv2=Abs(VM2-Vm2);
+
   Standard_Real _du1=Abs(_UM1-_Um1);
   Standard_Real _dv1=Abs(_VM1-_Vm1);
   Standard_Real _du2=Abs(_UM2-_Um2);
   Standard_Real _dv2=Abs(_VM2-_Vm2);
+
   //-- limit the reduction of uv box estimate to 0.01 natural box
   //--  du1 : On box of Inter
   //-- _du1 : On parametric space
@@ -57,32 +59,193 @@ void ComputePasInit(Standard_Real *pasuv,
   if(_dv1<1e50 && dv1<0.01*_dv1) dv1=0.01*_dv1;
   if(_du2<1e50 && du2<0.01*_du2) du2=0.01*_du2;
   if(_dv2<1e50 && dv2<0.01*_dv2) dv2=0.01*_dv2;
-  
+
   pasuv[0]=Increment*du1;
   pasuv[1]=Increment*dv1;
   pasuv[2]=Increment*du2;
   pasuv[3]=Increment*dv2;
 }
+
+//=======================================================================
+//function : IsParallel
+//purpose  : Checks if theLine is parallel of some boundary of given
+//            surface (it is determined by theCheckSurf1 flag). 
+//            Parallelism assumes small oscillations (swing is less or 
+//            equal than theToler).
+//            Small lines (if first and last parameters in the Surface 
+//            are almost equal) are classified as parallel (as same as 
+//            any point can be considered as parallel of any line).
+//=======================================================================
+static void IsParallel(const Handle(IntSurf_LineOn2S)& theLine,
+                  const Standard_Boolean theCheckSurf1,
+                  const Standard_Real theToler,
+                  Standard_Boolean& theIsUparallel,
+                  Standard_Boolean& theIsVparallel)
+{
+  const Standard_Integer aNbPointsMAX = 23;
+
+  theIsUparallel = theIsVparallel = Standard_True;
+
+  Standard_Integer aNbPoints = theLine->NbPoints();
+  if(aNbPoints > aNbPointsMAX)
+  {
+    aNbPoints = aNbPointsMAX;
+  }
+  else if(aNbPoints < 3)
+  {
+    //Here we cannot estimate parallelism.
+    //Do all same as for small lines 
+    return;
+  }
+
+  Standard_Real aStep = IntToReal(theLine->NbPoints()) / aNbPoints;
+  Standard_Real aNPoint = 1.0;
+
+  Standard_Real aUmin = RealLast(), aUmax = RealFirst(), aVmin = RealLast(), aVmax = RealFirst();
+  for(Standard_Integer aNum = 1; aNum <= aNbPoints; aNum++, aNPoint += aStep)
+  {
+    if(aNPoint > aNbPoints)
+    {
+      aNPoint = aNbPoints;
+    }
+
+    Standard_Real u, v;
+    if(theCheckSurf1)
+      theLine->Value(RealToInt(aNPoint)).ParametersOnS1(u, v);
+    else
+      theLine->Value(RealToInt(aNPoint)).ParametersOnS2(u, v);
+
+    if(u < aUmin)
+      aUmin = u;
+
+    if(u > aUmax)
+      aUmax = u;
+
+    if(v < aVmin)
+      aVmin = v;
+
+    if(v > aVmax)
+      aVmax = v;
+  }
+
+  theIsVparallel = ((aUmax - aUmin) < theToler);
+  theIsUparallel = ((aVmax - aVmin) < theToler);
+}
+
+//=======================================================================
+//function : Checking
+//purpose  : Check, if given point is in surface's boundaries.
+//            If "yes" then theFactTol = 0.0, else theFactTol is
+//            equal maximal deviation.
+//=======================================================================
+static Standard_Boolean Checking( const Handle(Adaptor3d_HSurface)& theASurf1,
+                                  const Handle(Adaptor3d_HSurface)& theASurf2,
+                                  Standard_Real& theU1,
+                                  Standard_Real& theV1,
+                                  Standard_Real& theU2,
+                                  Standard_Real& theV2,
+                                  Standard_Real& theFactTol)
+{
+  const Standard_Real aTol = Precision::PConfusion();
+  const Standard_Real aU1bFirst = theASurf1->FirstUParameter();
+  const Standard_Real aU1bLast = theASurf1->LastUParameter();
+  const Standard_Real aU2bFirst = theASurf2->FirstUParameter();
+  const Standard_Real aU2bLast = theASurf2->LastUParameter();
+  const Standard_Real aV1bFirst = theASurf1->FirstVParameter();
+  const Standard_Real aV1bLast = theASurf1->LastVParameter();
+  const Standard_Real aV2bFirst = theASurf2->FirstVParameter();
+  const Standard_Real aV2bLast = theASurf2->LastVParameter();
+
+  Standard_Boolean isOnOrIn = Standard_True;
+  theFactTol = 0.0;
+
+  Standard_Real aDelta = aU1bFirst - theU1;
+  if(aDelta > aTol)
+  {
+    theU1 = aU1bFirst;
+    theFactTol = Max(theFactTol, aDelta);
+    isOnOrIn = Standard_False;
+  }
+  
+  aDelta = theU1 - aU1bLast;
+  if(aDelta > aTol)
+  {
+    theU1 = aU1bLast;
+    theFactTol = Max(theFactTol, aDelta);
+    isOnOrIn = Standard_False;
+  }
+
+  aDelta = aV1bFirst - theV1;
+  if(aDelta > aTol)
+  {
+    theV1 = aV1bFirst;
+    theFactTol = Max(theFactTol, aDelta);
+    isOnOrIn = Standard_False;
+  }
+  
+  aDelta = theV1 - aV1bLast;
+  if(aDelta > aTol)
+  {
+    theV1 = aV1bLast;
+    theFactTol = Max(theFactTol, aDelta);
+    isOnOrIn = Standard_False;
+  }
+
+  aDelta = aU2bFirst - theU2;
+  if(aDelta > aTol)
+  {
+    theU2 = aU2bFirst;
+    theFactTol = Max(theFactTol, aDelta);
+    isOnOrIn = Standard_False;
+  }
+  
+  aDelta = theU2 - aU2bLast;
+  if(aDelta > aTol)
+  {
+    theU2 = aU2bLast;
+    theFactTol = Max(theFactTol, aDelta);
+    isOnOrIn = Standard_False;
+  }
+
+  aDelta = aV2bFirst - theV2;
+  if(aDelta > aTol)
+  {
+    theV2 = aV2bFirst;
+    theFactTol = Max(theFactTol, aDelta);
+    isOnOrIn = Standard_False;
+  }
+  
+  aDelta = theV2 - aV2bLast;
+  if(aDelta > aTol)
+  {
+    theV2 = aV2bLast;
+    theFactTol = Max(theFactTol, aDelta);
+    isOnOrIn = Standard_False;
+  }
+
+  return isOnOrIn;
+}
+
 //==================================================================================
 // function : IntWalk_PWalking::IntWalk_PWalking
 // purpose  : 
 //==================================================================================
 IntWalk_PWalking::IntWalk_PWalking(const ThePSurface& Caro1,
-                                  const ThePSurface& Caro2,
-                                  const Standard_Real TolTangency,
-                                  const Standard_Real Epsilon,
-                                  const Standard_Real Deflection,
-                                  const Standard_Real Increment ) 
-     :
-       
-       done(Standard_True),
-       close(Standard_False),
-       fleche(Deflection),
-       tolconf(Epsilon),
-       sensCheminement(1),
-       myIntersectionOn2S(Caro1,Caro2,TolTangency),
-       STATIC_BLOCAGE_SUR_PAS_TROP_GRAND(0),
-       STATIC_PRECEDENT_INFLEXION(0)
+                                   const ThePSurface& Caro2,
+                                   const Standard_Real TolTangency,
+                                   const Standard_Real Epsilon,
+                                   const Standard_Real Deflection,
+                                   const Standard_Real Increment ) 
+                                   :
+
+done(Standard_True),
+close(Standard_False),
+fleche(Deflection),
+tolconf(Epsilon),
+sensCheminement(1),
+myIntersectionOn2S(Caro1,Caro2,TolTangency),
+STATIC_BLOCAGE_SUR_PAS_TROP_GRAND(0),
+STATIC_PRECEDENT_INFLEXION(0)
 {
   Standard_Real KELARG=20.;
   //
@@ -152,7 +315,7 @@ IntWalk_PWalking::IntWalk_PWalking(const ThePSurface& Caro1,
       UM1+=t;  Um1-=t;
     }
   }
-      
+
   if(ThePSurfaceTool::IsVPeriodic(Caro1)==Standard_False) { 
     //VM1+=KELARG*pasuv[1];  Vm1-=KELARG*pasuv[1];
   }
@@ -164,7 +327,7 @@ IntWalk_PWalking::IntWalk_PWalking(const ThePSurface& Caro1,
       VM1+=t;  Vm1-=t;
     }
   }
-   
+
   if(ThePSurfaceTool::IsUPeriodic(Caro2)==Standard_False) { 
     //UM2+=KELARG*pasuv[2];  Um2-=KELARG*pasuv[2];
   }
@@ -176,7 +339,7 @@ IntWalk_PWalking::IntWalk_PWalking(const ThePSurface& Caro1,
       UM2+=t;  Um2-=t;
     }
   }
-   
+
   if(ThePSurfaceTool::IsVPeriodic(Caro2)==Standard_False) {   
     //VM2+=KELARG*pasuv[3];  Vm2-=KELARG*pasuv[3];
   }
@@ -204,25 +367,25 @@ IntWalk_PWalking::IntWalk_PWalking(const ThePSurface& Caro1,
 // purpose  : 
 //==================================================================================
 IntWalk_PWalking::IntWalk_PWalking(const ThePSurface& Caro1,
-                                  const ThePSurface& Caro2,
-                                  const Standard_Real TolTangency,
-                                  const Standard_Real Epsilon,
-                                  const Standard_Real Deflection,
-                                  const Standard_Real Increment, 
-                                  const Standard_Real U1,
-                                  const Standard_Real V1,
-                                  const Standard_Real U2, 
-                                  const Standard_Real V2)
-     :
-       
-       done(Standard_True),
-       close(Standard_False),
-       fleche(Deflection),
-       tolconf(Epsilon),
-       sensCheminement(1),       
-       myIntersectionOn2S(Caro1,Caro2,TolTangency),
-       STATIC_BLOCAGE_SUR_PAS_TROP_GRAND(0),
-       STATIC_PRECEDENT_INFLEXION(0)
+                                   const ThePSurface& Caro2,
+                                   const Standard_Real TolTangency,
+                                   const Standard_Real Epsilon,
+                                   const Standard_Real Deflection,
+                                   const Standard_Real Increment, 
+                                   const Standard_Real U1,
+                                   const Standard_Real V1,
+                                   const Standard_Real U2, 
+                                   const Standard_Real V2)
+                                   :
+
+done(Standard_True),
+close(Standard_False),
+fleche(Deflection),
+tolconf(Epsilon),
+sensCheminement(1),       
+myIntersectionOn2S(Caro1,Caro2,TolTangency),
+STATIC_BLOCAGE_SUR_PAS_TROP_GRAND(0),
+STATIC_PRECEDENT_INFLEXION(0)
 {
   Standard_Real KELARG=20.;
   //
@@ -331,7 +494,7 @@ IntWalk_PWalking::IntWalk_PWalking(const ThePSurface& Caro1,
       Um2-=t;
     }
   }
-   
+
   if(ThePSurfaceTool::IsVPeriodic(Caro2)==Standard_False) {   
     VM2+=KELARG*pasuv[3];  
     Vm2-=KELARG*pasuv[3];
@@ -369,7 +532,7 @@ IntWalk_PWalking::IntWalk_PWalking(const ThePSurface& Caro1,
 // purpose  : 
 //==================================================================================
 Standard_Boolean IntWalk_PWalking::PerformFirstPoint  (const TColStd_Array1OfReal& ParDep,
-                                                      IntSurf_PntOn2S& FirstPoint)   
+                                                       IntSurf_PntOn2S& FirstPoint)   
 {
   sensCheminement = 1;
   close = Standard_False;
@@ -408,72 +571,77 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep)
 // purpose  : 
 //==================================================================================
 void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
-                              const Standard_Real u1min,
-                              const Standard_Real v1min,
-                              const Standard_Real u2min,
-                              const Standard_Real v2min,
-                              const Standard_Real u1max,
-                              const Standard_Real v1max,
-                              const Standard_Real u2max,
-                              const Standard_Real v2max)
+                               const Standard_Real u1min,
+                               const Standard_Real v1min,
+                               const Standard_Real u2min,
+                               const Standard_Real v2min,
+                               const Standard_Real u1max,
+                               const Standard_Real v1max,
+                               const Standard_Real u2max,
+                               const Standard_Real v2max)
 {
+  const Standard_Real aSQDistMax = 1.0e-14;
   //xf
-  Standard_Integer i, NbPasOKConseq;
-  Standard_Real UFirst1, VFirst1, ULast1, VLast1, UFirst2, VFirst2, ULast2, VLast2;
+
+  Standard_Integer NbPasOKConseq=0;
   Standard_Real pasMaxSV[4], aTmp;
   TColStd_Array1OfReal Param(1,4);
   IntImp_ConstIsoparametric ChoixIso;
   //xt
   //
   done = Standard_False;
-  NbPasOKConseq=0;
   //
   // Caro1 and Caro2
   const ThePSurface& Caro1 =myIntersectionOn2S.Function().AuxillarSurface1();
   const ThePSurface& Caro2 =myIntersectionOn2S.Function().AuxillarSurface2();
   //
-  UFirst1 = ThePSurfaceTool::FirstUParameter(Caro1);
-  VFirst1 = ThePSurfaceTool::FirstVParameter(Caro1);
-  ULast1  = ThePSurfaceTool::LastUParameter (Caro1);
-  VLast1  = ThePSurfaceTool::LastVParameter (Caro1);
-  //
-  UFirst2 = ThePSurfaceTool::FirstUParameter(Caro2);
-  VFirst2 = ThePSurfaceTool::FirstVParameter(Caro2);
-  ULast2  = ThePSurfaceTool::LastUParameter (Caro2);
-  VLast2  = ThePSurfaceTool::LastVParameter (Caro2);
+  const Standard_Real UFirst1 = ThePSurfaceTool::FirstUParameter(Caro1);
+  const Standard_Real VFirst1 = ThePSurfaceTool::FirstVParameter(Caro1);
+  const Standard_Real ULast1  = ThePSurfaceTool::LastUParameter (Caro1);
+  const Standard_Real VLast1  = ThePSurfaceTool::LastVParameter (Caro1);
+
+  const Standard_Real UFirst2 = ThePSurfaceTool::FirstUParameter(Caro2);
+  const Standard_Real VFirst2 = ThePSurfaceTool::FirstVParameter(Caro2);
+  const Standard_Real ULast2  = ThePSurfaceTool::LastUParameter (Caro2);
+  const Standard_Real VLast2  = ThePSurfaceTool::LastVParameter (Caro2);
   //
   ComputePasInit(pasuv,u1min,u1max,v1min,v1max,u2min,u2max,v2min,v2max,
-                Um1,UM1,Vm1,VM1,Um2,UM2,Vm2,VM2,Caro1,Caro2,pasMax+pasMax);
+    Um1,UM1,Vm1,VM1,Um2,UM2,Vm2,VM2,Caro1,Caro2,pasMax+pasMax);
   //
-  if(pasuv[0]<100*ResoU1) {
-    pasuv[0]=100*ResoU1; 
+  if(pasuv[0]<100.0*ResoU1) {
+    pasuv[0]=100.0*ResoU1; 
   }
-  if(pasuv[1]<100*ResoV1) {
-    pasuv[1]=100*ResoV1; 
+  if(pasuv[1]<100.0*ResoV1) {
+    pasuv[1]=100.0*ResoV1; 
   }
-  if(pasuv[2]<100*ResoU2) {
-    pasuv[2]=100*ResoU2;
+  if(pasuv[2]<100.0*ResoU2) {
+    pasuv[2]=100.0*ResoU2;
   }
-  if(pasuv[3]<100*ResoV2) {
-    pasuv[3]=100*ResoV2;
+  if(pasuv[3]<100.0*ResoV2) {
+    pasuv[3]=100.0*ResoV2;
   }
   //
-  for (i=0; i<4; ++i) {
-    if(pasuv[i]>10) {
+  for (Standard_Integer i=0; i<4; ++i)
+  {
+    if(pasuv[i]>10)
+    {
       pasuv[i] = 10;
     }
+
     pasInit[i] = pasSav[i] = pasuv[i]; 
   }
   //
   line = new IntSurf_LineOn2S ();
   //
-  for (i=1; i<=4; ++i) {
+  for (Standard_Integer i=1; i<=4; ++i)
+  {
     aTmp=ParDep(i);
     Param(i)=ParDep(i);
   }
   //-- reproduce steps uv connected to surfaces Caro1 and Caro2
   //-- pasuv[] and pasSav[] are modified during the marching
-  for(i = 0; i < 4; ++i) { 
+  for(Standard_Integer i = 0; i < 4; ++i)
+  {
     pasMaxSV[i] = pasSav[i] = pasuv[i] = pasInit[i]; 
   }
 
@@ -481,19 +649,24 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
   math_FunctionSetRoot  Rsnld(myIntersectionOn2S.Function());
   //
   ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld);
-  if (!myIntersectionOn2S.IsDone())   {
+  if (!myIntersectionOn2S.IsDone())
+  {
     return;
   }
+
   //
-  if (myIntersectionOn2S.IsEmpty()) {
+  if (myIntersectionOn2S.IsEmpty())
+  {
     return;
   }
   //
-  if(myIntersectionOn2S.IsTangent()) {
+  if(myIntersectionOn2S.IsTangent())
+  {
     return;
   }
   //
   Standard_Boolean Arrive, DejaReparti;
+  const Standard_Integer RejectIndexMAX = 250000;
   Standard_Integer IncKey, RejectIndex;
   gp_Pnt pf,pl;
   //
@@ -519,8 +692,8 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
   //-- 
   pf = previousPoint.Value();
   Standard_Boolean bTestFirstPoint = Standard_True;
-  
-  previousPoint.Parameters(Param(1),Param(2),Param(3),Param(4));  
+
+  previousPoint.Parameters(Param(1),Param(2),Param(3),Param(4));
   AddAPoint(line,previousPoint);
   //
   IntWalk_StatusDeflection Status = IntWalk_OK;
@@ -531,12 +704,14 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
   Standard_Integer LevelOfIterWithoutAppend = -1;
   //
   Arrive = Standard_False;
-  while(!Arrive) {//010
+  while(!Arrive) //010
+  {
     LevelOfIterWithoutAppend++;
-    if(LevelOfIterWithoutAppend>20) { 
+    if(LevelOfIterWithoutAppend>20)
+    {
       Arrive = Standard_True; 
       if(DejaReparti) {
-       break;
+        break;
       }
       RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
       LevelOfIterWithoutAppend = 0;
@@ -568,16 +743,23 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
     //
     aIncKey=5.*(Standard_Real)IncKey;
     aEps=1.e-7;
-    if(ChoixIso == IntImp_UIsoparametricOnCaro1 && Abs(dP1) < aEps) {
+    if(ChoixIso == IntImp_UIsoparametricOnCaro1 && Abs(dP1) < aEps)
+    {
       dP1 *= aIncKey;
     }
-    if(ChoixIso == IntImp_VIsoparametricOnCaro1 && Abs(dP2) < aEps) {
+
+    if(ChoixIso == IntImp_VIsoparametricOnCaro1 && Abs(dP2) < aEps)
+    {
       dP2 *= aIncKey;
     }
-    if(ChoixIso == IntImp_UIsoparametricOnCaro2 && Abs(dP3) < aEps) {
+
+    if(ChoixIso == IntImp_UIsoparametricOnCaro2 && Abs(dP3) < aEps)
+    {
       dP3 *= aIncKey;
     }
-    if(ChoixIso == IntImp_VIsoparametricOnCaro2 && Abs(dP4) < aEps) {
+
+    if(ChoixIso == IntImp_VIsoparametricOnCaro2 && Abs(dP4) < aEps)
+    {
       dP4 *= aIncKey;
     }
     //--ofv.end
@@ -594,7 +776,8 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
     //
     ChoixIso= myIntersectionOn2S.Perform(Param, Rsnld, ChoixIso);                  
     //
-    if (!myIntersectionOn2S.IsDone())   {
+    if (!myIntersectionOn2S.IsDone())
+    {
       //end of line, division
       Arrive = Standard_False;
       Param(1)=SvParam[0]; 
@@ -603,403 +786,532 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
       Param(4)=SvParam[3];
       RepartirOuDiviser(DejaReparti, ChoixIso, Arrive);
     }
-    else  {//009 
+    else  //009 
+    {
       //== Calculation of exact point from Param(.) is possible
-      if (myIntersectionOn2S.IsEmpty())        {
-       Standard_Real u1,v1,u2,v2;
-       previousPoint.Parameters(u1,v1,u2,v2);
-       //
-       Arrive = Standard_False;
-       if(u1<UFirst1 || u1>ULast1) {
-         Arrive=Standard_True;
-       }       
-       if(u2<UFirst2 || u2>ULast2) {
-         Arrive=Standard_True;
-       }
-       if(v1<VFirst1 || v1>VLast1) {
-         Arrive=Standard_True;
-       }
-       if(v2<VFirst2 || v2>VLast2) {
-         Arrive=Standard_True;
-       }       
-       RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
-       LevelOfEmptyInmyIntersectionOn2S++;
-       //
-       if(LevelOfEmptyInmyIntersectionOn2S>10)    {
-         pasuv[0]=pasSav[0]; 
-         pasuv[1]=pasSav[1]; 
-         pasuv[2]=pasSav[2]; 
-         pasuv[3]=pasSav[3];
-       }           
+      if (myIntersectionOn2S.IsEmpty())
+      {
+        Standard_Real u1,v1,u2,v2;
+        previousPoint.Parameters(u1,v1,u2,v2);
+        //
+        Arrive = Standard_False;
+        if(u1<UFirst1 || u1>ULast1)
+        {
+          Arrive=Standard_True;
+        }      
+
+        if(u2<UFirst2 || u2>ULast2)
+        {
+          Arrive=Standard_True;
+        }
+
+        if(v1<VFirst1 || v1>VLast1)
+        {
+          Arrive=Standard_True;
+        }
+
+        if(v2<VFirst2 || v2>VLast2)
+        {
+          Arrive=Standard_True;
+        }
+
+        RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
+        LevelOfEmptyInmyIntersectionOn2S++;
+        //
+        if(LevelOfEmptyInmyIntersectionOn2S>10)
+        {
+          pasuv[0]=pasSav[0]; 
+          pasuv[1]=pasSav[1]; 
+          pasuv[2]=pasSav[2]; 
+          pasuv[3]=pasSav[3];
+        }
       }
-      else {//008
-       //============================================================
-       //== A point has been found :  T E S T   D E F L E C T I O N 
-       //============================================================
-       if(NoTestDeflection) {
-         NoTestDeflection = Standard_False;
-       }                 
-       else { 
-         if(--LevelOfEmptyInmyIntersectionOn2S<=0)     { 
-           LevelOfEmptyInmyIntersectionOn2S=0;
-           if(LevelOfIterWithoutAppend < 10) {
-             Status = TestDeflection();
-           }                   
-           else   { 
-             pasuv[0]*=0.5; 
-             pasuv[1]*=0.5; 
-             pasuv[2]*=0.5; 
-             pasuv[3]*=0.5;
-           }
-         }
-       }
-       //============================================================
-       //==       T r a i t e m e n t   s u r   S t a t u s        ==
-       //============================================================
-       if(LevelOfPointConfondu > 5) { 
-         Status = IntWalk_ArretSurPoint; 
-         LevelOfPointConfondu = 0;  
-       }
-       //
-       if(Status==IntWalk_OK) { 
-         NbPasOKConseq++;
-         if(NbPasOKConseq >= 5) { 
-           NbPasOKConseq=0;
-           Standard_Boolean pastroppetit;
-           Standard_Real t;
-           //
-           do { 
-             pastroppetit=Standard_True;
-             //
-             if(pasuv[0]<pasInit[0])     { 
-               t = (pasInit[0]-pasuv[0])*0.25;
-               if(t>0.1*pasInit[0]) {
-                 t=0.1*pasuv[0];
-               }
-               pasuv[0]+=t; 
-               pastroppetit=Standard_False;
-             } 
-             if(pasuv[1]<pasInit[1])   { 
-               t = (pasInit[1]-pasuv[1])*0.25;
-               if(t>0.1*pasInit[1]) {
-                 t=0.1*pasuv[1];
-               }               
-               pasuv[1]+=t; 
-               pastroppetit=Standard_False;
-             } 
-             if(pasuv[2]<pasInit[2]){
-               t = (pasInit[2]-pasuv[2])*0.25;
-               if(t>0.1*pasInit[2]) {
-                 t=0.1*pasuv[2];
-               }
-               pasuv[2]+=t; 
-               pastroppetit=Standard_False;
-             } 
-             if(pasuv[3]<pasInit[3])   { 
-               t = (pasInit[3]-pasuv[3])*0.25;
-               if(t>0.1*pasInit[3]) {
-                 t=0.1*pasuv[3];
-               }
-               pasuv[3]+=t; 
-               pastroppetit=Standard_False;
-             }
-             if(pastroppetit) { 
-               if(pasMax<0.1){ 
-                 pasMax*=1.1; 
-                 pasInit[0]*=1.1; 
-                 pasInit[1]*=1.1; 
-                 pasInit[2]*=1.1; 
-                 pasInit[3]*=1.1; 
-               }
-               else {
-                 pastroppetit=Standard_False;
-               }
-             }
-           } while(pastroppetit);
-         }
-       }//Status==IntWalk_OK
-       else NbPasOKConseq=0;
-       //
-       switch(Status) {//007 
-         case IntWalk_ArretSurPointPrecedent:  {                     
-           Arrive = Standard_False;                        
-           RepartirOuDiviser(DejaReparti, ChoixIso, Arrive);
-           break;
-         }
-         case IntWalk_PasTropGrand:  {
-           Param(1)=SvParam[0]; 
-           Param(2)=SvParam[1]; 
-           Param(3)=SvParam[2]; 
-           Param(4)=SvParam[3];
-           if(LevelOfIterWithoutAppend > 5) { 
-             if(pasSav[0]<pasInit[0]) { 
-               pasInit[0]-=(pasInit[0]-pasSav[0])*0.25; 
-               LevelOfIterWithoutAppend=0;
-             }
-             if(pasSav[1]<pasInit[1]) { 
-               pasInit[1]-=(pasInit[1]-pasSav[1])*0.25;  
-               LevelOfIterWithoutAppend=0; 
-             }
-             if(pasSav[2]<pasInit[2]) { 
-               pasInit[2]-=(pasInit[2]-pasSav[2])*0.25;  
-               LevelOfIterWithoutAppend=0; 
-             }
-             if(pasSav[3]<pasInit[3]) {
-               pasInit[3]-=(pasInit[3]-pasSav[3])*0.25; 
-               LevelOfIterWithoutAppend=0; 
-             }
-           }
-           break;
-         }
-         case IntWalk_PointConfondu:   {
-           LevelOfPointConfondu++;
-           if(LevelOfPointConfondu>5)   { 
-             Standard_Boolean pastroppetit;
-             //
-             do { 
-               pastroppetit=Standard_True;
-               if(pasuv[0]<pasInit[0]) { 
-                 pasuv[0]+=(pasInit[0]-pasuv[0])*0.25;
-                 pastroppetit=Standard_False; 
-               } 
-               if(pasuv[1]<pasInit[1]) { 
-                 pasuv[1]+=(pasInit[1]-pasuv[1])*0.25;
-                 pastroppetit=Standard_False; 
-               } 
-               if(pasuv[2]<pasInit[2]) { 
-                 pasuv[2]+=(pasInit[2]-pasuv[2])*0.25;
-                 pastroppetit=Standard_False; 
-               } 
-               if(pasuv[3]<pasInit[3]) { 
-                 pasuv[3]+=(pasInit[3]-pasuv[3])*0.25; 
-                 pastroppetit=Standard_False; 
-               }
-               if(pastroppetit)  { 
-                 if(pasMax<0.1){ 
-                   pasMax*=1.1; 
-                   pasInit[0]*=1.1; 
-                   pasInit[1]*=1.1; 
-                   pasInit[2]*=1.1; 
-                   pasInit[3]*=1.1; 
-                 }
-                 else{
-                   pastroppetit=Standard_False; 
-                 }             
-               }
-             } while(pastroppetit);
-           }
-           break;
-         }
-         case IntWalk_OK:
-         case IntWalk_ArretSurPoint:  {//006
-           //=======================================================
-           //== Stop Test t   :  Frame on Param(.)     ==
-           //=======================================================
-           //xft arrive here
-           Arrive = TestArret(DejaReparti,Param,ChoixIso); 
-           // JMB 30th December 1999. 
-           // Some statement below should not be put in comment because they are useful.
-           // See grid CTO 909 A1 which infinitely loops 
-           if(Arrive==Standard_False && Status==IntWalk_ArretSurPoint) { 
-             Arrive=Standard_True;
+      else //008
+      {
+        //============================================================
+        //== A point has been found :  T E S T   D E F L E C T I O N 
+        //============================================================
+        if(NoTestDeflection)
+        {
+          NoTestDeflection = Standard_False;
+        }                
+        else
+        {
+          if(--LevelOfEmptyInmyIntersectionOn2S<=0)
+          {
+            LevelOfEmptyInmyIntersectionOn2S=0;
+            if(LevelOfIterWithoutAppend < 10)
+            {
+              Status = TestDeflection();
+            }                  
+            else
+            {
+              pasuv[0]*=0.5; 
+              pasuv[1]*=0.5; 
+              pasuv[2]*=0.5; 
+              pasuv[3]*=0.5;
+            }
+          }
+        }
+
+        //============================================================
+        //==       T r a i t e m e n t   s u r   S t a t u s        ==
+        //============================================================
+        if(LevelOfPointConfondu > 5)
+        { 
+          Status = IntWalk_ArretSurPoint; 
+          LevelOfPointConfondu = 0;  
+        }
+        //
+        if(Status==IntWalk_OK)
+        { 
+          NbPasOKConseq++;
+          if(NbPasOKConseq >= 5)
+          {
+            NbPasOKConseq=0;
+            Standard_Boolean pastroppetit;
+            Standard_Real t;
+            //
+            do
+            {
+              pastroppetit=Standard_True;
+              //
+              if(pasuv[0]<pasInit[0])
+              {
+                t = (pasInit[0]-pasuv[0])*0.25;
+                if(t>0.1*pasInit[0])
+                {
+                  t=0.1*pasuv[0];
+                }
+
+                pasuv[0]+=t; 
+                pastroppetit=Standard_False;
+              }
+
+              if(pasuv[1]<pasInit[1])
+              {
+                t = (pasInit[1]-pasuv[1])*0.25;
+                if(t>0.1*pasInit[1]) {
+                  t=0.1*pasuv[1];
+                }              
+
+                pasuv[1]+=t; 
+                pastroppetit=Standard_False;
+              }
+
+              if(pasuv[2]<pasInit[2])
+              {
+                t = (pasInit[2]-pasuv[2])*0.25;
+                if(t>0.1*pasInit[2])
+                {
+                  t=0.1*pasuv[2];
+                }
+
+                pasuv[2]+=t; 
+                pastroppetit=Standard_False;
+              }
+
+              if(pasuv[3]<pasInit[3])
+              {
+                t = (pasInit[3]-pasuv[3])*0.25;
+                if(t>0.1*pasInit[3]) {
+                  t=0.1*pasuv[3];
+                }
+                pasuv[3]+=t; 
+                pastroppetit=Standard_False;
+              }
+              if(pastroppetit)
+              {
+                if(pasMax<0.1)
+                {
+                  pasMax*=1.1;
+                  pasInit[0]*=1.1; 
+                  pasInit[1]*=1.1; 
+                  pasInit[2]*=1.1; 
+                  pasInit[3]*=1.1; 
+                }
+                else
+                {
+                  pastroppetit=Standard_False;
+                }
+              }
+            }
+            while(pastroppetit);
+          }
+        }//Status==IntWalk_OK
+        else
+          NbPasOKConseq=0;
+
+        //
+        switch(Status)//007 
+        {
+        case IntWalk_ArretSurPointPrecedent:
+          {
+            Arrive = Standard_False;
+            RepartirOuDiviser(DejaReparti, ChoixIso, Arrive);
+            break;
+          }
+        case IntWalk_PasTropGrand:
+          {
+            Param(1)=SvParam[0];
+            Param(2)=SvParam[1]; 
+            Param(3)=SvParam[2]; 
+            Param(4)=SvParam[3];
+
+            if(LevelOfIterWithoutAppend > 5)
+            {
+              if(pasSav[0]<pasInit[0])
+              {
+                pasInit[0]-=(pasInit[0]-pasSav[0])*0.25;
+                LevelOfIterWithoutAppend=0;
+              }
+
+              if(pasSav[1]<pasInit[1])
+              {
+                pasInit[1]-=(pasInit[1]-pasSav[1])*0.25;
+                LevelOfIterWithoutAppend=0;
+              }
+
+              if(pasSav[2]<pasInit[2])
+              {
+                pasInit[2]-=(pasInit[2]-pasSav[2])*0.25;
+                LevelOfIterWithoutAppend=0;
+              }
+
+              if(pasSav[3]<pasInit[3])
+              {
+                pasInit[3]-=(pasInit[3]-pasSav[3])*0.25;
+                LevelOfIterWithoutAppend=0;
+              }
+            }
+
+            break;
+          }
+        case IntWalk_PointConfondu:
+          {
+            LevelOfPointConfondu++;
+
+            if(LevelOfPointConfondu>5)
+            {
+              Standard_Boolean pastroppetit;
+              //
+              do
+              {
+                pastroppetit=Standard_True;
+
+                if(pasuv[0]<pasInit[0])
+                {
+                  pasuv[0]+=(pasInit[0]-pasuv[0])*0.25;
+                  pastroppetit=Standard_False;
+                }
+
+                if(pasuv[1]<pasInit[1])
+                {
+                  pasuv[1]+=(pasInit[1]-pasuv[1])*0.25;
+                  pastroppetit=Standard_False;
+                }
+
+                if(pasuv[2]<pasInit[2])
+                {
+                  pasuv[2]+=(pasInit[2]-pasuv[2])*0.25;
+                  pastroppetit=Standard_False; 
+                }
+
+                if(pasuv[3]<pasInit[3])
+                {
+                  pasuv[3]+=(pasInit[3]-pasuv[3])*0.25;
+                  pastroppetit=Standard_False;
+                }
+
+                if(pastroppetit)
+                {
+                  if(pasMax<0.1)
+                  {
+                    pasMax*=1.1;
+                    pasInit[0]*=1.1;
+                    pasInit[1]*=1.1;
+                    pasInit[2]*=1.1;
+                    pasInit[3]*=1.1; 
+                  }
+                  else
+                  {
+                    pastroppetit=Standard_False;
+                  }
+                }
+              }
+              while(pastroppetit);
+            }
+
+            break;
+          }
+        case IntWalk_OK:
+        case IntWalk_ArretSurPoint://006
+          {
+            //=======================================================
+            //== Stop Test t   :  Frame on Param(.)     ==
+            //=======================================================
+            //xft arrive here
+            Arrive = TestArret(DejaReparti,Param,ChoixIso); 
+            // JMB 30th December 1999. 
+            // Some statement below should not be put in comment because they are useful.
+            // See grid CTO 909 A1 which infinitely loops 
+            if(Arrive==Standard_False && Status==IntWalk_ArretSurPoint)
+            {
+              Arrive=Standard_True;
 #ifdef DEB
-             cout << "Compile with option DEB : if problems with intersection : ";
-             cout << "IntWalk_PWalking_1.gxx (lbr le 1erdec98)"<<endl;
+              cout << "Compile with option DEB : if problems with intersection : ";
+              cout << "IntWalk_PWalking_1.gxx (lbr le 1erdec98)"<<endl;
 #endif
-           }
-           if(Arrive) {
-             NbPasOKConseq = -10;
-           }
-           if(!Arrive)  {//005
-             //=====================================================
-             //== Param(.) is in the limits                       ==
-             //==  and does not end a closed  line                ==
-             //=====================================================
-             //== Check on the current point of myInters
-             Standard_Boolean pointisvalid = Standard_False;
-             {
-               Standard_Real u1,v1,u2,v2; 
-               myIntersectionOn2S.Point().Parameters(u1,v1,u2,v2); 
-               //
-               if(u1 <= UM1  && u2 <= UM2 && v1 <= VM1 && 
-                  v2 <= VM2  && u1 >= Um1 && u2 >= Um2 &&
-                  v1 >= Vm1  && v2 >= Vm2) {
-                 pointisvalid=Standard_True;
-               }
-             }
-             //
-             if(pointisvalid) { 
-               previousPoint = myIntersectionOn2S.Point();
-               previoustg = myIntersectionOn2S.IsTangent();
-               if(!previoustg) {
-                 previousd  = myIntersectionOn2S.Direction();
-                 previousd1 = myIntersectionOn2S.DirectionOnS1();
-                 previousd2 = myIntersectionOn2S.DirectionOnS2();
-               }
-               //=====================================================
-               //== Check on the previous Point
-               {
-                 Standard_Real u1,v1,u2,v2; 
-                 previousPoint.Parameters(u1,v1,u2,v2); 
-                 if( u1 <= UM1  && u2 <= UM2 && v1 <= VM1 &&
-                     v2 <= VM2  && u1 >= Um1 && u2 >= Um2 &&
-                     v1 >= Vm1  && v2 >= Vm2) { 
-                   pl = previousPoint.Value();
-                   if(bTestFirstPoint) {
-                     if(pf.Distance(pl) < 1.e-7){ 
-                       IncKey++; 
-                       if(IncKey == 5000) 
-                         return; 
-                       else 
-                         continue; 
-                     }
-                     else {
-                       bTestFirstPoint = Standard_False;
-                     }
-                   }
-                   //
-                   AddAPoint(line,previousPoint);
-                   RejectIndex++; 
-                   if(RejectIndex >= 250000) {
-                     break; 
-                   };
-                   //
-                   LevelOfIterWithoutAppend = 0;
-                 } 
-               }
-             }//pointisvalid
-             //====================================================
-             if(Status == IntWalk_ArretSurPoint)  {
-               RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
-             }
-             else{ 
-               if (line->NbPoints() == 2) {
-                 pasSav[0] = pasuv[0]; 
-                 pasSav[1] = pasuv[1]; 
-                 pasSav[2] = pasuv[2]; 
-                 pasSav[3] = pasuv[3];
-               }
-             }
-           }//005 if(!Arrive)
-           //
-           else {//004
-             if(close) { 
-               //================= la ligne est fermee ===============
-               AddAPoint(line,line->Value(1)); //ligne fermee
-               LevelOfIterWithoutAppend=0;
-             }
-             else {//$$$
-               //====================================================
-               //== Param was not in the limits (was reframed)
-               //====================================================
-               Standard_Boolean bPrevNotTangent = !previoustg || !myIntersectionOn2S.IsTangent();
-               
-               IntImp_ConstIsoparametric SauvChoixIso = ChoixIso;
-               ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld,ChoixIso);    
-               //
-               if(!myIntersectionOn2S.IsEmpty()) { //002
-                 // mutially outpasses in the square or intersection in corner
-                 if(TestArret(Standard_True,Param,ChoixIso))  {
-                   NbPasOKConseq = -10;
-                   ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld,ChoixIso); 
-                   if(!myIntersectionOn2S.IsEmpty())     {
-                     previousPoint = myIntersectionOn2S.Point();         
-                     previoustg = myIntersectionOn2S.IsTangent();
-                     if (!previoustg)     {
-                       previousd  = myIntersectionOn2S.Direction();
-                       previousd1 = myIntersectionOn2S.DirectionOnS1();
-                       previousd2 = myIntersectionOn2S.DirectionOnS2();
-                     }
-                     pl = previousPoint.Value();
-                     if(bTestFirstPoint) {
-                       if(pf.Distance(pl) < 1.e-7){ 
-                         IncKey++; 
-                         if(IncKey == 5000) 
-                           return; 
-                         else 
-                           continue; 
-                       }
-                       else {
-                         bTestFirstPoint = Standard_False;
-                       }
-                     }
-                     //
-                     AddAPoint(line,previousPoint);
-                     RejectIndex++;
-                     if(RejectIndex >= 250000) {
-                       break;
-                     };
-                     //
-                     LevelOfIterWithoutAppend=0;
-                     RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
-                   }
-                   else  {
-                     //fail framing divides the step
-                     Arrive = Standard_False;
-                     RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
-                     NoTestDeflection = Standard_True;
-                     ChoixIso = SauvChoixIso;
-                   }
-                 }//if(TestArret())
-                 else {
-                   // save the last point
-                   // to revert to it if the current point is out of bounds
-                   IntSurf_PntOn2S previousPointSave = previousPoint;
-                   Standard_Boolean previoustgSave   = previoustg;
-                   gp_Dir previousdSave              = previousd;
-                   gp_Dir2d previousd1Save           = previousd1;
-                   gp_Dir2d previousd2Save           = previousd2;
-                   
-                   previousPoint = myIntersectionOn2S.Point();         
-                   previoustg = myIntersectionOn2S.IsTangent();
-                   Arrive = Standard_False; 
-                   if(!previoustg)  {
-                     previousd  = myIntersectionOn2S.Direction();
-                     previousd1 = myIntersectionOn2S.DirectionOnS1();
-                     previousd2 = myIntersectionOn2S.DirectionOnS2();
-                   }
-                   //========================================
-                   //== Check on PreviousPoint @@
-                   {
-                     Standard_Real u1,v1,u2,v2; 
-                     previousPoint.Parameters(u1,v1,u2,v2);
+            }
+
+            if(Arrive)
+            {
+              NbPasOKConseq = -10;
+            }
+
+            if(!Arrive)//005
+            {
+              //=====================================================
+              //== Param(.) is in the limits                       ==
+              //==  and does not end a closed  line                ==
+              //=====================================================
+              //== Check on the current point of myInters
+              Standard_Boolean pointisvalid = Standard_False;
+              {
+                Standard_Real u1,v1,u2,v2; 
+                myIntersectionOn2S.Point().Parameters(u1,v1,u2,v2);
+
+                //
+                if(u1 <= UM1  && u2 <= UM2 && v1 <= VM1 && 
+                  v2 <= VM2  && u1 >= Um1 && u2 >= Um2 &&
+                  v1 >= Vm1  && v2 >= Vm2)
+                {
+                  pointisvalid=Standard_True;
+                }
+              }
+
+              //
+              if(pointisvalid)
+              {
+                previousPoint = myIntersectionOn2S.Point();
+                previoustg = myIntersectionOn2S.IsTangent();
+
+                if(!previoustg)
+                {
+                  previousd  = myIntersectionOn2S.Direction();
+                  previousd1 = myIntersectionOn2S.DirectionOnS1();
+                  previousd2 = myIntersectionOn2S.DirectionOnS2();
+                }
+                //=====================================================
+                //== Check on the previous Point
+                {
+                  Standard_Real u1,v1,u2,v2;
+                  previousPoint.Parameters(u1,v1,u2,v2); 
+                  if( u1 <= UM1  && u2 <= UM2 && v1 <= VM1 &&
+                    v2 <= VM2  && u1 >= Um1 && u2 >= Um2 &&
+                    v1 >= Vm1  && v2 >= Vm2)
+                  {
+                    pl = previousPoint.Value();
+                    if(bTestFirstPoint)
+                    {
+                      if(pf.SquareDistance(pl) < aSQDistMax)
+                      {
+                        IncKey++;
+                        if(IncKey == 5000)
+                          return;
+                        else
+                          continue;
+                      }
+                      else
+                      {
+                        bTestFirstPoint = Standard_False;
+                      }
+                    }
+                    //
+                    AddAPoint(line,previousPoint);
+                    RejectIndex++;
+
+                    if(RejectIndex >= RejectIndexMAX)
+                    {
+                      break;
+                    }
+
+                    //
+                    LevelOfIterWithoutAppend = 0;
+                  }
+                }
+              }//pointisvalid
+              //====================================================
+
+              if(Status == IntWalk_ArretSurPoint)
+              {
+                RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
+              }
+              else
+              {
+                if (line->NbPoints() == 2)
+                {
+                  pasSav[0] = pasuv[0];
+                  pasSav[1] = pasuv[1];
+                  pasSav[2] = pasuv[2];
+                  pasSav[3] = pasuv[3];
+                }
+              }
+            }//005 if(!Arrive)
+            else  //004
+            {
+              if(close)
+              {
+                //================= la ligne est fermee ===============
+                AddAPoint(line,line->Value(1)); //ligne fermee
+                LevelOfIterWithoutAppend=0;
+              }
+              else    //$$$
+              {
+                //====================================================
+                //== Param was not in the limits (was reframed)
+                //====================================================
+                Standard_Boolean bPrevNotTangent = !previoustg || !myIntersectionOn2S.IsTangent();
+
+                IntImp_ConstIsoparametric SauvChoixIso = ChoixIso;
+                ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld,ChoixIso);
+                //
+                if(!myIntersectionOn2S.IsEmpty()) //002
+                {
+                  // mutially outpasses in the square or intersection in corner
+
+                  if(TestArret(Standard_True,Param,ChoixIso))
+                  {
+                    NbPasOKConseq = -10;
+                    ChoixIso = myIntersectionOn2S.Perform(Param,Rsnld,ChoixIso);
+
+                    if(!myIntersectionOn2S.IsEmpty())
+                    {
+                      previousPoint = myIntersectionOn2S.Point();
+                      previoustg = myIntersectionOn2S.IsTangent();
+
+                      if (!previoustg)
+                      {
+                        previousd  = myIntersectionOn2S.Direction();
+                        previousd1 = myIntersectionOn2S.DirectionOnS1();
+                        previousd2 = myIntersectionOn2S.DirectionOnS2();
+                      }
+
+                      pl = previousPoint.Value();
+
+                      if(bTestFirstPoint)
+                      {
+                        if(pf.SquareDistance(pl) < aSQDistMax)
+                        {
+                          IncKey++;
+                          if(IncKey == 5000)
+                            return;
+                          else
+                            continue;
+                        }
+                        else
+                        {
+                          bTestFirstPoint = Standard_False;
+                        }
+                      }
+                      //
+                      AddAPoint(line,previousPoint);
+                      RejectIndex++;
+
+                      if(RejectIndex >= RejectIndexMAX)
+                      {
+                        break;
+                      }
+
+                      //
+                      LevelOfIterWithoutAppend=0;
+                      RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
+                    }
+                    else
+                    {
+                      //fail framing divides the step
+                      Arrive = Standard_False;
+                      RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
+                      NoTestDeflection = Standard_True;
+                      ChoixIso = SauvChoixIso;
+                    }
+                  }//if(TestArret())
+                  else
+                  {
+                    // save the last point
+                    // to revert to it if the current point is out of bounds
+
+                    IntSurf_PntOn2S previousPointSave = previousPoint;
+                    Standard_Boolean previoustgSave   = previoustg;
+                    gp_Dir previousdSave              = previousd;
+                    gp_Dir2d previousd1Save           = previousd1;
+                    gp_Dir2d previousd2Save           = previousd2;
+
+                    previousPoint = myIntersectionOn2S.Point();
+                    previoustg = myIntersectionOn2S.IsTangent();
+                    Arrive = Standard_False;
+
+                    if(!previoustg)
+                    {
+                      previousd  = myIntersectionOn2S.Direction();
+                      previousd1 = myIntersectionOn2S.DirectionOnS1();
+                      previousd2 = myIntersectionOn2S.DirectionOnS2();
+                    }
+
+                    //========================================
+                    //== Check on PreviousPoint @@
+
+                    {
+                      Standard_Real u1,v1,u2,v2;
+                      previousPoint.Parameters(u1,v1,u2,v2);
+
                       //To save initial 2d points
                       gp_Pnt2d ParamPntOnS1(Param(1), Param(2));
                       gp_Pnt2d ParamPntOnS2(Param(3), Param(4));
+
                       ///////////////////////////
-                     Param(1) = u1; 
-                     Param(2) = v1;    
-                     Param(3) = u2; 
-                     Param(4) = v2;
-                     //
-                     //xf
-                     Standard_Boolean bFlag1, bFlag2;
-                     Standard_Real aTol2D=1.e-11;
-                     //
-                     bFlag1=u1 >= Um1-aTol2D && v1 >= Vm1-aTol2D && u1 <= UM1+aTol2D && v1 <= VM1+aTol2D;
-                     bFlag2=u2 >= Um2-aTol2D && v2 >= Vm2-aTol2D && u2 <= UM2+aTol2D && v2 <= VM2+aTol2D;
-                     if (bFlag1 && bFlag2) {
-                     /*
-                     if(u1 <= UM1  && u2 <= UM2 && v1 <= VM1 &&
-                        v2 <= VM2  && u1 >= Um1 && u2 >= Um2 &&
-                        v1 >= Vm1  && v2 >= Vm2)  {
-                        */                     
-                     //xt
-                       pl = previousPoint.Value();
-                       if(bTestFirstPoint) {
-                         if(pf.Distance(pl) < 1.e-7) {
-                           IncKey++;
-                           if(IncKey == 5000)
-                             return; 
-                           else 
-                             continue;
-                         }
-                         else {
-                           bTestFirstPoint = Standard_False;
-                         }
-                       }
+                      Param(1) = u1;
+                      Param(2) = v1;
+                      Param(3) = u2;
+                      Param(4) = v2;
+                      //
+
+                      //xf
+                      Standard_Boolean bFlag1, bFlag2;
+                      Standard_Real aTol2D=1.e-11;
+                      //
+                      bFlag1=u1 >= Um1-aTol2D && v1 >= Vm1-aTol2D && u1 <= UM1+aTol2D && v1 <= VM1+aTol2D;
+                      bFlag2=u2 >= Um2-aTol2D && v2 >= Vm2-aTol2D && u2 <= UM2+aTol2D && v2 <= VM2+aTol2D;
+                      if (bFlag1 && bFlag2)
+                      {
+                        /*
+                        if(u1 <= UM1  && u2 <= UM2 && v1 <= VM1 &&
+                        v2 <= VM2  && u1 >= Um1 && u2 >= Um2 &&
+                        v1 >= Vm1  && v2 >= Vm2)  {
+                        */                     
+                        //xt
+                        pl = previousPoint.Value();
+
+                        if(bTestFirstPoint)
+                        {
+                          if(pf.SquareDistance(pl) < aSQDistMax)
+                          {
+                            IncKey++;
+
+                            if(IncKey == 5000)
+                              return;
+                            else
+                              continue;
+                          }
+                          else
+                          {
+                            bTestFirstPoint = Standard_False;
+                          }
+                        }
+
                         //To avoid walking around the same point
                         //in the tangent zone near a border
+
                         if (previoustg)
                         {
                           Standard_Real prevU1, prevV1, prevU2, prevV2;
@@ -1011,70 +1323,84 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
                           gp_Vec2d PrevToParamOnS2(prevPntOnS2, ParamPntOnS2);
                           gp_Vec2d PrevToCurOnS2(prevPntOnS2, curPntOnS2);
                           Standard_Real MaxAngle = 3*M_PI/4;
+
                           if (Abs(PrevToParamOnS1.Angle(PrevToCurOnS1)) > MaxAngle &&
-                              Abs(PrevToParamOnS2.Angle(PrevToCurOnS2)) > MaxAngle)
+                            Abs(PrevToParamOnS2.Angle(PrevToCurOnS2)) > MaxAngle)
                           {
                             Arrive = Standard_True;
                             break;
                           }
                         }
+
                         ////////////////////////////////////////
-                       AddAPoint(line,previousPoint);
-                       RejectIndex++;
-                       if(RejectIndex >= 250000) {
-                         break;
-                       }
-                       //
-                       LevelOfIterWithoutAppend=0;
-                       Arrive = Standard_True;
-                     }
-                     else {
-                       // revert to the last correctly calculated point
-                       previousPoint = previousPointSave;
-                       previoustg    = previoustgSave;
-                       previousd     = previousdSave;
-                       previousd1    = previousd1Save;
-                       previousd2    = previousd2Save;
-                     }
-                   }
-                   //
-                   Standard_Boolean wasExtended = Standard_False;
-                   
-                   if(Arrive && myIntersectionOn2S.IsTangent() && bPrevNotTangent) {
-                     if(ExtendLineInCommonZone(SauvChoixIso, DejaReparti)) {
-                       wasExtended = Standard_True;
-                       Arrive = Standard_False;
-                       ChoixIso = SauvChoixIso;
-                     }
-                   }
-                   
-                   RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
-                   if(Arrive && 
-                      myIntersectionOn2S.IsDone() && !myIntersectionOn2S.IsEmpty() &&
-                      myIntersectionOn2S.IsTangent() && bPrevNotTangent &&
-                      !wasExtended) {
-                     
-                     if(ExtendLineInCommonZone(SauvChoixIso, DejaReparti)) {
-                       wasExtended = Standard_True;
-                       Arrive = Standard_False;
-                       ChoixIso = SauvChoixIso;
-                     }
-                   }
-                 }//else !TestArret() $
-               } //$$ end successful framing on border (!myIntersectionOn2S.IsEmpty())
-               else  {
-                 //echec framing on border; division of step 
-                 Arrive = Standard_False;
-                 NoTestDeflection = Standard_True;
-                 RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
-               } 
-             }//$$$ end framing on border (!close)
-           } //004 fin TestArret return Arrive = True
-         } // 006case IntWalk_ArretSurPoint:  end Processing Status = OK  or ArretSurPoint 
-       } //007  switch(Status) 
+                        AddAPoint(line,previousPoint);
+                        RejectIndex++;
+
+                        if(RejectIndex >= RejectIndexMAX)
+                        {
+                          break;
+                        }
+
+                        //
+
+                        LevelOfIterWithoutAppend=0;
+                        Arrive = Standard_True;
+                      }
+                      else
+                      {
+                        // revert to the last correctly calculated point
+                        previousPoint = previousPointSave;
+                        previoustg    = previoustgSave;
+                        previousd     = previousdSave;
+                        previousd1    = previousd1Save;
+                        previousd2    = previousd2Save;
+                      }
+                    }
+
+                    //
+                    Standard_Boolean wasExtended = Standard_False;
+
+                    if(Arrive && myIntersectionOn2S.IsTangent() && bPrevNotTangent)
+                    {
+                      if(ExtendLineInCommonZone(SauvChoixIso, DejaReparti))
+                      {
+                        wasExtended = Standard_True;
+                        Arrive = Standard_False;
+                        ChoixIso = SauvChoixIso;
+                      }
+                    }
+
+                    RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
+
+                    if(Arrive && 
+                      myIntersectionOn2S.IsDone() && !myIntersectionOn2S.IsEmpty() &&
+                      myIntersectionOn2S.IsTangent() && bPrevNotTangent &&
+                      !wasExtended)
+                    {
+                      if(ExtendLineInCommonZone(SauvChoixIso, DejaReparti))
+                      {
+                        wasExtended = Standard_True;
+                        Arrive = Standard_False;
+                        ChoixIso = SauvChoixIso;
+                      }
+                    }
+                  }//else !TestArret() $
+                }//$$ end successful framing on border (!myIntersectionOn2S.IsEmpty())
+                else
+                {
+                  //echec framing on border; division of step 
+                  Arrive = Standard_False;
+                  NoTestDeflection = Standard_True;
+                  RepartirOuDiviser(DejaReparti,ChoixIso,Arrive);
+                }
+              }//$$$ end framing on border (!close)
+            }//004 fin TestArret return Arrive = True
+          } // 006case IntWalk_ArretSurPoint:  end Processing Status = OK  or ArretSurPoint 
+        } //007  switch(Status) 
       } //008 end processing point  (TEST DEFLECTION)
     } //009 end processing line (else if myIntersectionOn2S.IsDone())
   }  //010 end if first departure point allows marching  while (!Arrive)
+
   done = Standard_True;
 }
 // ===========================================================================================================
@@ -1084,7 +1410,7 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
 //           is outside the tangent zone (but it is not put into the line). Otherwise returns Standard_False.
 // ===========================================================================================================
 Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric theChoixIso,
-                                                         const Standard_Boolean          theDirectionFlag) 
+                                                          const Standard_Boolean          theDirectionFlag) 
 {
   Standard_Boolean bOutOfTangentZone = Standard_False;
   Standard_Boolean bStop = !myIntersectionOn2S.IsTangent();
@@ -1111,15 +1437,15 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop
     Standard_Real f = 0.;
 
     switch (theChoixIso)
-      
-      case IntImp_UIsoparametricOnCaro1: f = Abs(previousd1.X()); break;
-      case IntImp_VIsoparametricOnCaro1: f = Abs(previousd1.Y()); break;
-      case IntImp_UIsoparametricOnCaro2: f = Abs(previousd2.X()); break;
-      case IntImp_VIsoparametricOnCaro2: f = Abs(previousd2.Y()); break;
-      }
+    { 
+    case IntImp_UIsoparametricOnCaro1: f = Abs(previousd1.X()); break;
+    case IntImp_VIsoparametricOnCaro1: f = Abs(previousd1.Y()); break;
+    case IntImp_UIsoparametricOnCaro2: f = Abs(previousd2.X()); break;
+    case IntImp_VIsoparametricOnCaro2: f = Abs(previousd2.Y()); break;
+    }
 
     if(f<0.1) f=0.1;
-    
+
     previousPoint.Parameters(Param(1),Param(2),Param(3),Param(4));
 
     Standard_Real dP1 = sensCheminement * pasuv[0] * previousd1.X() /f;
@@ -1131,7 +1457,7 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop
     if(theChoixIso == IntImp_VIsoparametricOnCaro1 && Abs(dP2) < 1.e-7) dP2 *= (5. * (Standard_Real)dIncKey);
     if(theChoixIso == IntImp_UIsoparametricOnCaro2 && Abs(dP3) < 1.e-7) dP3 *= (5. * (Standard_Real)dIncKey);
     if(theChoixIso == IntImp_VIsoparametricOnCaro2 && Abs(dP4) < 1.e-7) dP4 *= (5. * (Standard_Real)dIncKey);
-   
+
     Param(1) += dP1;
     Param(2) += dP2;
     Param(3) += dP3; 
@@ -1150,196 +1476,196 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop
     }
     else {
       if (myIntersectionOn2S.IsEmpty()) {
-       return bOutOfTangentZone;
+        return bOutOfTangentZone;
       }
 
       Status = TestDeflection();
 
       if(Status == IntWalk_OK) {
 
-       for(uvit = 0; uvit < 4; uvit++) {
-         if(pasuv[uvit] < pasInit[uvit]) {
-           pasuv[uvit] = pasInit[uvit];
-         }
-       }
+        for(uvit = 0; uvit < 4; uvit++) {
+          if(pasuv[uvit] < pasInit[uvit]) {
+            pasuv[uvit] = pasInit[uvit];
+          }
+        }
       }
 
       switch(Status) {
       case  IntWalk_ArretSurPointPrecedent:
-       {
-         bStop = Standard_True;
-         bOutOfTangentZone = !myIntersectionOn2S.IsTangent();
-         break;
-       }
+        {
+          bStop = Standard_True;
+          bOutOfTangentZone = !myIntersectionOn2S.IsTangent();
+          break;
+        }
       case IntWalk_PasTropGrand:
-       {
-         for(parit = 0; parit < 4; parit++) {
-           Param(parit+1) = SvParam[parit];
-         }
-         Standard_Boolean bDecrease = Standard_False;
-
-         for(uvit = 0; uvit < 4; uvit++) {
-           if(pasSav[uvit] < pasInit[uvit]) { 
-             pasInit[uvit] -= (pasInit[uvit] - pasSav[uvit]) * 0.1;
-             bDecrease = Standard_True;
-           }
-         }
-
-         if(bDecrease) nbIterWithoutAppend--;
-         break;
-       }
+        {
+          for(parit = 0; parit < 4; parit++) {
+            Param(parit+1) = SvParam[parit];
+          }
+          Standard_Boolean bDecrease = Standard_False;
+
+          for(uvit = 0; uvit < 4; uvit++) {
+            if(pasSav[uvit] < pasInit[uvit]) { 
+              pasInit[uvit] -= (pasInit[uvit] - pasSav[uvit]) * 0.1;
+              bDecrease = Standard_True;
+            }
+          }
+
+          if(bDecrease) nbIterWithoutAppend--;
+          break;
+        }
       case IntWalk_PointConfondu:
-       {
-         for(uvit = 0; uvit < 4; uvit++) {
-           if(pasuv[uvit] < pasInit[uvit]) {
-             pasuv[uvit] += (pasInit[uvit] - pasuv[uvit]) * 0.1;
-           }
-         }
-         break;
-       }
+        {
+          for(uvit = 0; uvit < 4; uvit++) {
+            if(pasuv[uvit] < pasInit[uvit]) {
+              pasuv[uvit] += (pasInit[uvit] - pasuv[uvit]) * 0.1;
+            }
+          }
+          break;
+        }
       case IntWalk_OK:
       case IntWalk_ArretSurPoint:
-       {
-         //
-         bStop = TestArret(theDirectionFlag, Param, ChoixIso);
-         //
-
-         //
-         if(!bStop) {
-           Standard_Real u11,v11,u12,v12; 
-           myIntersectionOn2S.Point().Parameters(u11,v11,u12,v12); 
-           Standard_Real u21,v21,u22,v22;
-           previousPoint.Parameters(u21,v21,u22,v22); 
-
-           if(((fabs(u11-u21) < ResoU1) && (fabs(v11-v21) < ResoV1)) ||
-              ((fabs(u12-u22) < ResoU2) && (fabs(v12-v22) < ResoV2))) {
-             nbEqualPoints++;
-           }
-           else {
-             nbEqualPoints = 0;
-           }
-         }
-         //
-
-         bStop = bStop || !myIntersectionOn2S.IsTangent();
-         bOutOfTangentZone = !myIntersectionOn2S.IsTangent();
-
-         if(!bStop) {
-           Standard_Boolean pointisvalid = Standard_False;
-           Standard_Real u1,v1,u2,v2; 
-           myIntersectionOn2S.Point().Parameters(u1,v1,u2,v2); 
-
-           if(u1 <= UM1  && u2 <= UM2 && v1 <= VM1 && 
-              v2 <= VM2  && u1 >= Um1 && u2 >= Um2 &&
-              v1 >= Vm1  && v2 >= Vm2) 
-             pointisvalid = Standard_True;
-
-           if(pointisvalid) {
-             previousPoint = myIntersectionOn2S.Point();
-             previoustg = myIntersectionOn2S.IsTangent();
-
-             if(!previoustg) {
-               previousd  = myIntersectionOn2S.Direction();
-               previousd1 = myIntersectionOn2S.DirectionOnS1();
-               previousd2 = myIntersectionOn2S.DirectionOnS2();
-             }
-             Standard_Boolean bAddPoint = Standard_True;
-
-             if(line->NbPoints() >= 1) {
-               gp_Pnt pf = line->Value(1).Value();
-               gp_Pnt pl = previousPoint.Value(); 
-
-               if(pf.Distance(pl) < Precision::Confusion()) { 
-                 dIncKey++; 
-                 if(dIncKey == 5000) return bOutOfTangentZone; 
-                 else bAddPoint = Standard_False;
-               }
-             }
-
-             if(bAddPoint) {
-               aSeqOfNewPoint.Append(previousPoint);
-               nbIterWithoutAppend = 0;
-             }
-           }
-
-           if (line->NbPoints() == 2) {
-             for(uvit = 0; uvit < 4; uvit++) {
-               pasSav[uvit] = pasuv[uvit]; 
-             }
-           }
-
-           if ( !pointisvalid ) {
-             // decrease step if out of bounds
-             // otherwise the same calculations will be 
-             // repeated several times
-             if ( ( u1 > UM1 ) || ( u1 < Um1 ) )
-               pasuv[0] *= 0.5;
-
-             if ( ( v1 > VM1 ) || ( v1 < Vm1 ) ) 
-               pasuv[1] *= 0.5;
-
-             if ( ( u2 > UM2 ) || ( u2 < Um2 ) )
-               pasuv[2] *= 0.5;
-
-             if ( ( v2 > VM2 ) || ( v2 < Vm2 ) )
-               pasuv[3] *= 0.5;
-           }
-         } // end if(!bStop)
-         else { //if(bStop)
-           if(close && (line->NbPoints() >= 1)) { 
-
-             if(!bOutOfTangentZone) {
-               aSeqOfNewPoint.Append(line->Value(1)); // line end
-             }
-             nbIterWithoutAppend = 0;
-           }
-           else {
-             ChoixIso = myIntersectionOn2S.Perform(Param, Rsnld, theChoixIso);
-
-             if(myIntersectionOn2S.IsEmpty()) { 
-               bStop = !myIntersectionOn2S.IsTangent();
-               bOutOfTangentZone = !myIntersectionOn2S.IsTangent();
-             }
-             else {
-               Standard_Boolean bAddPoint = Standard_True;
-               Standard_Boolean pointisvalid = Standard_False;
-
-               previousPoint = myIntersectionOn2S.Point();
-               Standard_Real u1,v1,u2,v2; 
-               previousPoint.Parameters(u1,v1,u2,v2); 
-
-               if(u1 <= UM1  && u2 <= UM2 && v1 <= VM1 && 
-                  v2 <= VM2  && u1 >= Um1 && u2 >= Um2 &&
-                  v1 >= Vm1  && v2 >= Vm2) 
-                 pointisvalid = Standard_True;
-
-               if(pointisvalid) {
-
-                 if(line->NbPoints() >= 1) {
-                   gp_Pnt pf = line->Value(1).Value();
-                   gp_Pnt pl = previousPoint.Value(); 
-
-                   if(pf.Distance(pl) < Precision::Confusion()) { 
-                     dIncKey++; 
-                     if(dIncKey == 5000) return bOutOfTangentZone; 
-                     else bAddPoint = Standard_False;
-                   }
-                 }
-
-                 if(bAddPoint && !bOutOfTangentZone) {
-                   aSeqOfNewPoint.Append(previousPoint);
-                   nbIterWithoutAppend = 0;
-                 }
-               }
-             }
-           }
-         }
-         break;
-       }
+        {
+          //
+          bStop = TestArret(theDirectionFlag, Param, ChoixIso);
+          //
+
+          //
+          if(!bStop) {
+            Standard_Real u11,v11,u12,v12; 
+            myIntersectionOn2S.Point().Parameters(u11,v11,u12,v12); 
+            Standard_Real u21,v21,u22,v22;
+            previousPoint.Parameters(u21,v21,u22,v22); 
+
+            if(((fabs(u11-u21) < ResoU1) && (fabs(v11-v21) < ResoV1)) ||
+              ((fabs(u12-u22) < ResoU2) && (fabs(v12-v22) < ResoV2))) {
+                nbEqualPoints++;
+            }
+            else {
+              nbEqualPoints = 0;
+            }
+          }
+          //
+
+          bStop = bStop || !myIntersectionOn2S.IsTangent();
+          bOutOfTangentZone = !myIntersectionOn2S.IsTangent();
+
+          if(!bStop) {
+            Standard_Boolean pointisvalid = Standard_False;
+            Standard_Real u1,v1,u2,v2; 
+            myIntersectionOn2S.Point().Parameters(u1,v1,u2,v2); 
+
+            if(u1 <= UM1  && u2 <= UM2 && v1 <= VM1 && 
+              v2 <= VM2  && u1 >= Um1 && u2 >= Um2 &&
+              v1 >= Vm1  && v2 >= Vm2) 
+              pointisvalid = Standard_True;
+
+            if(pointisvalid) {
+              previousPoint = myIntersectionOn2S.Point();
+              previoustg = myIntersectionOn2S.IsTangent();
+
+              if(!previoustg) {
+                previousd  = myIntersectionOn2S.Direction();
+                previousd1 = myIntersectionOn2S.DirectionOnS1();
+                previousd2 = myIntersectionOn2S.DirectionOnS2();
+              }
+              Standard_Boolean bAddPoint = Standard_True;
+
+              if(line->NbPoints() >= 1) {
+                gp_Pnt pf = line->Value(1).Value();
+                gp_Pnt pl = previousPoint.Value(); 
+
+                if(pf.Distance(pl) < Precision::Confusion()) { 
+                  dIncKey++; 
+                  if(dIncKey == 5000) return bOutOfTangentZone; 
+                  else bAddPoint = Standard_False;
+                }
+              }
+
+              if(bAddPoint) {
+                aSeqOfNewPoint.Append(previousPoint);
+                nbIterWithoutAppend = 0;
+              }
+            }
+
+            if (line->NbPoints() == 2) {
+              for(uvit = 0; uvit < 4; uvit++) {
+                pasSav[uvit] = pasuv[uvit]; 
+              }
+            }
+
+            if ( !pointisvalid ) {
+              // decrease step if out of bounds
+              // otherwise the same calculations will be 
+              // repeated several times
+              if ( ( u1 > UM1 ) || ( u1 < Um1 ) )
+                pasuv[0] *= 0.5;
+
+              if ( ( v1 > VM1 ) || ( v1 < Vm1 ) ) 
+                pasuv[1] *= 0.5;
+
+              if ( ( u2 > UM2 ) || ( u2 < Um2 ) )
+                pasuv[2] *= 0.5;
+
+              if ( ( v2 > VM2 ) || ( v2 < Vm2 ) )
+                pasuv[3] *= 0.5;
+            }
+          } // end if(!bStop)
+          else { //if(bStop)
+            if(close && (line->NbPoints() >= 1)) { 
+
+              if(!bOutOfTangentZone) {
+                aSeqOfNewPoint.Append(line->Value(1)); // line end
+              }
+              nbIterWithoutAppend = 0;
+            }
+            else {
+              ChoixIso = myIntersectionOn2S.Perform(Param, Rsnld, theChoixIso);
+
+              if(myIntersectionOn2S.IsEmpty()) { 
+                bStop = !myIntersectionOn2S.IsTangent();
+                bOutOfTangentZone = !myIntersectionOn2S.IsTangent();
+              }
+              else {
+                Standard_Boolean bAddPoint = Standard_True;
+                Standard_Boolean pointisvalid = Standard_False;
+
+                previousPoint = myIntersectionOn2S.Point();
+                Standard_Real u1,v1,u2,v2; 
+                previousPoint.Parameters(u1,v1,u2,v2); 
+
+                if(u1 <= UM1  && u2 <= UM2 && v1 <= VM1 && 
+                  v2 <= VM2  && u1 >= Um1 && u2 >= Um2 &&
+                  v1 >= Vm1  && v2 >= Vm2) 
+                  pointisvalid = Standard_True;
+
+                if(pointisvalid) {
+
+                  if(line->NbPoints() >= 1) {
+                    gp_Pnt pf = line->Value(1).Value();
+                    gp_Pnt pl = previousPoint.Value(); 
+
+                    if(pf.Distance(pl) < Precision::Confusion()) { 
+                      dIncKey++; 
+                      if(dIncKey == 5000) return bOutOfTangentZone; 
+                      else bAddPoint = Standard_False;
+                    }
+                  }
+
+                  if(bAddPoint && !bOutOfTangentZone) {
+                    aSeqOfNewPoint.Append(previousPoint);
+                    nbIterWithoutAppend = 0;
+                  }
+                }
+              }
+            }
+          }
+          break;
+        }
       default:
-       {
-         break;
-       }
+        {
+          break;
+        }
       }
     }
   }
@@ -1353,19 +1679,19 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop
       previousPoint.Parameters(u1,v1,u2,v2); 
     else {
       if(aSeqOfNewPoint.Length() > 0)
-       aSeqOfNewPoint.Value(aSeqOfNewPoint.Length()).Parameters(u1,v1,u2,v2); 
+        aSeqOfNewPoint.Value(aSeqOfNewPoint.Length()).Parameters(u1,v1,u2,v2); 
       else
-       break;
+        break;
     }
 
     if(((u1 - Um1) < ResoU1) ||
-       ((UM1 - u1) < ResoU1) ||
-       ((u2 - Um2) < ResoU2) ||
-       ((UM2 - u2) < ResoU2) ||
-       ((v1 - Vm1) < ResoV1) ||
-       ((VM1 - v1) < ResoV1) ||
-       ((v2 - Vm2) < ResoV2) ||
-       ((VM2 - v2) < ResoV2))
+      ((UM1 - u1) < ResoU1) ||
+      ((u2 - Um2) < ResoU2) ||
+      ((UM2 - u2) < ResoU2) ||
+      ((v1 - Vm1) < ResoV1) ||
+      ((VM1 - v1) < ResoV1) ||
+      ((v2 - Vm2) < ResoV2) ||
+      ((VM2 - v2) < ResoV2))
       bExtendLine = Standard_True;
   }
 
@@ -1375,86 +1701,86 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop
       bExtendLine = Standard_True;
 
       if(aSeqOfNewPoint.Length() > 1) {
-       TColStd_Array1OfReal FirstParams(0, 3), LastParams(0, 3), Resolutions(0, 3);
-       Resolutions(0) = ResoU1; Resolutions(1) = ResoV1; Resolutions(2) = ResoU2; Resolutions(3) = ResoV2;
-
-       aSeqOfNewPoint(1).Parameters(FirstParams.ChangeValue(0), FirstParams.ChangeValue(1),
-                                    FirstParams.ChangeValue(2), FirstParams.ChangeValue(3));
-       aSeqOfNewPoint(aSeqOfNewPoint.Length()).Parameters(LastParams.ChangeValue(0), 
-                                                          LastParams.ChangeValue(1),
-                                                          LastParams.ChangeValue(2), 
-                                                          LastParams.ChangeValue(3)); 
-       Standard_Integer indexofiso = 0;
-
-       if(theChoixIso == IntImp_UIsoparametricOnCaro1) indexofiso = 0;
-       if(theChoixIso == IntImp_VIsoparametricOnCaro1) indexofiso = 1;
-       if(theChoixIso == IntImp_UIsoparametricOnCaro2) indexofiso = 2;
-       if(theChoixIso == IntImp_VIsoparametricOnCaro2) indexofiso = 3;
-
-       Standard_Integer afirstindex = (indexofiso < 2) ? 0 : 2;
-       gp_Vec2d aTangentZoneDir(gp_Pnt2d(FirstParams.Value(afirstindex), FirstParams.Value(afirstindex + 1)),
-                                gp_Pnt2d(LastParams.Value(afirstindex), LastParams.Value(afirstindex + 1)));
-
-       gp_Dir2d anIsoDir(0, 1);
-
-       if((indexofiso == 1) || (indexofiso == 3))
-         anIsoDir = gp_Dir2d(1, 0);
-
-       if(aTangentZoneDir.SquareMagnitude() > gp::Resolution()) {
-         Standard_Real piquota = M_PI*0.25;
-
-         if(fabs(aTangentZoneDir.Angle(anIsoDir)) > piquota) {
-           Standard_Integer ii = 1, nextii = 2;
-           gp_Vec2d d1(0, 0);
-           Standard_Real asqresol = gp::Resolution();
-           asqresol *= asqresol;
-
-           do {
-             aSeqOfNewPoint(ii).Parameters(FirstParams.ChangeValue(0), FirstParams.ChangeValue(1),
-                                           FirstParams.ChangeValue(2), FirstParams.ChangeValue(3));
-             aSeqOfNewPoint(ii + 1).Parameters(LastParams.ChangeValue(0), LastParams.ChangeValue(1),
-                                                 LastParams.ChangeValue(2), LastParams.ChangeValue(3));
-             d1 = gp_Vec2d(gp_Pnt2d(FirstParams.Value(afirstindex),
-                                    FirstParams.Value(afirstindex + 1)),
-                           gp_Pnt2d(LastParams.Value(afirstindex),
-                                    LastParams.Value(afirstindex + 1)));
-             ii++;
-           }
-           while((d1.SquareMagnitude() < asqresol) &&
-                 (ii < aSeqOfNewPoint.Length()));
-
-           nextii = ii;
-
-           while(nextii < aSeqOfNewPoint.Length()) {
-
-             gp_Vec2d nextd1(0, 0);
-             Standard_Integer jj = nextii;
-
-             do {
-               aSeqOfNewPoint(jj).Parameters(FirstParams.ChangeValue(0), FirstParams.ChangeValue(1),
-                                             FirstParams.ChangeValue(2), FirstParams.ChangeValue(3));
-               aSeqOfNewPoint(jj + 1).Parameters(LastParams.ChangeValue(0), LastParams.ChangeValue(1),
-                                                 LastParams.ChangeValue(2), LastParams.ChangeValue(3));
-               nextd1 = gp_Vec2d(gp_Pnt2d(FirstParams.Value(afirstindex),
-                                          FirstParams.Value(afirstindex + 1)),
-                                 gp_Pnt2d(LastParams.Value(afirstindex),
-                                          LastParams.Value(afirstindex + 1)));
-               jj++;
-               
-             }
-             while((nextd1.SquareMagnitude() < asqresol) &&
-                   (jj < aSeqOfNewPoint.Length()));
-             nextii = jj;
-             
-             if(fabs(d1.Angle(nextd1)) > piquota) {
-               bExtendLine = Standard_False;
-               break;
-             }
-             d1 = nextd1;
-           }
-         }
-         // end if(fabs(aTangentZoneDir.Angle(anIsoDir)
-       }
+        TColStd_Array1OfReal FirstParams(0, 3), LastParams(0, 3), Resolutions(0, 3);
+        Resolutions(0) = ResoU1; Resolutions(1) = ResoV1; Resolutions(2) = ResoU2; Resolutions(3) = ResoV2;
+
+        aSeqOfNewPoint(1).Parameters(FirstParams.ChangeValue(0), FirstParams.ChangeValue(1),
+          FirstParams.ChangeValue(2), FirstParams.ChangeValue(3));
+        aSeqOfNewPoint(aSeqOfNewPoint.Length()).Parameters(LastParams.ChangeValue(0), 
+          LastParams.ChangeValue(1),
+          LastParams.ChangeValue(2), 
+          LastParams.ChangeValue(3)); 
+        Standard_Integer indexofiso = 0;
+
+        if(theChoixIso == IntImp_UIsoparametricOnCaro1) indexofiso = 0;
+        if(theChoixIso == IntImp_VIsoparametricOnCaro1) indexofiso = 1;
+        if(theChoixIso == IntImp_UIsoparametricOnCaro2) indexofiso = 2;
+        if(theChoixIso == IntImp_VIsoparametricOnCaro2) indexofiso = 3;
+
+        Standard_Integer afirstindex = (indexofiso < 2) ? 0 : 2;
+        gp_Vec2d aTangentZoneDir(gp_Pnt2d(FirstParams.Value(afirstindex), FirstParams.Value(afirstindex + 1)),
+          gp_Pnt2d(LastParams.Value(afirstindex), LastParams.Value(afirstindex + 1)));
+
+        gp_Dir2d anIsoDir(0, 1);
+
+        if((indexofiso == 1) || (indexofiso == 3))
+          anIsoDir = gp_Dir2d(1, 0);
+
+        if(aTangentZoneDir.SquareMagnitude() > gp::Resolution()) {
+          Standard_Real piquota = M_PI*0.25;
+
+          if(fabs(aTangentZoneDir.Angle(anIsoDir)) > piquota) {
+            Standard_Integer ii = 1, nextii = 2;
+            gp_Vec2d d1(0, 0);
+            Standard_Real asqresol = gp::Resolution();
+            asqresol *= asqresol;
+
+            do {
+              aSeqOfNewPoint(ii).Parameters(FirstParams.ChangeValue(0), FirstParams.ChangeValue(1),
+                FirstParams.ChangeValue(2), FirstParams.ChangeValue(3));
+              aSeqOfNewPoint(ii + 1).Parameters(LastParams.ChangeValue(0), LastParams.ChangeValue(1),
+                LastParams.ChangeValue(2), LastParams.ChangeValue(3));
+              d1 = gp_Vec2d(gp_Pnt2d(FirstParams.Value(afirstindex),
+                FirstParams.Value(afirstindex + 1)),
+                gp_Pnt2d(LastParams.Value(afirstindex),
+                LastParams.Value(afirstindex + 1)));
+              ii++;
+            }
+            while((d1.SquareMagnitude() < asqresol) &&
+              (ii < aSeqOfNewPoint.Length()));
+
+            nextii = ii;
+
+            while(nextii < aSeqOfNewPoint.Length()) {
+
+              gp_Vec2d nextd1(0, 0);
+              Standard_Integer jj = nextii;
+
+              do {
+                aSeqOfNewPoint(jj).Parameters(FirstParams.ChangeValue(0), FirstParams.ChangeValue(1),
+                  FirstParams.ChangeValue(2), FirstParams.ChangeValue(3));
+                aSeqOfNewPoint(jj + 1).Parameters(LastParams.ChangeValue(0), LastParams.ChangeValue(1),
+                  LastParams.ChangeValue(2), LastParams.ChangeValue(3));
+                nextd1 = gp_Vec2d(gp_Pnt2d(FirstParams.Value(afirstindex),
+                  FirstParams.Value(afirstindex + 1)),
+                  gp_Pnt2d(LastParams.Value(afirstindex),
+                  LastParams.Value(afirstindex + 1)));
+                jj++;
+
+              }
+              while((nextd1.SquareMagnitude() < asqresol) &&
+                (jj < aSeqOfNewPoint.Length()));
+              nextii = jj;
+
+              if(fabs(d1.Angle(nextd1)) > piquota) {
+                bExtendLine = Standard_False;
+                break;
+              }
+              d1 = nextd1;
+            }
+          }
+          // end if(fabs(aTangentZoneDir.Angle(anIsoDir)
+        }
       }
     }
   }
@@ -1470,3 +1796,612 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop
 
   return bOutOfTangentZone;
 }
+
+//=======================================================================
+//function : DistanceMinimizeByGradient
+//purpose  : 
+//=======================================================================
+Standard_Boolean IntWalk_PWalking::
+  DistanceMinimizeByGradient( const Handle(Adaptor3d_HSurface)& theASurf1,
+                              const Handle(Adaptor3d_HSurface)& theASurf2,
+                              Standard_Real& theU1,
+                              Standard_Real& theV1,
+                              Standard_Real& theU2,
+                              Standard_Real& theV2,
+                              const Standard_Real theStep0U1V1,
+                              const Standard_Real theStep0U2V2)
+{
+  const Standard_Integer aNbIterMAX = 60;
+  const Standard_Real aTol = 1.0e-14;
+  Handle(Geom_Surface) aS1, aS2;
+
+  switch(theASurf1->GetType())
+  {
+  case GeomAbs_BezierSurface:
+    aS1 = theASurf1->Surface().Bezier();
+    break;
+  case GeomAbs_BSplineSurface:
+    aS1 = theASurf1->Surface().BSpline();
+    break;
+  default:
+    return Standard_True;
+  }
+
+  switch(theASurf2->GetType())
+  {
+  case GeomAbs_BezierSurface:
+    aS2 = theASurf2->Surface().Bezier();
+    break;
+  case GeomAbs_BSplineSurface:
+    aS2 = theASurf2->Surface().BSpline();
+    break;
+  default:
+    return Standard_True;
+  }
+
+  Standard_Boolean aStatus = Standard_False;
+
+  gp_Pnt aP1, aP2;
+  gp_Vec aD1u, aD1v, aD2U, aD2V;
+
+  aS1->D1(theU1, theV1, aP1, aD1u, aD1v);
+  aS2->D1(theU2, theV2, aP2, aD2U, aD2V);
+
+  Standard_Real aSQDistPrev = aP1.SquareDistance(aP2);
+
+  gp_Vec aP12(aP1, aP2);
+
+  Standard_Real aGradFu(-aP12.Dot(aD1u));
+  Standard_Real aGradFv(-aP12.Dot(aD1v));
+  Standard_Real aGradFU( aP12.Dot(aD2U));
+  Standard_Real aGradFV( aP12.Dot(aD2V));
+
+  Standard_Real aSTEPuv = theStep0U1V1, aStepUV = theStep0U2V2;
+
+  Standard_Boolean flRepeat = Standard_True;
+  Standard_Integer aNbIter = aNbIterMAX;
+
+  while(flRepeat)
+  {
+    Standard_Real anAdd = aGradFu*aSTEPuv;
+    Standard_Real aPARu = (anAdd >= 0.0)?
+            (theU1 - Max(anAdd, Epsilon(theU1))) :
+            (theU1 + Max(-anAdd, Epsilon(theU1)));
+    anAdd = aGradFv*aSTEPuv;
+    Standard_Real aPARv = (anAdd >= 0.0)?
+            (theV1 - Max(anAdd, Epsilon(theV1))) :
+            (theV1 + Max(-anAdd, Epsilon(theV1)));
+    anAdd = aGradFU*aStepUV;
+    Standard_Real aParU = (anAdd >= 0.0)?
+            (theU2 - Max(anAdd, Epsilon(theU2))) :
+            (theU2 + Max(-anAdd, Epsilon(theU2)));
+    anAdd = aGradFV*aStepUV;
+    Standard_Real aParV = (anAdd >= 0.0)?
+            (theV2 - Max(anAdd, Epsilon(theV2))) :
+            (theV2 + Max(-anAdd, Epsilon(theV2)));
+
+    gp_Pnt aPt1, aPt2;
+
+    aS1->D1(aPARu, aPARv, aPt1, aD1u, aD1v);
+    aS2->D1(aParU, aParV, aPt2, aD2U, aD2V);
+
+    Standard_Real aSQDist = aPt1.SquareDistance(aPt2);
+
+    if(aSQDist < aSQDistPrev)
+    {
+      aSQDistPrev = aSQDist;
+      theU1 = aPARu;
+      theV1 = aPARv;
+      theU2 = aParU;
+      theV2 = aParV;
+
+      aStatus = aSQDistPrev < aTol;
+      aSTEPuv *= 1.2;
+      aStepUV *= 1.2;
+    }
+    else
+    {
+      if(--aNbIter < 0)
+      {
+        flRepeat = Standard_False;
+      }
+      else
+      {
+        aS1->D1(theU1, theV1, aPt1, aD1u, aD1v);
+        aS2->D1(theU2, theV2, aPt2, aD2U, aD2V);
+
+        gp_Vec aP12(aPt1, aPt2);
+        aGradFu = -aP12.Dot(aD1u);
+        aGradFv = -aP12.Dot(aD1v);
+        aGradFU = aP12.Dot(aD2U);
+        aGradFV = aP12.Dot(aD2V);
+        aSTEPuv = theStep0U1V1;
+        aStepUV = theStep0U2V2;
+      }
+    }
+  }
+
+  return aStatus;
+}
+
+//=======================================================================
+//function : DistanceMinimizeByExtrema
+//purpose  : 
+//=======================================================================
+Standard_Boolean IntWalk_PWalking::
+  DistanceMinimizeByExtrema(const Handle(Adaptor3d_HSurface)& theASurf, 
+                            const gp_Pnt& theP0,
+                            Standard_Real& theU0,
+                            Standard_Real& theV0,
+                            const Standard_Real theStep0U,
+                            const Standard_Real theStep0V)
+{
+  const Standard_Real aTol = 1.0e-14;
+  gp_Pnt aPS;
+  gp_Vec aD1Su, aD1Sv, aD2Su, aD2Sv, aD2SuvTemp;
+  Standard_Real aSQDistPrev = RealLast();
+  Standard_Real aU = theU0, aV = theV0;
+  
+  Standard_Integer aNbIter = 10;
+  do
+  {
+    theASurf->D2(aU, aV, aPS, aD1Su, aD1Sv, aD2Su, aD2Sv, aD2SuvTemp);
+    
+    gp_Vec aVec(theP0, aPS);
+    
+    Standard_Real aSQDist = aVec.SquareMagnitude();
+
+    if(aSQDist >= aSQDistPrev)
+      break;
+
+    aSQDistPrev = aSQDist;
+    theU0 = aU;
+    theV0 = aV;
+    aNbIter--;
+
+    if(aSQDistPrev < aTol)
+      break;
+
+    //Functions
+    const Standard_Real aF1 = aD1Su.Dot(aVec), aF2 = aD1Sv.Dot(aVec);
+
+    //Derivatives
+    const Standard_Real aDf1u = aD2Su.Dot(aVec) + aD1Su.Dot(aD1Su),
+                        aDf1v = aD2Su.Dot(aD1Sv),
+                        aDf2u = aDf1v,
+                        aDf2v = aD2Sv.Dot(aVec) + aD1Sv.Dot(aD1Sv);
+
+    const Standard_Real aDet = aDf1u*aDf2v - aDf1v*aDf2u;
+    aU -= theStep0U*(aDf2v*aF1 - aDf1v*aF2)/aDet;
+    aV += theStep0V*(aDf2u*aF1 - aDf1u*aF2)/aDet;
+  }
+  while(aNbIter > 0);
+
+  return (aSQDistPrev < aTol);
+}
+
+//=======================================================================
+//function : SeekPointOnBoundary
+//purpose  : 
+//=======================================================================
+Standard_Boolean IntWalk_PWalking::
+  SeekPointOnBoundary(const Handle(Adaptor3d_HSurface)& theASurf1,
+                      const Handle(Adaptor3d_HSurface)& theASurf2,
+                      const Standard_Real theU1,
+                      const Standard_Real theV1,
+                      const Standard_Real theU2,
+                      const Standard_Real theV2,
+                      const Standard_Boolean isTheFirst)
+{
+  const Standard_Real aTol = 1.0e-14;
+  Standard_Boolean isOK = Standard_False;
+  Standard_Real U1prec = theU1, V1prec = theV1, U2prec = theU2, V2prec = theV2;
+
+  Standard_Boolean flFinish = Standard_False;
+
+  Standard_Integer aNbIter = 20;
+  while(!flFinish)
+  {
+    flFinish = Standard_False;
+    Standard_Boolean aStatus = Standard_False;
+
+    do
+    {
+      aNbIter--;
+      aStatus = DistanceMinimizeByGradient(theASurf1, theASurf2, U1prec, V1prec, U2prec, V2prec);
+      if(aStatus)
+      {
+        break;
+      }
+
+      aStatus = DistanceMinimizeByExtrema(theASurf1, theASurf2->Value(U2prec, V2prec), U1prec, V1prec);
+      if(aStatus)
+      {
+        break;
+      }
+
+      aStatus = DistanceMinimizeByExtrema(theASurf2, theASurf1->Value(U1prec, V1prec), U2prec, V2prec);
+      if(aStatus)
+      {
+        break;
+      }
+    }
+    while(!aStatus && (aNbIter > 0));
+
+    if(aStatus)
+    {
+      const Standard_Real aTolMax = 1.0e-8;
+      Standard_Real aTolF = 0.0;
+
+      Standard_Real u1 = U1prec, v1 = V1prec, u2 = U2prec, v2 = V2prec;
+
+      flFinish = Checking(theASurf1, theASurf2, U1prec, V1prec, U2prec, V2prec, aTolF);
+      
+      if(aTolF <= aTolMax)
+      {
+        gp_Pnt  aP1 = theASurf1->Value(u1, v1),
+                aP2 = theASurf2->Value(u2, v2);
+        gp_Pnt aPInt(0.5*(aP1.XYZ() + aP2.XYZ()));
+
+        const Standard_Real aSQDist1 = aPInt.SquareDistance(aP1),
+                            aSQDist2 = aPInt.SquareDistance(aP2);
+        if((aSQDist1 < aTol) && (aSQDist2 < aTol))
+        {
+          IntSurf_PntOn2S anIP;
+          anIP.SetValue(aPInt, u1, v1, u2, v2);
+          
+          if(isTheFirst)
+            line->InsertBefore(1,anIP);
+          else
+            line->Add(anIP);
+
+          isOK = Standard_True;
+        }
+      }
+    }
+    else
+    {
+      break;
+    }
+
+    if(aNbIter < 0)
+      break;
+  }
+
+  return isOK;
+}
+
+//=======================================================================
+//function : PutToBoundary
+//purpose  : 
+//=======================================================================
+Standard_Boolean IntWalk_PWalking::
+  PutToBoundary(const Handle(Adaptor3d_HSurface)& theASurf1,
+                const Handle(Adaptor3d_HSurface)& theASurf2)
+{
+  const Standard_Real aTolMin = Precision::Confusion();
+
+  Standard_Boolean hasBeenAdded = Standard_False;
+
+  const Standard_Real aU1bFirst = theASurf1->FirstUParameter();
+  const Standard_Real aU1bLast = theASurf1->LastUParameter();
+  const Standard_Real aU2bFirst = theASurf2->FirstUParameter();
+  const Standard_Real aU2bLast = theASurf2->LastUParameter();
+  const Standard_Real aV1bFirst = theASurf1->FirstVParameter();
+  const Standard_Real aV1bLast = theASurf1->LastVParameter();
+  const Standard_Real aV2bFirst = theASurf2->FirstVParameter();
+  const Standard_Real aV2bLast = theASurf2->LastVParameter();
+
+  Standard_Real aTol = 1.0;
+  aTol = Min(aTol, aU1bLast - aU1bFirst);
+  aTol = Min(aTol, aU2bLast - aU2bFirst);
+  aTol = Min(aTol, aV1bLast - aV1bFirst);
+  aTol = Min(aTol, aV2bLast - aV2bFirst)*1.0e-3;
+
+  if(aTol <= 2.0*aTolMin)
+    return hasBeenAdded;
+
+  Standard_Boolean isNeedAdding = Standard_False;
+  Standard_Boolean isU1parallel = Standard_False, isV1parallel = Standard_False;
+  Standard_Boolean isU2parallel = Standard_False, isV2parallel = Standard_False;
+  IsParallel(line, Standard_True, aTol, isU1parallel, isV1parallel);
+  IsParallel(line, Standard_False, aTol, isU2parallel, isV2parallel);
+
+  const Standard_Integer aNbPnts = line->NbPoints();
+  Standard_Real u1, v1, u2, v2;
+  line->Value(1).Parameters(u1, v1, u2, v2);
+  Standard_Real aDelta = 0.0;
+  
+  if(!isV1parallel)
+  {
+    aDelta = u1 - aU1bFirst;
+    if((aTolMin < aDelta) && (aDelta < aTol))
+    {
+      u1 = aU1bFirst - aDelta;
+      isNeedAdding = Standard_True;
+    }
+    else
+    {
+      aDelta = aU1bLast - u1;
+      if((aTolMin < aDelta) && (aDelta < aTol))
+      {
+        u1 = aU1bLast + aDelta;
+        isNeedAdding = Standard_True;
+      }
+    }
+  }
+
+  if(!isV2parallel)
+  {
+    aDelta = u2 - aU2bFirst;
+    if((aTolMin < aDelta) && (aDelta < aTol))
+    {
+      u2 = aU2bFirst - aDelta;
+      isNeedAdding = Standard_True;
+    }
+    else
+    {
+      aDelta = aU2bLast - u2;
+      if((aTolMin < aDelta) && (aDelta < aTol))
+      {
+        u2 = aU2bLast + aDelta;
+        isNeedAdding = Standard_True;
+      }
+    }
+  }
+
+  if(!isU1parallel)
+  {
+    aDelta = v1 - aV1bFirst;
+    if((aTolMin < aDelta) && (aDelta < aTol))
+    {
+      v1 = aV1bFirst - aDelta;
+      isNeedAdding = Standard_True;
+    }
+    else
+    {
+      aDelta = aV1bLast - v1;
+      if((aTolMin < aDelta) && (aDelta < aTol))
+      {
+        v1 = aV1bLast + aDelta;
+        isNeedAdding = Standard_True;
+      }
+    }
+  }
+
+  if(!isU2parallel)
+  {
+    aDelta = v2 - aV2bFirst;
+    if((aTolMin < aDelta) && (aDelta < aTol))
+    {
+      v2 = aV2bFirst - aDelta;
+      isNeedAdding = Standard_True;
+    }
+    else
+    {
+      aDelta = aV2bLast - v2;
+      if((aTolMin < aDelta) && (aDelta < aTol))
+      {
+        v2 = aV2bLast + aDelta;
+        isNeedAdding = Standard_True;
+      }
+    }
+  }
+
+  if(isNeedAdding)
+  {
+    hasBeenAdded = 
+      SeekPointOnBoundary(theASurf1, theASurf2, u1, 
+                            v1, u2, v2, Standard_True);
+  }
+
+  isNeedAdding = Standard_False;
+  line->Value(aNbPnts).Parameters(u1, v1, u2, v2);
+
+  if(!isV1parallel)
+  {
+    aDelta = u1 - aU1bFirst;
+    if((aTolMin < aDelta) && (aDelta < aTol))
+    {
+      u1 = aU1bFirst - aDelta;
+      isNeedAdding = Standard_True;
+    }
+    else
+    {
+      aDelta = aU1bLast - u1;
+      if((aTolMin < aDelta) && (aDelta < aTol))
+      {
+        u1 = aU1bLast + aDelta;
+        isNeedAdding = Standard_True;
+      }
+    }
+  }
+
+  if(!isV2parallel)
+  {
+    aDelta = u2 - aU2bFirst;
+    if((aTolMin < aDelta) && (aDelta < aTol))
+    {
+      u2 = aU2bFirst - aDelta;
+      isNeedAdding = Standard_True;
+    }
+    else
+    {
+      aDelta = aU2bLast - u2;
+      if((aTolMin < aDelta) && (aDelta < aTol))
+      {
+        u2 = aU2bLast + aDelta;
+        isNeedAdding = Standard_True;
+      }
+    }
+  }
+
+  if(!isU1parallel)
+  {
+    aDelta = v1 - aV1bFirst;
+    if((aTolMin < aDelta) && (aDelta < aTol))
+    {
+      v1 = aV1bFirst - aDelta;
+      isNeedAdding = Standard_True;
+    }
+    else
+    {
+      aDelta = aV1bLast - v1;
+      if((aTolMin < aDelta) && (aDelta < aTol))
+      {
+        v1 = aV1bLast + aDelta;
+        isNeedAdding = Standard_True;
+      }
+    }
+  }
+
+  if(!isU2parallel)
+  {
+    aDelta = v2 - aV2bFirst;
+    if((aTolMin < aDelta) && (aDelta < aTol))
+    {
+      v2 = aV2bFirst - aDelta;
+      isNeedAdding = Standard_True;
+    }
+    else
+    {
+      aDelta = aV2bLast - v2;
+      if((aTolMin < aDelta) && (aDelta < aTol))
+      {
+        v2 = aV2bLast + aDelta;
+        isNeedAdding = Standard_True;
+      }
+    }
+  }
+
+  if(isNeedAdding)
+  {
+    hasBeenAdded = 
+      SeekPointOnBoundary(theASurf1, theASurf2, u1, 
+                            v1, u2, v2, Standard_False);
+  }
+
+  return hasBeenAdded;
+}
+
+//=======================================================================
+//function : SeekAdditionalPoints
+//purpose  : 
+//=======================================================================
+Standard_Boolean IntWalk_PWalking::
+  SeekAdditionalPoints( const Handle(Adaptor3d_HSurface)& theASurf1,
+                        const Handle(Adaptor3d_HSurface)& theASurf2,
+                        const Standard_Integer theMinNbPoints)
+{
+  const Standard_Real aTol = 1.0e-14;
+  Standard_Integer aNbPoints = line->NbPoints();
+  if(aNbPoints > theMinNbPoints)
+    return Standard_True;
+
+  const Standard_Real aU1bFirst = theASurf1->FirstUParameter();
+  const Standard_Real aU1bLast = theASurf1->LastUParameter();
+  const Standard_Real aU2bFirst = theASurf2->FirstUParameter();
+  const Standard_Real aU2bLast = theASurf2->LastUParameter();
+  const Standard_Real aV1bFirst = theASurf1->FirstVParameter();
+  const Standard_Real aV1bLast = theASurf1->LastVParameter();
+  const Standard_Real aV2bFirst = theASurf2->FirstVParameter();
+  const Standard_Real aV2bLast = theASurf2->LastVParameter();
+
+  
+  Standard_Boolean isPrecise = Standard_False;
+
+  Standard_Real U1prec = 0.0, V1prec = 0.0, U2prec = 0.0, V2prec = 0.0;
+
+  Standard_Integer aNbPointsPrev = 0;
+  while(aNbPoints < theMinNbPoints && (aNbPoints != aNbPointsPrev))
+  {
+    aNbPointsPrev = aNbPoints;
+    for(Standard_Integer fp = 1, lp = 2; fp < aNbPoints; fp = lp + 1)
+    {
+      Standard_Real U1f, V1f, U2f, V2f; //first point in 1st and 2nd surafaces
+      Standard_Real U1l, V1l, U2l, V2l; //last  point in 1st and 2nd surafaces
+
+      lp = fp+1;
+      line->Value(fp).Parameters(U1f, V1f, U2f, V2f);
+      line->Value(lp).Parameters(U1l, V1l, U2l, V2l);
+
+      U1prec = 0.5*(U1f+U1l);
+      if(U1prec < aU1bFirst)
+        U1prec = aU1bFirst;
+      if(U1prec > aU1bLast)
+        U1prec = aU1bLast;
+
+      V1prec = 0.5*(V1f+V1l);
+      if(V1prec < aV1bFirst)
+        V1prec = aV1bFirst;
+      if(V1prec > aV1bLast)
+        V1prec = aV1bLast;
+
+      U2prec = 0.5*(U2f+U2l);
+      if(U2prec < aU2bFirst)
+        U2prec = aU2bFirst;
+      if(U2prec > aU2bLast)
+        U2prec = aU2bLast;
+
+      V2prec = 0.5*(V2f+V2l);
+      if(V2prec < aV2bFirst)
+        V2prec = aV2bFirst;
+      if(V2prec > aV2bLast)
+        V2prec = aV2bLast;
+
+      Standard_Boolean aStatus = Standard_False;
+      Standard_Integer aNbIter = 5;
+      do
+      {
+        aStatus = DistanceMinimizeByGradient(theASurf1, theASurf2, U1prec, V1prec, U2prec, V2prec);
+        if(aStatus)
+        {
+          break;
+        }
+
+        aStatus = DistanceMinimizeByExtrema(theASurf1, theASurf2->Value(U2prec, V2prec), U1prec, V1prec);
+        if(aStatus)
+        {
+          break;
+        }
+
+        aStatus = DistanceMinimizeByExtrema(theASurf2, theASurf1->Value(U1prec, V1prec), U2prec, V2prec);
+        if(aStatus)
+        {
+          break;
+        }
+      }
+      while(!aStatus && (--aNbIter > 0));
+
+      if(aStatus)
+      {
+        gp_Pnt  aP1 = theASurf1->Value(U1prec, V1prec),
+                aP2 = theASurf2->Value(U2prec, V2prec);
+        gp_Pnt aPInt(0.5*(aP1.XYZ() + aP2.XYZ()));
+
+        const Standard_Real aSQDist1 = aPInt.SquareDistance(aP1),
+                            aSQDist2 = aPInt.SquareDistance(aP2);
+
+        if((aSQDist1 < aTol) && (aSQDist2 < aTol))
+        {
+          IntSurf_PntOn2S anIP;
+          anIP.SetValue(aPInt, U1prec, V1prec, U2prec, V2prec);
+          line->InsertBefore(lp, anIP);
+          
+          isPrecise = Standard_True;
+
+          if(++aNbPoints >= theMinNbPoints)
+            break;
+        }
+        else
+        {
+          lp--;
+        }
+      }
+    }
+  }
+
+  return isPrecise;
+}
+
+
index a16d0735724669d8c02802a890091f705f21b018..db29631eb0b410d69a2e80ed9f383c0e74624b1b 100644 (file)
 #include <Geom_Circle.hxx>
 
 #include <LocOpe_PntFace.hxx>
-
+#include <GeomAdaptor_Curve.hxx>
 
 #include <Precision.hxx>
-
+#include <gp_Lin.hxx>
 
 static void Perform(BRepIntCurveSurface_Inter&,
                    LocOpe_SequenceOfPntFace&);
index b13a66c9af481edabeafe45af95606d60ed556a1..eb7900e2fdcc0f2f6305f766fde998ce2c4aeb17 100644 (file)
@@ -660,11 +660,12 @@ void LocOpe_SplitShape::AddClosedWire(const TopoDS_Wire& W,
 void LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W,
                                     const TopoDS_Face& F)
 {
+  
   // On cherche la face descendante de F qui continent le wire
   TopTools_ListOfShape& lf = myMap(F);
   TopTools_ListIteratorOfListOfShape itl(lf);
   TopoDS_Vertex Vfirst,Vlast;
-
   BRepTools::Update(F);
 
   Standard_Real tolf, toll, tol1;
@@ -680,7 +681,9 @@ void LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W,
   TopExp_Explorer exp,exp2;  
 
   TopoDS_Wire wfirst,wlast;
   for (; itl.More(); itl.Next()) {
+    
     TopoDS_Face fac = TopoDS::Face(itl.Value());
     if (!IsInside(fac,W)) {
       continue;
@@ -893,9 +896,12 @@ void LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W,
       else if (nbPoss > 1) {
         // Faire choix en U,V...
         TopoDS_Shape aLocalFace  = FaceRef.Oriented(wfirst.Orientation());
-        
         ChoixUV(LastEdge, TopoDS::Face(aLocalFace), PossE,
                 itm, plast, dlast, toll);
+        /*if(!ChoixUV(LastEdge, TopoDS::Face(aLocalFace), PossE,
+                itm, plast, dlast, toll))
+                return;*/
+
       }
 
       if (nbPoss >= 1) {
@@ -961,9 +967,9 @@ void LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W,
     newW2.Oriented(orfila);
     
     B.Add(newF1,newW1);
-    BRepTools::Write(newF1, "k:/queries/WrongBOP/NewF1.brep");
+    //BRepTools::Write(newF1, "NewF1.brep");
     B.Add(newF2,newW2);
-    BRepTools::Write(newF2, "k:/queries/WrongBOP/NewF2.brep");
+    //BRepTools::Write(newF2, "NewF2.brep");
     
     for (exp.ReInit(); exp.More(); exp.Next()) {
       const TopoDS_Wire& wir = TopoDS::Wire(exp.Current());
@@ -1363,7 +1369,7 @@ static Standard_Boolean IsInside(const TopoDS_Face& F,
 //purpose  : 
 //=======================================================================
 
-static void ChoixUV(const TopoDS_Edge& Last,
+void ChoixUV(const TopoDS_Edge& Last,
                     const TopoDS_Face& F,
                     const TopTools_MapOfShape& Poss,
                     TopTools_MapIteratorOfMapOfShape& It,
@@ -1436,6 +1442,7 @@ static void ChoixUV(const TopoDS_Edge& Last,
     //if ((dist < dmin - tol) ||
     //(dist <= dmin+tol && ang > angmax)) {
     if ((dist < tol)  && (ang > angmax)) {
+    //if (ang > angmax) {
       imin = index;
       //      dmin = dist;
       angmax = ang;
@@ -1469,7 +1476,7 @@ static void ChoixUV(const TopoDS_Edge& Last,
     }
     index++;
   }
-
+  //return (imin);
 }
 
 //=======================================================================
index 5ce9e5c38fcf39d3b64290c2e50eb4285b835176..ae7dd00d8bb2b047446366755e8699bdaefa9c49 100644 (file)
@@ -1078,11 +1078,11 @@ void FindInternalIntersections(const TopoDS_Edge& theEdge,
   
   TopoDS_Vertex theVertices [2];
   TopExp::Vertices(theEdge, theVertices[0], theVertices[1]);
-  if (theEdge.Orientation() == TopAbs_REVERSED)
+  /*if (theEdge.Orientation() == TopAbs_REVERSED)
   {
     theVertices[0].Reverse();
     theVertices[1].Reverse();
-  }
+  }*/
   gp_Pnt thePnt [2];
   thePnt[0] = BRep_Tool::Pnt(theVertices[0]);
   thePnt[1] = BRep_Tool::Pnt(theVertices[1]);
@@ -1217,11 +1217,13 @@ void FindInternalIntersections(const TopoDS_Edge& theEdge,
     LastVertex.Orientation(TopAbs_REVERSED);
     
     TopoDS_Shape aLocalShape = theEdge.EmptyCopied();
+    TopAbs_Orientation anOrient = aLocalShape.Orientation();
+    aLocalShape.Orientation(TopAbs_FORWARD);
     TopoDS_Edge NewEdge = TopoDS::Edge(aLocalShape);
     BB.Range(NewEdge, FirstPar, LastPar);
     BB.Add(NewEdge, FirstVertex);
     BB.Add(NewEdge, LastVertex);
-
+    NewEdge.Orientation(anOrient);
     NewEdges.Append(NewEdge);
     FirstVertex = LastVertex;
     FirstPar = LastPar;
index 58f83d20270ca566f2b6c133e3dfdc4534fe868e..9027e4d9b1bec16d72dad1aa0a5135daa1d305e7 100644 (file)
@@ -1,10 +1,10 @@
 // Created by: Kirill GAVRILOV
-// Copyright (c) 2014 OPEN CASCADE SAS
+// Copyright (c) 2013-2014 OPEN CASCADE SAS
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -79,7 +79,7 @@ public:
   Element_t y() const { return v[1]; }
 
   //! @return 2 components by their names in specified order (in GLSL-style)
-  NCOLLECTION_VEC_COMPONENTS_2D(x, y);
+  NCOLLECTION_VEC_COMPONENTS_2D(x, y)
 
   //! Alias to 1st component as X coordinate in XY.
   Element_t& x() { return v[0]; }
@@ -161,6 +161,20 @@ public:
                              v[1] * theFactor);
   }
 
+  //! Compute component-wise minimum of two vectors.
+  NCollection_Vec2 cwiseMin (const NCollection_Vec2& theVec) const
+  {
+    return NCollection_Vec2 (v[0] < theVec.v[0] ? v[0] : theVec.v[0],
+                             v[1] < theVec.v[1] ? v[1] : theVec.v[1]);
+  }
+
+  //! Compute component-wise maximum of two vectors.
+  NCollection_Vec2 cwiseMax (const NCollection_Vec2& theVec) const
+  {
+    return NCollection_Vec2 (v[0] > theVec.v[0] ? v[0] : theVec.v[0],
+                             v[1] > theVec.v[1] ? v[1] : theVec.v[1]);
+  }
+
   //! Compute per-component multiplication by scale factor.
   NCollection_Vec2& operator*= (const Element_t theFactor)
   {
index 311fd6c1283e50d1137d648ffdca0ed12ad2f486..35cb9e2538f828c44612578d6b2ca41394f17547 100644 (file)
@@ -1,10 +1,10 @@
 // Created by: Kirill GAVRILOV
-// Copyright (c) 2014 OPEN CASCADE SAS
+// Copyright (c) 2013-2014 OPEN CASCADE SAS
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -105,12 +105,12 @@ public:
   Element_t b() const { return v[2]; }
 
   //! @return 2 components by their names in specified order (in GLSL-style)
-  NCOLLECTION_VEC_COMPONENTS_2D(x, y);
-  NCOLLECTION_VEC_COMPONENTS_2D(x, z);
-  NCOLLECTION_VEC_COMPONENTS_2D(y, z);
+  NCOLLECTION_VEC_COMPONENTS_2D(x, y)
+  NCOLLECTION_VEC_COMPONENTS_2D(x, z)
+  NCOLLECTION_VEC_COMPONENTS_2D(y, z)
 
   //! @return 3 components by their names in specified order (in GLSL-style)
-  NCOLLECTION_VEC_COMPONENTS_3D(x, y, z);
+  NCOLLECTION_VEC_COMPONENTS_3D(x, y, z)
 
   //! Alias to 1st component as X coordinate in XYZ.
   Element_t& x() { return v[0]; }
@@ -234,6 +234,22 @@ public:
     return aCopyVec3;
   }
 
+  //! Compute component-wise minimum of two vectors.
+  NCollection_Vec3 cwiseMin (const NCollection_Vec3& theVec) const
+  {
+    return NCollection_Vec3 (v[0] < theVec.v[0] ? v[0] : theVec.v[0],
+                             v[1] < theVec.v[1] ? v[1] : theVec.v[1],
+                             v[2] < theVec.v[2] ? v[2] : theVec.v[2]);
+  }
+
+  //! Compute component-wise maximum of two vectors.
+  NCollection_Vec3 cwiseMax (const NCollection_Vec3& theVec) const
+  {
+    return NCollection_Vec3 (v[0] > theVec.v[0] ? v[0] : theVec.v[0],
+                             v[1] > theVec.v[1] ? v[1] : theVec.v[1],
+                             v[2] > theVec.v[2] ? v[2] : theVec.v[2]);
+  }
+
   //! Compute per-component division by scale factor.
   NCollection_Vec3& operator/= (const Element_t theInvFactor)
   {
index 2042a0dd8b0eda34d6696e1135d31a58eff28093..45aa2b013abf5b793331ee3ee0541adc2fa4f59e 100644 (file)
@@ -1,10 +1,10 @@
 // Created by: Kirill GAVRILOV
-// Copyright (c) 2014 OPEN CASCADE SAS
+// Copyright (c) 2013-2014 OPEN CASCADE SAS
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -29,7 +29,7 @@ class NCollection_Vec4
 public:
 
   //! Returns the number of components.
-  static size_t Length()
+  static int Length()
   {
     return 4;
   }
@@ -118,21 +118,21 @@ public:
   Element_t a() const { return v[3]; }
 
   //! @return 2 of XYZW components in specified order as vector in GLSL-style
-  NCOLLECTION_VEC_COMPONENTS_2D(x, y);
-  NCOLLECTION_VEC_COMPONENTS_2D(x, z);
-  NCOLLECTION_VEC_COMPONENTS_2D(x, w);
-  NCOLLECTION_VEC_COMPONENTS_2D(y, z);
-  NCOLLECTION_VEC_COMPONENTS_2D(y, w);
-  NCOLLECTION_VEC_COMPONENTS_2D(z, w);
+  NCOLLECTION_VEC_COMPONENTS_2D(x, y)
+  NCOLLECTION_VEC_COMPONENTS_2D(x, z)
+  NCOLLECTION_VEC_COMPONENTS_2D(x, w)
+  NCOLLECTION_VEC_COMPONENTS_2D(y, z)
+  NCOLLECTION_VEC_COMPONENTS_2D(y, w)
+  NCOLLECTION_VEC_COMPONENTS_2D(z, w)
 
   //! @return 3 of XYZW components in specified order as vector in GLSL-style
-  NCOLLECTION_VEC_COMPONENTS_3D(x, y, z);
-  NCOLLECTION_VEC_COMPONENTS_3D(x, y, w);
-  NCOLLECTION_VEC_COMPONENTS_3D(x, z, w);
-  NCOLLECTION_VEC_COMPONENTS_3D(y, z, w);
+  NCOLLECTION_VEC_COMPONENTS_3D(x, y, z)
+  NCOLLECTION_VEC_COMPONENTS_3D(x, y, w)
+  NCOLLECTION_VEC_COMPONENTS_3D(x, z, w)
+  NCOLLECTION_VEC_COMPONENTS_3D(y, z, w)
 
   //! @return RGB components as vector
-  NCOLLECTION_VEC_COMPONENTS_3D(r, g, b);
+  NCOLLECTION_VEC_COMPONENTS_3D(r, g, b)
 
   //! Alias to 1st component as X coordinate in XYZW.
   Element_t& x() { return v[0]; }
@@ -284,6 +284,24 @@ public:
     return aCopyVec4;
   }
 
+  //! Compute component-wise minimum of two vectors.
+  NCollection_Vec4 cwiseMin (const NCollection_Vec4& theVec) const
+  {
+    return NCollection_Vec4 (v[0] < theVec.v[0] ? v[0] : theVec.v[0],
+                             v[1] < theVec.v[1] ? v[1] : theVec.v[1],
+                             v[2] < theVec.v[2] ? v[2] : theVec.v[2],
+                             v[3] < theVec.v[3] ? v[3] : theVec.v[3]);
+  }
+
+  //! Compute component-wise maximum of two vectors.
+  NCollection_Vec4 cwiseMax (const NCollection_Vec4& theVec) const
+  {
+    return NCollection_Vec4 (v[0] > theVec.v[0] ? v[0] : theVec.v[0],
+                             v[1] > theVec.v[1] ? v[1] : theVec.v[1],
+                             v[2] > theVec.v[2] ? v[2] : theVec.v[2],
+                             v[3] > theVec.v[3] ? v[3] : theVec.v[3]);
+  }
+
   //! Compute per-component division by scale factor.
   NCollection_Vec4& operator/= (const Element_t theInvFactor)
   {
@@ -297,7 +315,7 @@ public:
   //! Compute per-component division by scale factor.
   NCollection_Vec4 operator/ (const Element_t theInvFactor)
   {
-    NCollection_Vec4 aResult(this);
+    NCollection_Vec4 aResult(*this);
     return aResult /= theInvFactor;
   }
 
index c3c155338f370787a09805298e4d76da7e023aa1..cf309d0172078743fe8bdebca45cb2d494e4f3f1 100644 (file)
@@ -511,6 +511,7 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
          Projector.Bounds(1,Udeb,Ufin);
        }
        else {
+    
          StdFail_NotDone::Raise("ProjLib CompProjectedCurve Not Done");
        }
        // Approximons cette courbe algorithmique.
index 5ff99e31030e8316bc7926a6b1cc11583b1e3596..da0218ce77778d184507ea9c943ed52806c56987 100644 (file)
@@ -263,6 +263,8 @@ TopoDS_Vertex ShapeAnalysis_Edge::FirstVertex (const TopoDS_Edge& edge) const
   else {
     V = TopExp::FirstVertex (edge);
   }
+  if( V.IsNull())
+    return V;
   return V;
 }
 
@@ -282,6 +284,8 @@ TopoDS_Vertex ShapeAnalysis_Edge::LastVertex (const TopoDS_Edge& edge) const
   else {
     V = TopExp::LastVertex (edge);
   }
+  if( V.IsNull())
+    return V;
   return V;
 }
 
index 55c81c16fcc689e0b7afa8efc093900aa28bbdcb..932b253fb3e5e8476b2b92c9c54447f9cf382359 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -149,9 +149,11 @@ ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape,
   
   Standard_Integer i; // svv #1
   for (i = 1; i <= edges->Length(); i++) {
+    const TopoDS_Shape& aEdge = edges->Value (i);
+  
     TopoDS_Wire wire;
     B.MakeWire (wire);
-    B.Add (wire, edges->Value (i));
+    B.Add (wire, aEdge);
     iwires->Append (wire);
   }
 
@@ -199,6 +201,15 @@ ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape,
   Handle(ShapeExtend_WireData)
     sewd = new ShapeExtend_WireData (TopoDS::Wire (arrwires->Value (1)));
 
+  Standard_Boolean isUsedManifoldMode = Standard_True;
+
+  if((sewd->NbEdges() < 1) && (sewd->NbNonManifoldEdges() > 0))
+  {
+    isUsedManifoldMode = Standard_False;
+    sewd = new ShapeExtend_WireData (TopoDS::Wire (arrwires->Value (1)), Standard_True,
+                                     isUsedManifoldMode);
+  }
+
   Handle(ShapeAnalysis_Wire) saw = new ShapeAnalysis_Wire;
   saw->Load (sewd);
   saw->SetPrecision (tolerance);
@@ -220,14 +231,16 @@ ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape,
     aBox.SetGap(tolerance);
     aTreeFiller.Add(inbW, aBox);
   }
-  Standard_Integer nbFill;
-  nbFill = aTreeFiller.Fill();
+
+  aTreeFiller.Fill();
   Standard_Integer nsel;
   
   ShapeAnalysis_Edge sae; //szv#4:S4163:12Mar99 moved
   Standard_Boolean done = Standard_False;
+
   
-  while (!done) {
+  while (!done)
+  {
     Standard_Boolean found = Standard_False, tail = Standard_False, direct = Standard_False;
     Standard_Integer lwire=0;
     aSel.SetStop();
@@ -235,6 +248,7 @@ ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape,
     TopoDS_Vertex Vf, Vl;
     Vf = sae.FirstVertex(sewd->Edge(1));
     Vl = sae.LastVertex(sewd->Edge(sewd->NbEdges()));
+
     gp_Pnt pf, pl;
     pf = BRep_Tool::Pnt(Vf);
     pl = BRep_Tool::Pnt(Vl);
@@ -247,14 +261,16 @@ ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape,
     
     if (shared)
       aSel.DefineVertexes(Vf,Vl);
-    else{
+    else
+    {
       aSel.DefinePnt(pf,pl);
       aSel.SetTolerance(tolerance);
     }
     
     nsel = aBBTree.Select(aSel);
     
-    if (nsel != 0 && !aSel.LastCheckStatus(ShapeExtend_FAIL)) {
+    if (nsel != 0 && !aSel.LastCheckStatus(ShapeExtend_FAIL))
+    {
       found = Standard_True;
       lwire = aSel.GetNb();
       tail    = aSel.LastCheckStatus (ShapeExtend_DONE1) ||
@@ -264,71 +280,122 @@ ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape,
       aSel.LoadList(lwire);
     }
     
-    if (found) {
-      if (!direct) arrwires->ChangeValue(lwire).Reverse();
+    if (found)
+    {
+      if (!direct)
+        arrwires->ChangeValue(lwire).Reverse();
+
       TopoDS_Wire aCurW = TopoDS::Wire (arrwires->Value (lwire));
-      Handle(ShapeExtend_WireData) acurwd = 
-       new ShapeExtend_WireData ( TopoDS::Wire (arrwires->Value (lwire)));
+      Handle(ShapeExtend_WireData) acurwd = new 
+        ShapeExtend_WireData ( TopoDS::Wire (arrwires->Value (lwire)), Standard_True, isUsedManifoldMode);
+      if( !acurwd->NbEdges())
+        continue;
       sewd->Add (acurwd, (tail ? 0 : 1));
     }
-    else {
+    else
+    {
       //making wire
       //1.providing connection (see ShapeFix_Wire::FixConnected())
       //Standard_Integer i; // svv #1
-      for (/*Standard_Integer*/ i = 1; i <= saw->NbEdges(); i++) {
-       if (saw->CheckConnected (i)) {
-         Standard_Integer n2 = i;
-         Standard_Integer n1 = (n2 > 1 ? n2 - 1 : saw->NbEdges());
-         TopoDS_Edge E1 = sewd->Edge(n1);
-         TopoDS_Edge E2 = sewd->Edge(n2);
-  
-         TopoDS_Vertex Vprev, Vfol, V; //connection vertex
-         Vprev = sae.LastVertex (E1);
-         Vfol = sae.FirstVertex (E2);
-
-         if (saw->LastCheckStatus (ShapeExtend_DONE1)) //absolutely confused
-           V = Vprev;
-         else {
-           ShapeBuild_Vertex sbv; 
-           V = sbv.CombineVertex (Vprev, Vfol);
-         }
-         vertices.Bind (Vprev, V);
-         vertices.Bind (Vfol, V);
-
-         //replace vertices to a new one
-         ShapeBuild_Edge sbe;
-         if (saw->NbEdges() < 2)
-           sewd->Set (sbe.CopyReplaceVertices (E2, V, V), n2);
-         else {
-           sewd->Set (sbe.CopyReplaceVertices (E2, V, TopoDS_Vertex()), n2);
-           if (!saw->LastCheckStatus (ShapeExtend_DONE1))
-             sewd->Set (sbe.CopyReplaceVertices (E1, TopoDS_Vertex(), V), n1);
-         }
-       }
+      for (/*Standard_Integer*/ i = 1; i <= saw->NbEdges(); i++)
+      {
+        if (saw->CheckConnected (i))
+        {
+          Standard_Integer n2 = i;
+          Standard_Integer n1 = (n2 > 1 ? n2 - 1 : saw->NbEdges());
+          TopoDS_Edge E1 = sewd->Edge(n1);
+          TopoDS_Edge E2 = sewd->Edge(n2);
+
+          TopoDS_Vertex Vprev, Vfol, V; //connection vertex
+          Vprev = sae.LastVertex (E1);
+          Vfol = sae.FirstVertex (E2);
+
+          if (saw->LastCheckStatus (ShapeExtend_DONE1)) //absolutely confused
+            V = Vprev;
+          else {
+            ShapeBuild_Vertex sbv; 
+            V = sbv.CombineVertex (Vprev, Vfol);
+          }
+          vertices.Bind (Vprev, V);
+          vertices.Bind (Vfol, V);
+
+          //replace vertices to a new one
+          ShapeBuild_Edge sbe;
+          if (saw->NbEdges() < 2)
+            sewd->Set (sbe.CopyReplaceVertices (E2, V, V), n2);
+          else {
+            sewd->Set (sbe.CopyReplaceVertices (E2, V, TopoDS_Vertex()), n2);
+            if (!saw->LastCheckStatus (ShapeExtend_DONE1))
+              sewd->Set (sbe.CopyReplaceVertices (E1, TopoDS_Vertex(), V), n1);
+          }
+        }
       }
 
       //2.making wire
       TopoDS_Wire wire = sewd->Wire();
-      if (!saw->CheckConnected (1) && saw->LastCheckStatus (ShapeExtend_OK))
-        wire.Closed (Standard_True);
+      if(isUsedManifoldMode)
+      {
+        if (!saw->CheckConnected (1) && saw->LastCheckStatus (ShapeExtend_OK))
+          wire.Closed (Standard_True);
+      }
+      else
+      {
+        //Try to check connection by number of free vertices
+        TopTools_MapOfShape vmap;
+        TopoDS_Iterator it(wire);
+
+        for(; it.More(); it.Next())
+        {
+          const TopoDS_Shape& E = it.Value();
+          TopoDS_Iterator ite(E, Standard_False, Standard_True);
+          for(; ite.More(); ite.Next())
+          {
+            const TopoDS_Shape& V = ite.Value();
+            if (V.Orientation() == TopAbs_FORWARD ||
+                V.Orientation() == TopAbs_REVERSED)
+            {
+              // add or remove in the vertex map
+              if (!vmap.Add(V)) vmap.Remove(V);
+            }
+          }
+
+        }
+        if(vmap.IsEmpty())
+        {
+          wire.Closed(Standard_True);
+        }
+      }
+
       owires->Append (wire);
       sewd->Clear();
+      sewd->ManifoldMode() = isUsedManifoldMode;
         
       // Recherche de la premier edge non traitee pour un autre wire.
       //Searching for first edge for next wire
       lwire = -1;
-      for (/*Standard_Integer*/ i = 1 ; i <= arrwires->Length() && lwire == -1; i++)
-       if (!aSel.ContWire(i)) lwire = i; //szv#4:S4163:12Mar99 optimized
-
-      if (lwire == -1) done = 1;
-      else {
-       sewd->Add (TopoDS::Wire (arrwires->Value (lwire)));
-        aSel.LoadList(lwire);
+      for (/*Standard_Integer*/ i = 1 ; i <= arrwires->Length(); i++)
+      {
+        if (!aSel.ContWire(i))
+        {
+          lwire = i; //szv#4:S4163:12Mar99 optimized
+          sewd->Add (TopoDS::Wire (arrwires->Value (lwire)));
+          aSel.LoadList(lwire);
+
+          if (sewd->NbEdges() > 0)
+            break;
+          sewd->Clear();
+        }
       }
+
+      if (lwire == -1)
+        done = 1;
     }
   }
+
   for ( /*Standard_Integer*/ i = 1; i <= iwires->Length(); i++)
+  {
     iwires->SetValue (i, arrwires->Value(i));
+  }
 }
 
 static void SplitWire(const TopoDS_Wire& wire,
@@ -363,7 +430,6 @@ static void SplitWire(const TopoDS_Wire& wire,
       Standard_Boolean SearchBackward = Standard_True;
 
       for(;;) {
-       Standard_Integer ei = ces.Last(); //ei-edge index, number of current edge analyzed for connection
        Standard_Boolean found;
        TopoDS_Edge edge;
        TopoDS_Vertex lvertex;
@@ -403,7 +469,6 @@ static void SplitWire(const TopoDS_Wire& wire,
     
        //searching for connection among free edges
        found = Standard_False;
-       ei = ces.Last();
        edge = sewd->Edge (ces.Last());
        lvertex = sae.LastVertex (edge);
        lpoint = BRep_Tool::Pnt (lvertex);