1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Compare commits

...

9 Commits

Author SHA1 Message Date
msv
6033b13c29 Make it compilable 2015-02-04 13:10:56 +03:00
gka
ec738c8ff1 New classes for BOPAlgo for patch on boolean operations from OCC version 680 2015-02-03 19:12:57 +03:00
gka
fe7caef6da Fix for regressions for case infinite box ( case 46)
Test cases
2015-02-02 17:03:59 +03:00
gka
097a0cae0f Fix to avoid exception for case46 (regressions) 2014-10-28 19:51:23 +03:00
gka
3054ab58fb Fix for case 52 2014-10-28 12:43:36 +03:00
ifv
75ee56f2df Analyzer for surface normals is added 2014-10-24 12:12:27 +04:00
aml
95ee0712bc 0025380: Intersection curve cannot reach boundary of surface
Changed next point computation in point walker. Now trying to walk over another isoline if new point is too close to previous.
2014-10-23 15:43:31 +04:00
gka
a5a0a4399f Fix for operation "Split shell" 2014-10-21 15:13:54 +04:00
gka
d099845895 Version Open CASCADE 670 with fixes 2014-10-10 15:48:10 +04:00
81 changed files with 8441 additions and 5911 deletions

View File

@@ -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.

View 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

View 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;
}

View File

@@ -74,6 +74,7 @@ is
class CheckerSI;
class ArgumentAnalyzer;
class CheckResult;
class ShellSplitter;
--
-- pointers
--

View File

@@ -57,6 +57,8 @@
#include <BOPCol_DataMapOfShapeShape.hxx>
#include <BOPCol_DataMapOfShapeListOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BRepBndLib.hxx>
#include <Bnd_Box.hxx>
static
@@ -444,6 +446,7 @@ TopAbs_Orientation BOPAlgo_BuilderFace::Orientation()const
}
//
// 2. Find outer growth shell that is most close to each hole shell
BOPCol_ListOfShape anUnUsedHoles;
aIt2.Initialize(aHoleWires);
for (; aIt2.More(); aIt2.Next()) {
const TopoDS_Shape& aHole = aIt2.Value();
@@ -481,8 +484,26 @@ TopAbs_Orientation BOPAlgo_BuilderFace::Orientation()const
aMSH.Bind(aF, aLH);
}
}
else {
anUnUsedHoles.Append(aHole);
}
}// for (; aIt2.More(); aIt2.Next())
//
if (anUnUsedHoles.Extent()) {
// add the infinite face to new faces
Bnd_Box aBox;
BRepBndLib::Add(myFace, aBox);
if (aBox.IsOpenXmin() || aBox.IsOpenXmax() ||
aBox.IsOpenYmin() || aBox.IsOpenYmax() ||
aBox.IsOpenZmin() || aBox.IsOpenZmax()) {
TopoDS_Face aFace;
aBB.MakeFace(aFace, aS, aLoc, aTol);
//
aNewFaces.Append(aFace);
aMSH.Bind(aFace, anUnUsedHoles);
}
}
//
// 3. Add aHoles to Faces
aItMSH.Initialize(aMSH);
for (; aItMSH.More(); aItMSH.Next()) {

File diff suppressed because it is too large Load Diff

View File

@@ -64,6 +64,9 @@
#include <BOPCol_ListOfInteger.hxx>
#include <BOPInt_Context.hxx>
#include <TCollection_CompareOfInteger.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <SortTools_QuickSortOfInteger.hxx>
static
Standard_Boolean IsClosedShell(const TopoDS_Shell& aSh);
@@ -284,7 +287,7 @@ void BOPAlgo_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts
const BOPAlgo_ShapeBox& aSBk=aItDMISB.Value();
const TopoDS_Shape& aFk=aSBk.Shape();
if (aMF.Contains(aFk)) {
continue;
continue;
}
//
const Bnd_Box& aBk=aSBk.Box();
@@ -300,67 +303,76 @@ void BOPAlgo_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts
aSelector.SetBox(aBoxS);
//
aNbFP=aBBTree.Select(aSelector);
//
const BOPCol_ListOfInteger& aLIFP=aSelector.Indices();
//
// 2.7. Collect faces that are IN aSolid [ aLFIN ]
BOPCol_ListOfShape aLFP(aAlr1);
BOPCol_ListOfShape aLCBF(aAlr1);
BOPCol_MapOfShape aMFDone(100, aAlr1);
BOPCol_IndexedMapOfShape aME(100, aAlr1);
//
BOPTools::MapShapes(aSD, TopAbs_EDGE, aME);
//
aItLI.Initialize(aLIFP);
for (; aItLI.More(); aItLI.Next()) {
nFP=aItLI.Value();
const BOPAlgo_ShapeBox& aSBF=aDMISB.Find(nFP);
const TopoDS_Face& aFP=(*(TopoDS_Face*)&aSBF.Shape());
if (aMFDone.Contains(aFP)) {
continue;
if (aNbFP) {
const BOPCol_ListOfInteger& aLIFP=aSelector.Indices();
//sort indices
TColStd_Array1OfInteger anArray(1, aNbFP);
aItLI.Initialize(aLIFP);
for (k = 1; aItLI.More(); aItLI.Next(), ++k) {
nFP=aItLI.Value();
anArray(k) = nFP;
}
TCollection_CompareOfInteger comp;
SortTools_QuickSortOfInteger::Sort(anArray,comp);
//
aMFDone.Add(aFP);
// 2.7. Collect faces that are IN aSolid [ aLFIN ]
BOPCol_ListOfShape aLFP(aAlr1);
BOPCol_ListOfShape aLCBF(aAlr1);
BOPCol_MapOfShape aMFDone(100, aAlr1);
BOPCol_IndexedMapOfShape aME(100, aAlr1);
//
iIsIN=BOPTools_AlgoTools::IsInternalFace(aFP, aSD, aMEF, 1.e-14, myContext);
BOPTools::MapShapes(aSD, TopAbs_EDGE, aME);
//
aLFP.Clear();
aLFP.Append(aFP);
//
aItLI1.Initialize(aLIFP);
for (; aItLI1.More(); aItLI1.Next()) {
const TopoDS_Shape& aFx=aDMISB.Find(aItLI1.Value()).Shape();
if (!aMFDone.Contains(aFx)) {
aLFP.Append(aFx);
}
}
//
aLCBF.Clear();
//----------------------------------------
{
Handle(NCollection_IncAllocator) aAlr2;
aAlr2=new NCollection_IncAllocator();
//
BOPTools_AlgoTools::MakeConnexityBlock(aLFP, aME, aLCBF, aAlr2);
}
//----------------------------------------
aItLS.Initialize(aLCBF);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aFx=aItLS.Value();
aMFDone.Add(aFx);
if (iIsIN) {
aLFIN.Append(aFx);
for (k = 1; k <= aNbFP; ++k) {
nFP = anArray(k);
const BOPAlgo_ShapeBox& aSBF=aDMISB.Find(nFP);
const TopoDS_Face& aFP=(*(TopoDS_Face*)&aSBF.Shape());
if (aMFDone.Contains(aFP)) {
continue;
}
}
}// for (; aItLI.More(); aItLI.Next()) {
//
//
aMFDone.Add(aFP);
//
iIsIN=BOPTools_AlgoTools::IsInternalFace(aFP, aSD, aMEF, 1.e-14, myContext);
//
aLFP.Clear();
aLFP.Append(aFP);
//
aItLI1.Initialize(aLIFP);
for (; aItLI1.More(); aItLI1.Next()) {
const TopoDS_Shape& aFx=aDMISB.Find(aItLI1.Value()).Shape();
if (!aMFDone.Contains(aFx)) {
aLFP.Append(aFx);
}
}
//
aLCBF.Clear();
//----------------------------------------
{
Handle(NCollection_IncAllocator) aAlr2;
aAlr2=new NCollection_IncAllocator();
//
BOPTools_AlgoTools::MakeConnexityBlock(aLFP, aME, aLCBF, aAlr2);
}
//----------------------------------------
aItLS.Initialize(aLCBF);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aFx=aItLS.Value();
aMFDone.Add(aFx);
if (iIsIN) {
aLFIN.Append(aFx);
}
}
}// for (; aItLI.More(); aItLI.Next()) {
//
}
// 2.8. Store the results in theInParts, theDraftSolids
aNbFIN=aLFIN.Extent();
if (aNbFIN || aNbLIF) {
aItLS.Initialize(aLIF);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aFI=aItLS.Value();
aLFIN.Append(aFI);
const TopoDS_Shape& aFI=aItLS.Value();
aLFIN.Append(aFI);
}
theInParts.Bind(aSolid, aLFIN);
}

View File

@@ -183,6 +183,7 @@
return;
}
// 12
PerformEF();
if (myErrorStatus) {
return;

View File

@@ -0,0 +1,73 @@
-- Created by: Peter KURNEV
-- Copyright (c) 1999-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 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.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class ShellSplitter from BOPAlgo
inherits Algo from BOPAlgo
---Purpose:
-- The class provides the splitting of the set of connected faces
-- on separate loops
uses
BaseAllocator from BOPCol,
Shape from TopoDS,
ListOfShape from BOPCol,
ConnexityBlock from BOPTools,
ListOfConnexityBlock from BOPTools
--raises
is
Create
returns ShellSplitter from BOPAlgo;
---C++: alias "Standard_EXPORT virtual ~BOPAlgo_ShellSplitter();"
---Purpose: empty constructor
Create(theAllocator: BaseAllocator from BOPCol)
returns ShellSplitter from BOPAlgo;
---Purpose: constructor
AddStartElement(me:out;
theS: Shape from TopoDS);
---Purpose: adds a face <theS> to process
StartElements(me)
returns ListOfShape from BOPCol;
---C++: return const &
---Purpose: return the faces to process
Perform(me:out)
is redefined;
---Purpose: performs the algorithm
Shells(me)
returns ListOfShape from BOPCol;
---C++: return const &
---Purpose: returns the loops
MakeConnexityBlocks(me:out)
is protected;
MakeShells (me:out)
is protected;
SplitBlock(myclass;
theCB:out ConnexityBlock from BOPTools);
fields
myStartShapes: ListOfShape from BOPCol is protected;
myShells: ListOfShape from BOPCol is protected;
myLCB : ListOfConnexityBlock from BOPTools is protected;
end ShellSplitter;

View File

@@ -0,0 +1,612 @@
// Created by: Peter KURNEV
// Copyright (c) 1999-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 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.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// File: BOPAlgo_ShellSplitter.cxx
// Created: Thu Jan 16 08:33:50 2014
// <pkv@PETREX>
#include <BOPAlgo_ShellSplitter.ixx>
//
#include <TopoDS_Shape.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Edge.hxx>
#include <BRep_Builder.hxx>
#include <TopExp_Explorer.hxx>
//
#include <BOPCol_IndexedMapOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BOPCol_MapOfOrientedShape.hxx>
#include <BOPCol_NCVector.hxx>
#include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
//
#include <BOPInt_Context.hxx>
//
#include <BOPTools.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPTools_CoupleOfShape.hxx>
//
static
void MakeShell(const BOPCol_ListOfShape& ,
TopoDS_Shell& );
//
static
void RefineShell(TopoDS_Shell& theShell);
//
static
Standard_Boolean IsClosedShell(const TopoDS_Shell& theShell);
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_ShellSplitter::BOPAlgo_ShellSplitter()
:
BOPAlgo_Algo(),
myStartShapes(myAllocator),
myShells(myAllocator),
myLCB(myAllocator)
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_ShellSplitter::BOPAlgo_ShellSplitter
(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_Algo(theAllocator),
myStartShapes(theAllocator),
myShells(theAllocator),
myLCB(myAllocator)
{
}
//=======================================================================
//function : ~
//purpose :
//=======================================================================
BOPAlgo_ShellSplitter::~BOPAlgo_ShellSplitter()
{
}
//=======================================================================
//function : AddStartElement
//purpose :
//=======================================================================
void BOPAlgo_ShellSplitter::AddStartElement(const TopoDS_Shape& aE)
{
myStartShapes.Append(aE);
}
//=======================================================================
//function : StartElements
//purpose :
//=======================================================================
const BOPCol_ListOfShape& BOPAlgo_ShellSplitter::StartElements()const
{
return myStartShapes;
}
//=======================================================================
//function : Loops
//purpose :
//=======================================================================
const BOPCol_ListOfShape& BOPAlgo_ShellSplitter::Shells()const
{
return myShells;
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BOPAlgo_ShellSplitter::Perform()
{
myErrorStatus=0;
//
MakeConnexityBlocks();
if (myErrorStatus) {
return;
}
//
MakeShells();
}
//=======================================================================
//function : MakeConnexityBlocks
//purpose :
//=======================================================================
void BOPAlgo_ShellSplitter::MakeConnexityBlocks()
{
Standard_Boolean bRegular;
Standard_Integer i, j, aNbE, aNbES, aNbEP, k, aNbCB;
TopoDS_Shape aFR;
TopExp_Explorer aExpF;
BOPCol_IndexedDataMapOfShapeListOfShape aMEF(100, myAllocator);
BOPCol_IndexedMapOfShape aMEP(100, myAllocator);
BOPCol_IndexedMapOfShape aMFC(100, myAllocator);
BOPCol_MapOfShape aMER(100, myAllocator);
BOPCol_MapOfShape aMFP(100, myAllocator);
BOPCol_IndexedMapOfShape aMEAdd(100, myAllocator);
BOPCol_MapOfShape aMES(100, myAllocator);
BOPCol_ListIteratorOfListOfShape aIt;
//
myErrorStatus=0;
//
myLCB.Clear();
//
const BOPCol_ListOfShape& aLSE=myStartShapes;
aIt.Initialize(aLSE);
for (i=1; aIt.More(); aIt.Next(), ++i) {
const TopoDS_Shape& aSE=aIt.Value();
if (!aMEP.Contains(aSE)) {
aMEP.Add(aSE);
BOPTools::MapShapesAndAncestors(aSE,
TopAbs_EDGE,
TopAbs_FACE,
aMEF);
}
else {
aMER.Add(aSE);
}
}
//
// 2
aNbE=aMEF.Extent();
for (i=1; i<=aNbE; ++i) {
aNbES=aMES.Extent();
if (aNbES==aNbE) {
break;
}
//
const TopoDS_Shape& aE=aMEF.FindKey(i);
//
if (!aMES.Add(aE)) {
continue;
}
// aMES - globally processed edges
//
//------------------------------------- goal: aMEC
aMFC.Clear(); // aMEC - edges of CB
aMEP.Clear(); // aMVP - edges to process right now
aMEAdd.Clear(); // aMVAdd edges to process on next step of for(;;) {
//
aMEP.Add(aE);
//
for(;;) {
aNbEP=aMEP.Extent();
for (k=1; k<=aNbEP; ++k) {
const TopoDS_Shape& aEP=aMEP(k);
const BOPCol_ListOfShape& aLF=aMEF.FindFromKey(aEP);
aIt.Initialize(aLF);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aF=aIt.Value();
if (aMFC.Add(aF)) {
aExpF.Init(aF, TopAbs_EDGE);
for (; aExpF.More(); aExpF.Next()) {
const TopoDS_Shape& aEF=aExpF.Current();
if (aMES.Add(aEF)) {
aMEAdd.Add(aEF);
}
}
}
}
}
//
aNbEP=aMEAdd.Extent();
if (!aNbEP) {
break; // from for(;;) {
}
//
aMEP.Clear();
//
for (k=1; k<=aNbEP; ++k) {
const TopoDS_Shape& aEF=aMEAdd(k);
aMEP.Add(aEF);
}
aMEAdd.Clear();
}// for(;;) {
//
//-------------------------------------
BOPTools_ConnexityBlock aCB(myAllocator);
//
BOPCol_ListOfShape& aLECB=aCB.ChangeShapes();
BOPCol_IndexedDataMapOfShapeListOfShape aMEFR(100, myAllocator);
//
bRegular=Standard_True;
aNbCB = aMFC.Extent();
for (j=1; j<=aNbCB; ++j) {
aFR = aMFC(j);
//
if (aMER.Contains(aFR)) {
aFR.Orientation(TopAbs_FORWARD);
aLECB.Append(aFR);
aFR.Orientation(TopAbs_REVERSED);
aLECB.Append(aFR);
bRegular=Standard_False;
}
else {
aLECB.Append(aFR);
}
//
if (bRegular) {
BOPTools::MapShapesAndAncestors(aFR,
TopAbs_EDGE,
TopAbs_FACE,
aMEFR);
}
}
//
if (bRegular) {
Standard_Integer aNbER, aNbFR;
//
aNbER=aMEFR.Extent();
for (k=1; k<=aNbER; ++k) {
const BOPCol_ListOfShape& aLFR=aMEFR(k);
aNbFR=aLFR.Extent();
if (aNbFR>2) {
bRegular=!bRegular;
break;
}
}
}
//
aCB.SetRegular(bRegular);
myLCB.Append(aCB);
}
}
//=======================================================================
//function : SplitBlock
//purpose :
//=======================================================================
void BOPAlgo_ShellSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB)
{
Standard_Integer aNbLF, aNbOff, aNbFP;
Standard_Integer i;
TopAbs_Orientation anOr;
TopoDS_Edge aEL;
BRep_Builder aBB;
TopoDS_Iterator aItS;
TopExp_Explorer aExp;
BOPCol_ListIteratorOfListOfShape aItF;
BOPTools_CoupleOfShape aCSOff;
BOPCol_MapOfOrientedShape AddedFacesMap;
BOPCol_IndexedDataMapOfShapeListOfShape aEFMap, aMEFP;
//
Handle (BOPInt_Context) aContext=new BOPInt_Context;
//
const BOPCol_ListOfShape& myShapes=aCB.Shapes();
//
BOPCol_ListOfShape& myLoops=aCB.ChangeLoops();
myLoops.Clear();
//
// 1. Shells Usual
aItF.Initialize (myShapes);
for (; aItF.More(); aItF.Next()) {
const TopoDS_Shape& aFF = aItF.Value();
BOPTools::MapShapesAndAncestors (aFF,
TopAbs_EDGE,
TopAbs_FACE,
aEFMap);
}
//
aItF.Initialize (myShapes);
for (i=1; aItF.More(); aItF.Next(), ++i) {
const TopoDS_Shape& aFF = aItF.Value();
if (!AddedFacesMap.Add(aFF)) {
continue;
}
//
// make a new shell
TopoDS_Shell aShell;
aBB.MakeShell(aShell);
aBB.Add(aShell, aFF);
//
aMEFP.Clear();
BOPTools::MapShapesAndAncestors(aFF,
TopAbs_EDGE,
TopAbs_FACE,
aMEFP);
//
// loop on faces added to Shell;
// add their neighbor faces to Shell and so on
aItS.Initialize (aShell);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Face& aF = (*(TopoDS_Face*)(&aItS.Value()));
//
// loop on edges of aF; find a good neighbor face of aF by aE
aExp.Init(aF, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&aExp.Current()));
//
//1
if (aMEFP.Contains(aE)) {
const BOPCol_ListOfShape& aLFP=aMEFP.FindFromKey(aE);
aNbFP=aLFP.Extent();
if (aNbFP>1) {
continue;
}
}
//2
anOr=aE.Orientation();
if (anOr==TopAbs_INTERNAL) {
continue;
}
//3
if (BRep_Tool::Degenerated(aE)) {
continue;
}
//
// candidate faces list
const BOPCol_ListOfShape& aLF=aEFMap.FindFromKey(aE);
aNbLF=aLF.Extent();
if (!aNbLF) {
continue;
}
//
// try to select one of neighbors
// check if a face already added to Shell shares E
Standard_Boolean bFound;
BOPCol_ListIteratorOfListOfShape aItLF;
BOPTools_ListOfCoupleOfShape aLCSOff;
//
aItLF.Initialize(aLF);
for (; aItLF.More(); aItLF.Next()) {
const TopoDS_Face& aFL=(*(TopoDS_Face*)(&aItLF.Value()));
if (aF.IsSame(aFL)) {
continue;
}
if (AddedFacesMap.Contains(aFL)){
continue;
}
//
bFound=BOPTools_AlgoTools::GetEdgeOff(aE, aFL, aEL);
if (!bFound) {
continue;
}
//
aCSOff.SetShape1(aEL);
aCSOff.SetShape2(aFL);
aLCSOff.Append(aCSOff);
}//for (; aItLF.More(); aItLF.Next()) {
//
aNbOff=aLCSOff.Extent();
if (!aNbOff){
continue;
}
//
TopoDS_Face aSelF;
if (aNbOff==1) {
aSelF=(*(TopoDS_Face*)(&aLCSOff.First().Shape2()));
}
else if (aNbOff>1){
BOPTools_AlgoTools::GetFaceOff(aE,
aF,
aLCSOff,
aSelF,
aContext);
}
//
if (!aSelF.IsNull() && AddedFacesMap.Add(aSelF)) {
aBB.Add(aShell, aSelF);
BOPTools::MapShapesAndAncestors(aSelF,
TopAbs_EDGE,
TopAbs_FACE,
aMEFP);
}
} // for (; aExp.More(); aExp.Next()) {
} // for (; aItS.More(); aItS.Next()) {
//
if (IsClosedShell(aShell)) {
aShell.Closed (Standard_True);
myLoops.Append(aShell);
}
else {
RefineShell(aShell);
if (IsClosedShell(aShell)) {
aShell.Closed (Standard_True);
myLoops.Append(aShell);
}
}
} // for (; aItF.More(); aItF.Next()) {
}
//=======================================================================
//function : RefineShell
//purpose :
//=======================================================================
void RefineShell(TopoDS_Shell& theShell)
{
TopoDS_Iterator aIt;
//
aIt.Initialize(theShell);
if(!aIt.More()) {
return;
}
//
Standard_Integer i, aNbMEF, aNbF;
BOPCol_IndexedDataMapOfShapeListOfShape aMEF;
TopoDS_Builder aBB;
TopExp_Explorer aExp;
BOPCol_MapOfShape aMEStop, aMFB;
BOPCol_MapIteratorOfMapOfShape aItM;
BOPCol_ListIteratorOfListOfShape aItLF, aItLFP;
BOPCol_ListOfShape aLFP, aLFP1;
//
// Branch points
BOPTools::MapShapesAndAncestors (theShell,
TopAbs_EDGE,
TopAbs_FACE,
aMEF);
aNbMEF=aMEF.Extent();
for (i=1; i<=aNbMEF; ++i) {
const TopoDS_Shape& aE=aMEF.FindKey(i);
const BOPCol_ListOfShape& aLF=aMEF.FindFromIndex(i);
aNbF=aLF.Extent();
if (aNbF>2) {
aMEStop.Add(aE);
}
}
//
if (aMEStop.IsEmpty()) {
return;
}
//
// The first Face
const TopoDS_Shape& aF1=aIt.Value();
aMFB.Add(aF1);
aLFP.Append(aF1);
//
// Trying to reach the branch point
for (;;) {
aItLFP.Initialize(aLFP);
for (; aItLFP.More(); aItLFP.Next()) {
const TopoDS_Shape& aFP=aItLFP.Value();
//
aExp.Init(aFP, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current()));
if (aMEStop.Contains(aE)) {
continue;
}
//
if (BRep_Tool::Degenerated(aE)) {
continue;
}
//
const BOPCol_ListOfShape& aLF=aMEF.FindFromKey(aE);
//
aItLF.Initialize(aLF);
for (; aItLF.More(); aItLF.Next()) {
const TopoDS_Shape& aFP1=aItLF.Value();
if (aFP1.IsSame(aFP)) {
continue;
}
if (aMFB.Contains(aFP1)) {
continue;
}
aMFB.Add(aFP1);
aLFP1.Append(aFP1);
}// for (; aItLF.More(); aItLF.Next()) {
}// for (; aExp.More(); aExp.Next()) {
}// for (; aItLFP.More(); aItLFP.Next()) {
//
//
if (aLFP1.IsEmpty()) {
break;
}
//
aLFP.Clear();
aItLF.Initialize(aLFP1);
for (; aItLF.More(); aItLF.Next()) {
const TopoDS_Shape& aFP1=aItLF.Value();
aLFP.Append(aFP1);
}
aLFP1.Clear();
}// for (;;) {
//
// Remove all faces before the branch point
aItM.Initialize(aMFB);
for (; aItM.More(); aItM.Next()) {
const TopoDS_Shape& aFB=aItM.Value();
aBB.Remove(theShell, aFB);
}
}
//=======================================================================
//function : MakeShells
//purpose :
//=======================================================================
void BOPAlgo_ShellSplitter::MakeShells()
{
Standard_Boolean bIsRegular;
BOPTools_ListIteratorOfListOfConnexityBlock aItCB;
BOPCol_ListIteratorOfListOfShape aIt;
//
myErrorStatus=0;
myShells.Clear();
//
aItCB.Initialize(myLCB);
for (; aItCB.More(); aItCB.Next()) {
BOPTools_ConnexityBlock& aCB=aItCB.ChangeValue();
bIsRegular=aCB.IsRegular();
if (bIsRegular) {
TopoDS_Shell aShell;
//
const BOPCol_ListOfShape& aLF=aCB.Shapes();
MakeShell(aLF, aShell);
aShell.Closed(Standard_True);
myShells.Append(aShell);
}
else {
SplitBlock(aCB);
const BOPCol_ListOfShape& aLS=aCB.Loops();
aIt.Initialize(aLS);
for (; aIt.More(); aIt.Next()) {
TopoDS_Shape& aShell=aIt.ChangeValue();
aShell.Closed(Standard_True);
myShells.Append(aShell);
}
}
}
}
//=======================================================================
//function : MakeShell
//purpose :
//=======================================================================
void MakeShell(const BOPCol_ListOfShape& aLS,
TopoDS_Shell& aShell)
{
BRep_Builder aBB;
BOPCol_ListIteratorOfListOfShape aIt;
//
aBB.MakeShell(aShell);
//
aIt.Initialize(aLS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aF=aIt.Value();
aBB.Add(aShell, aF);
}
}
//=======================================================================
//function : IsClosedShell
//purpose :
//=======================================================================
Standard_Boolean IsClosedShell(const TopoDS_Shell& theShell)
{
Standard_Integer aNbE;
Standard_Boolean bRet;
TopoDS_Iterator aIt;
TopExp_Explorer aExp;
BOPCol_MapOfShape aM;
//
aIt.Initialize(theShell);
for(; aIt.More(); aIt.Next()) {
const TopoDS_Face& aF=(*(TopoDS_Face*)(&aIt.Value()));
aExp.Init(aF, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Edge& aE=(*(TopoDS_Edge*)(&aExp.Current()));
if (BRep_Tool::Degenerated(aE)) {
continue;
}
//
if (aE.Orientation()==TopAbs_INTERNAL) {
continue;
}
//
if (!aM.Add(aE)) {
aM.Remove(aE);
}
}
}
//
aNbE = aM.Extent();
bRet = (aNbE > 0) ? Standard_False : Standard_True;
return bRet;
}

View 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;
//
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;
}
}
}//if (anIsSameV) {
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;
//
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);
}
anIt.Initialize(aLEInfo);
for (; anIt.More() && !bIsClosed; anIt.Next()) {
const BOPAlgo_EdgeInfo& anEI = anIt.Value();
const TopoDS_Edge& aE = anEI.Edge();
//
aNbj=i-1;
if (aNbj<1) {
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);
}
}
}
//
aNb=aLS.Length();
if (aNb>0) {
//
BOPCol_ListOfShape aBuf;
//
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 (anIsSameV) {
//
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;
//
break;
}
}
}
//
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++;
//
// 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;
}
//
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));
if (iCnt==1) {
// the one and only way to go out .
pEdgeInfo=&anEI;
anIsFound=Standard_True;
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;
//
aP2Dx=Coord2dVf(aE, myFace);
//
aD2=aP2Dx.SquareDistance(aPb);
if (aD2 > aTol2D2){
continue;
}
//
//
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

View 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;
}

View File

@@ -29,11 +29,24 @@
#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>
@@ -42,28 +55,57 @@
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <BRepAdaptor_Curve.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 <BRepAdaptor_Surface.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Plane.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <BRep_Builder.hxx>
#include <Geom_Surface.hxx>
#include <BOPCol_IndexedMapOfShape.hxx>
#include <BOPTools.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <BRepTools.hxx>
#include <BOPCol_IndexedMapOfShape.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;
}

View 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.

View File

@@ -74,9 +74,10 @@
//=======================================================================
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);
}
//=======================================================================
@@ -87,9 +88,10 @@
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);
}
@@ -101,11 +103,12 @@
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();
//

View File

@@ -0,0 +1,342 @@
#include <BRepCheck_SurfNormAnalyzer.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <Geom_Surface.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomAdaptor_HSurface.hxx>
#include <Adaptor3d_TopolTool.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <gp_VectorWithNullMagnitude.hxx>
static Standard_Real AdjustExtr(const Adaptor3d_Surface& S,
const Standard_Real UMin,
const Standard_Real UMax,
const Standard_Real VMin,
const Standard_Real VMax,
const Standard_Real Extr0,
const Standard_Real Tol,
Standard_Real& uextr,
Standard_Real& vextr );
//=======================================================================
//function : BRepCheck_Analyzer
//purpose :
//=======================================================================
BRepCheck_SurfNormAnalyzer::BRepCheck_SurfNormAnalyzer ():
myAngTol(0.01)
{
}
//=======================================================================
//function : BRepCheck_Analyzer
//purpose :
//=======================================================================
BRepCheck_SurfNormAnalyzer::BRepCheck_SurfNormAnalyzer
(const TopoDS_Shape& theS,
const Standard_Real theAngTol):
myShape(theS), myAngTol(theAngTol)
{
}
//=======================================================================
//function : IsValid
//purpose :
//=======================================================================
Standard_Boolean BRepCheck_SurfNormAnalyzer::IsValid()
{
TopLoc_Location anL;
myBadFaces.Clear();
Standard_Real umin, umax, vmin, vmax;
TopExp_Explorer anEx(myShape, TopAbs_FACE);
for(; anEx.More(); anEx.Next())
{
TopoDS_Face aF = TopoDS::Face(anEx.Current());
BRepTools::UVBounds(aF, umin, umax, vmin, vmax);
const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(aF, anL);
if(IsProblemSurf(aSurf, umin, umax, vmin, vmax, myAngTol))
{
myBadFaces.Append(aF);
}
}
return myBadFaces.IsEmpty();
}
//=======================================================================
//function : BadFaces
//purpose :
//=======================================================================
const TopTools_ListOfShape& BRepCheck_SurfNormAnalyzer::BadFaces() const
{
return myBadFaces;
}
//=======================================================================
//function : SetShape
//purpose :
//=======================================================================
void BRepCheck_SurfNormAnalyzer::SetShape(const TopoDS_Shape& theShape)
{
myBadFaces.Clear();
myShape = theShape;
}
//=======================================================================
//function : SetTolerance
//purpose :
//=======================================================================
void BRepCheck_SurfNormAnalyzer::SetTolerance(const Standard_Real theAngTol)
{
myBadFaces.Clear();
myAngTol = theAngTol;
}
//=======================================================================
//function : GetShape
//purpose :
//=======================================================================
const TopoDS_Shape& BRepCheck_SurfNormAnalyzer::GetShape() const
{
return myShape;
}
//=======================================================================
//function : GetTolerance
//purpose :
//=======================================================================
Standard_Real BRepCheck_SurfNormAnalyzer::GetTolerance() const
{
return myAngTol;
}
//=======================================================================
//function : IsProblemSurf
//purpose :
//=======================================================================
Standard_Boolean
BRepCheck_SurfNormAnalyzer::IsProblemSurf(const Handle_Geom_Surface& theSurf,
const Standard_Real theUMin,
const Standard_Real theUMax,
const Standard_Real theVMin,
const Standard_Real theVMax,
const Standard_Real theAngTol)
{
Standard_Boolean aStatus = Standard_False;
GeomAdaptor_Surface aGAS(theSurf, theUMin, theUMax, theVMin, theVMax);
GeomAbs_SurfaceType aSType = aGAS.GetType();
//
if(aSType <= GeomAbs_Torus)
{
return aStatus;
}
//
Handle(GeomAdaptor_HSurface) aGAHS = new GeomAdaptor_HSurface(aGAS);
Handle(Adaptor3d_TopolTool) aTT = new Adaptor3d_TopolTool(aGAHS);
if(aTT->DomainIsInfinite())
{
return aStatus;
}
//
Standard_Real aDefl = 0.1; //the same as for intersection default
Standard_Integer aNbMinU = 10, aNbMinV = 10;
aTT->SamplePnts(aDefl, aNbMinU, aNbMinV);
Standard_Integer aNbU = aTT->NbSamplesU();
Standard_Integer aNbV = aTT->NbSamplesV();
TColStd_Array1OfReal anUPars(1, aNbU), aVPars(1, aNbV);
aTT->UParameters(anUPars);
aTT->VParameters(aVPars);
//
gp_Pnt aP;
gp_Vec aDU, aDV;
Standard_Real u, v, ang;
TColStd_Array2OfReal aTabN(1, aNbU, 1, aNbV);
Standard_Integer i, j;
//Check singular point on boundary
for(j = 1; j <= aNbV; j += aNbV-1)
{
aP = theSurf->Value(anUPars(1), aVPars(j));
Standard_Real length = 0.;
for(i = 2; i <= aNbU; ++i)
{
gp_Pnt aPcur = theSurf->Value(anUPars(i), aVPars(j));
length += aPcur.Distance(aP);
if(length > Precision::Confusion())
{
break;
}
aP = aPcur;
}
if(length <= Precision::Confusion())
{
if(j == 1)
{
aVPars(j) += (aVPars(2)-aVPars(1)) / 10.;
}
else
{
aVPars(aNbV) -= (aVPars(aNbV)-aVPars(aNbV-1)) / 10.;
}
}
}
for(j = 1; j <= aNbU; j += aNbU-1)
{
aP = theSurf->Value(anUPars(j), aVPars(1));
Standard_Real length = 0.;
for(i = 2; i <= aNbV; ++i)
{
gp_Pnt aPcur = theSurf->Value(anUPars(j), aVPars(i));
length += aPcur.Distance(aP);
if(length > Precision::Confusion())
{
break;
}
aP = aPcur;
}
if(length <= Precision::Confusion())
{
if(j == 1)
{
anUPars(j) += (anUPars(2)-anUPars(1)) / 10.;
}
else
{
anUPars(aNbU) -= (anUPars(aNbU)-anUPars(aNbU-1)) / 10.;
}
}
}
//
for(i = 1; i <= aNbU; ++i)
{
u = anUPars(i);
for(j = 1; j <= aNbV; ++j)
{
v = aVPars(j);
theSurf->D1(u, v, aP, aDU, aDV);
try
{
ang = aDU.Angle(aDV);
if(ang > M_PI/2.)
{
ang = M_PI - ang;
}
}
catch (gp_VectorWithNullMagnitude)
{
ang = 0.;
}
aTabN(i, j) = ang;
}
}
//
Standard_Real min = RealLast();
Standard_Integer imin = 0, jmin = 0;
for(i = 1; i <= aNbU; ++i)
{
for(j = 1; j <= aNbV; ++j)
{
if(aTabN(i, j) < theAngTol)
{
return Standard_True;
}
else
{
if(aTabN(i, j) < min)
{
min = aTabN(i, j);
imin = i;
jmin = j;
}
}
}
}
//
Standard_Real umin = anUPars(Max(1, imin-1));
Standard_Real umax = anUPars(Min(aNbU, imin+1));
Standard_Real vmin = aVPars(Max(1, jmin-1));
Standard_Real vmax = aVPars(Min(aNbV, jmin+1));
//
Standard_Real min0 = min, uextr = anUPars(imin), vextr = aVPars(jmin);
min = AdjustExtr(aGAS, umin, umax, vmin, vmax,
min0, theAngTol / 10., uextr, vextr );
if(min < theAngTol)
{
aStatus = Standard_True;
}
return aStatus;
}
Standard_Real AdjustExtr(const Adaptor3d_Surface& S,
const Standard_Real UMin,
const Standard_Real UMax,
const Standard_Real VMin,
const Standard_Real VMax,
const Standard_Real Extr0,
const Standard_Real Tol,
Standard_Real& uextr,
Standard_Real& vextr )
{
Standard_Integer Nu = 5, Nv = 5;
gp_Pnt P;
gp_Vec DU, DV;
Standard_Integer i, j;
Standard_Real du = (UMax-UMin)/(Nu-1);
Standard_Real dv = (VMax-VMin)/(Nv-1);
Standard_Real extr = Extr0;
Standard_Real u, v, ang;
for (i = 1, u = UMin; i <= Nu; i++, u += du){
for (j = 1, v = VMin;j <= Nv; j++, v += dv){
S.D1(u,v,P,DU,DV);
try
{
ang = DU.Angle(DV);
if(ang > M_PI/2.)
{
ang = M_PI - ang;
}
}
catch (gp_VectorWithNullMagnitude)
{
ang = 0.;
}
//
if(extr > ang)
{
extr = ang;
uextr = u;
vextr = v;
}
}
}
if(Abs(extr - Extr0) > Tol)
{
Standard_Real umin, umax, vmin, vmax;
umin = Max(UMin, uextr - du);
umax = Min(UMax, uextr + du);
vmin = Max(VMin, vextr - dv);
vmax = Min(VMax, vextr + dv);
Standard_Real extr0 = extr;
extr = AdjustExtr(S, umin, umax, vmin, vmax,
extr0, Tol, uextr, vextr);
}
return extr;
}

View File

@@ -0,0 +1,84 @@
#ifndef _BRepCheck_SurfNormAnalyzer_HeaderFile
#define _BRepCheck_SurfNormAnalyzer_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 _TopoDS_Shape_HeaderFile
#include <TopoDS_Shape.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
#ifndef _TopAbs_ShapeEnum_HeaderFile
#include <TopAbs_ShapeEnum.hxx>
#endif
#include <TopTools_ListOfShape.hxx>
class Handle_Geom_Surface;
//! A class to check the problems with calculations<br>
//! of normals of face surfaces when dS/du and dS/dv are almost parallel:
//! normal to surface is calculated as N = dS/du^dS/dv and when<br>
//! dS/du || dS/dv N is poor defined. It can cause problems in intersection<br>
//! and other algoritms.<br>
//! This class diagnoses whether the area on the surface where angle between dS/du<br>
//! and dS/dv less then given angular tolerance. <br>
class BRepCheck_SurfNormAnalyzer {
public:
DEFINE_STANDARD_ALLOC
//
Standard_EXPORT BRepCheck_SurfNormAnalyzer();
Standard_EXPORT BRepCheck_SurfNormAnalyzer(const TopoDS_Shape& theS, const Standard_Real theAngTol);
//
Standard_EXPORT void SetShape(const TopoDS_Shape& theS);
Standard_EXPORT void SetTolerance(const Standard_Real theAngTol);
//
Standard_EXPORT Standard_Boolean IsValid();
//
Standard_EXPORT const TopoDS_Shape& GetShape() const;
Standard_EXPORT Standard_Real GetTolerance() const;
//
Standard_EXPORT const TopTools_ListOfShape& BadFaces() const;
//
Standard_EXPORT static Standard_Boolean
IsProblemSurf(const Handle_Geom_Surface& theSurf,
const Standard_Real theUMin,
const Standard_Real theUMax,
const Standard_Real theVMin,
const Standard_Real theVMax,
const Standard_Real theAngTol);
protected:
private:
TopoDS_Shape myShape;
TopTools_ListOfShape myBadFaces;
Standard_Real myAngTol;
};
#endif

2
src/BRepCheck/FILES Normal file
View File

@@ -0,0 +1,2 @@
BRepCheck_SurfNormAnalyzer.hxx
BRepCheck_SurfNormAnalyzer.cxx

View 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.
@@ -30,12 +30,14 @@
#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;
myFace.Nullify();
myState=2;
for(aSE.InitShell(); aSE.MoreShell() && nump<2; aSE.NextShell()) {
for(aSE.InitFace(); aSE.MoreFace() && nump<2; ) {
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)
{
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);
Standard_Boolean bFound;
Standard_Real aParam, aU = 0., aV = 0.;
gp_Pnt aPoint;
gp_Dir aDN;
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;
math_RealRandom RandomGenerator(0.1, 0.9);
myFace.Nullify();
myState=2;
aSE.InitShell();
if (aSE.MoreShell())
{
aSE.InitFace();
if (aSE.MoreFace())
{
TopoDS_Face aF = aSE.CurrentFace();
TopAbs_State aState = TopAbs_OUT;
IntCurveSurface_TransitionOnCurve aTransition = IntCurveSurface_Tangent;
TopoDS_Face MinFace = aF;
for (;;)
{
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;
}

View 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;
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);
(Ext.Point(iNear)).Parameter(aU, aV);
gp_Pnt2d aPuv(aU, aV);
gp_Pnt2d aPuv(aU, aV);
classifier2d.Perform(face,aPuv,Precision::PConfusion());
classifier2d.Perform(face,aPuv,Precision::PConfusion());
TopAbs_State aState = classifier2d.State();
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;
}
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

View 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.

View 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.

View 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.
@@ -14,52 +14,17 @@
#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;

View 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.

View 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.
@@ -14,34 +14,12 @@
#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;

View 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();
}

View 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.
@@ -14,31 +14,10 @@
#ifndef _BRepExtrema_ExtCC_HeaderFile
#define _BRepExtrema_ExtCC_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_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
#include <BRepAdaptor_HCurve.hxx>
#include <Standard_DefineAlloc.hxx>
class BRepAdaptor_HCurve;
class TopoDS_Edge;
class gp_Pnt;

View 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);
}
//=======================================================================

View 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.
@@ -14,46 +14,15 @@
#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
{

View 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);

View 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.
@@ -14,40 +14,13 @@
#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;

View 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);
}
//=======================================================================

View 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.
@@ -14,31 +14,10 @@
#ifndef _BRepExtrema_ExtPC_HeaderFile
#define _BRepExtrema_ExtPC_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_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
#include <BRepAdaptor_HCurve.hxx>
#include <Standard_DefineAlloc.hxx>
class BRepAdaptor_HCurve;
class TopoDS_Vertex;
class TopoDS_Edge;

View 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);
}
//=======================================================================

View 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.
@@ -14,43 +14,15 @@
#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;

View 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.

View 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.
@@ -14,28 +14,16 @@
#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);
};

View 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.
@@ -19,12 +19,8 @@
#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;

View 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.
@@ -19,130 +19,137 @@
#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.)
//! 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 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.)
{
}
//! 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

View 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

View 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 :

View 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>

View File

@@ -59,6 +59,7 @@
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp_Explorer.hxx>
#ifdef DRAW
#include <DrawTrSurf.hxx>

View 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

View 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.
@@ -16,8 +16,26 @@
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)
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.
returns Boolean from Standard
is static;
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;

View 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,224 +24,286 @@
#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
myFastClass = new BRepTopAdaptor_TopolTool();
Clear();
}
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();
//===========================================================================
//function :Init
//purpose :
//===========================================================================
void BRepIntCurveSurface_Inter::Init(const TopoDS_Shape& theShape,
const GeomAdaptor_Curve& theCurve,
const Standard_Real theTol)
{
Load(theShape, theTol);
Init(theCurve);
}
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 :
//===========================================================================
Standard_Boolean BRepIntCurveSurface_Inter::More() const {
return(explorer.More());
}
void BRepIntCurveSurface_Inter::Next() {
Find();
}
void BRepIntCurveSurface_Inter::Find() {
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;
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);
}
explorer.Next();
}
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
void BRepIntCurveSurface_Inter::Init(const TopoDS_Shape& theShape,
const gp_Lin& theLine,
const Standard_Real theTol)
{
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;
}
Handle(Geom_Line) geomline = new Geom_Line(theLine);
GeomAdaptor_Curve aCurve(geomline);
Load(theShape, theTol);
Init(aCurve);
}
//----------------------------------------------
Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(curve);
Handle(BRepAdaptor_HSurface) HS = new BRepAdaptor_HSurface(brepadaptsurf);
//----------------------------------------------
//-- intcs.Perform(curve,brepadaptsurf);
intcs.Perform(HC,HS);
//===========================================================================
//function :Clear
//purpose :
//===========================================================================
currentindex = 0;
currentnbpoints = intcs.NbPoints();
if(currentnbpoints) {
Find();
}
else {
explorer.Next();
Find();
void BRepIntCurveSurface_Inter::Clear()
{
myCurrentindex = 0;
myCurrentnbpoints = 0;
myIndFace = 0;
myCurrentstate = TopAbs_UNKNOWN;
myCurrentU = 0;
myCurrentV = 0;
}
//===========================================================================
//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();
}
//===========================================================================
//function :More
//purpose :
//===========================================================================
Standard_Boolean BRepIntCurveSurface_Inter::More() const
{
return (myIndFace <= myFaces.Length() );
}
//===========================================================================
//function :Next
//purpose :
//===========================================================================
void BRepIntCurveSurface_Inter::Next()
{
if(myCurrentnbpoints)
myCurrentindex++;
Find();
}
//===========================================================================
//function :Find
//purpose :
//===========================================================================
void BRepIntCurveSurface_Inter::Find()
{
if(myCurrentnbpoints && myCurrentindex <= myCurrentnbpoints && FindPoint())
return;
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());
}
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;
}
else {
currentnbpoints=0;
if(!myCurrentnbpoints && i > myFaces.Length())
{
myIndFace = i;
return;
}
}
//===========================================================================
//function :FindPoint
//purpose :
//===========================================================================
Standard_Boolean BRepIntCurveSurface_Inter::FindPoint()
{
Standard_Integer j = (!myCurrentindex ? 1 : myCurrentindex);
for( ; j <= myCurrentnbpoints; j++ )
{
Standard_Real anU = myIntcs.Point(j).U();
Standard_Real aV = myIntcs.Point(j).V();
gp_Pnt2d Puv( anU,aV );
IntCurveSurface_IntersectionPoint BRepIntCurveSurface_Inter::Point() const {
if(currentindex==0)
myCurrentstate = myFastClass->Classify(Puv,myTolerance);
if(myCurrentstate == TopAbs_ON || myCurrentstate == TopAbs_IN)
{
myCurrentindex = j;
myCurrentU = anU;
myCurrentV = aV;
return Standard_True;
}
}
return Standard_False;
}
//===========================================================================
//function :Point
//purpose :
//===========================================================================
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());
}

View 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.
@@ -58,7 +58,7 @@
//purpose :
//=======================================================================
static Standard_Real Controle(const TColgp_SequenceOfPnt& thePoints,
const Handle(Geom_Plane)& thePlane)
const Handle(Geom_Plane)& thePlane)
{
Standard_Real dfMaxDist=0.;
Standard_Real a,b,c,d, dist;
@@ -79,9 +79,9 @@ static Standard_Real Controle(const TColgp_SequenceOfPnt& thePoints,
// the first vertex of theEdge2 in parametric space of theFace
//=======================================================================
inline static Standard_Boolean Is2DConnected(const TopoDS_Edge& theEdge1,
const TopoDS_Edge& theEdge2,
const Handle(Geom_Surface)& theSurface,
const TopLoc_Location& theLocation)
const TopoDS_Edge& theEdge2,
const Handle(Geom_Surface)& theSurface,
const TopLoc_Location& theLocation)
{
Standard_Real f,l;
//TopLoc_Location aLoc;
@@ -110,8 +110,8 @@ inline static Standard_Boolean Is2DConnected(const TopoDS_Edge& theEdge1,
//=======================================================================
static Standard_Boolean Is2DClosed(const TopoDS_Shape& theShape,
const Handle(Geom_Surface)& theSurface,
const TopLoc_Location& theLocation)
const Handle(Geom_Surface)& theSurface,
const TopLoc_Location& theLocation)
{
try
{
@@ -164,9 +164,9 @@ BRepLib_FindSurface::BRepLib_FindSurface()
//purpose :
//=======================================================================
BRepLib_FindSurface::BRepLib_FindSurface(const TopoDS_Shape& S,
const Standard_Real Tol,
const Standard_Boolean OnlyPlane,
const Standard_Boolean OnlyClosed)
const Standard_Real Tol,
const Standard_Boolean OnlyPlane,
const Standard_Boolean OnlyClosed)
{
Init(S,Tol,OnlyPlane,OnlyClosed);
}
@@ -175,9 +175,9 @@ BRepLib_FindSurface::BRepLib_FindSurface(const TopoDS_Shape& S,
//purpose :
//=======================================================================
void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
const Standard_Real Tol,
const Standard_Boolean OnlyPlane,
const Standard_Boolean OnlyClosed)
const Standard_Real Tol,
const Standard_Boolean OnlyPlane,
const Standard_Boolean OnlyClosed)
{
myTolerance = Tol;
myTolReached = 0.;
@@ -214,24 +214,24 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
// check the other edges
for (ex.Init(S,TopAbs_EDGE); ex.More(); ex.Next()) {
if (!E.IsSame(ex.Current())) {
j = 0;
for(;;) {
j++;
BRep_Tool::CurveOnSurface(TopoDS::Edge(ex.Current()),
PPC,SS,L,ff,ll,j);
if (SS.IsNull()) {
break;
}
if (SS == mySurface) {
break;
}
SS.Nullify();
}
j = 0;
for(;;) {
j++;
BRep_Tool::CurveOnSurface(TopoDS::Edge(ex.Current()),
PPC,SS,L,ff,ll,j);
if (SS.IsNull()) {
break;
}
if (SS == mySurface) {
break;
}
SS.Nullify();
}
if (SS.IsNull()) {
mySurface.Nullify();
break;
}
if (SS.IsNull()) {
mySurface.Nullify();
break;
}
}
}
@@ -262,7 +262,7 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
// distances from neighboring points (_only_ same edge)
// 2. Minimizing the weighed sum of squared deviations
// compute coefficients of the sought plane.
TColgp_SequenceOfPnt aPoints;
TColStd_SequenceOfReal aWeight;
@@ -284,64 +284,84 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
{
case GeomAbs_BezierCurve:
{
// Put all poles for bezier
Handle(Geom_BezierCurve) GC = c.Bezier();
Standard_Integer iNbPol = GC->NbPoles();
if ( iNbPol < 2)
// Degenerate
continue;
else
{
Handle(TColgp_HArray1OfPnt) aPoles = new (TColgp_HArray1OfPnt) (1, iNbPol);
GC->Poles(aPoles->ChangeArray1());
gp_Pnt aPolePrev = aPoles->Value(1), aPoleNext;
Standard_Real dfDistPrev = 0., dfDistNext;
for (Standard_Integer iPol=1; iPol<=iNbPol; iPol++)
{
if (iPol<iNbPol)
{
aPoleNext = aPoles->Value(iPol+1);
dfDistNext = aPolePrev.Distance(aPoleNext);
}
else
dfDistNext = 0.;
aPoints.Append (aPolePrev);
aWeight.Append (dfDistPrev+dfDistNext);
dfDistPrev = dfDistNext;
aPolePrev = aPoleNext;
}
}
// Put all poles for bezier
Handle(Geom_BezierCurve) GC = c.Bezier();
Standard_Integer iNbPol = GC->NbPoles();
Standard_Real tf = GC->FirstParameter();
Standard_Real tl = GC->LastParameter();
Standard_Real r = (dfUl - dfUf) / (tl - tf);
r *= iNbPol;
if ( iNbPol < 2 || r < 1.)
// Degenerate
continue;
else
{
Handle(TColgp_HArray1OfPnt) aPoles = new (TColgp_HArray1OfPnt) (1, iNbPol);
GC->Poles(aPoles->ChangeArray1());
gp_Pnt aPolePrev = aPoles->Value(1), aPoleNext;
Standard_Real dfDistPrev = 0., dfDistNext;
for (Standard_Integer iPol=1; iPol<=iNbPol; iPol++)
{
if (iPol<iNbPol)
{
aPoleNext = aPoles->Value(iPol+1);
dfDistNext = aPolePrev.Distance(aPoleNext);
}
else
dfDistNext = 0.;
aPoints.Append (aPolePrev);
aWeight.Append (dfDistPrev+dfDistNext);
dfDistPrev = dfDistNext;
aPolePrev = aPoleNext;
}
}
}
break;
case GeomAbs_BSplineCurve:
{
// Put all poles for bspline
Handle(Geom_BSplineCurve) GC = c.BSpline();
Standard_Integer iNbPol = GC->NbPoles();
if ( iNbPol < 2)
// Degenerate
continue;
else
{
Handle(TColgp_HArray1OfPnt) aPoles = new (TColgp_HArray1OfPnt) (1, iNbPol);
GC->Poles(aPoles->ChangeArray1());
gp_Pnt aPolePrev = aPoles->Value(1), aPoleNext;
Standard_Real dfDistPrev = 0., dfDistNext;
for (Standard_Integer iPol=1; iPol<=iNbPol; iPol++)
{
if (iPol<iNbPol)
{
aPoleNext = aPoles->Value(iPol+1);
dfDistNext = aPolePrev.Distance(aPoleNext);
}
else
dfDistNext = 0.;
aPoints.Append (aPolePrev);
aWeight.Append (dfDistPrev+dfDistNext);
dfDistPrev = dfDistNext;
aPolePrev = aPoleNext;
}
}
// Put all poles for bspline
Handle(Geom_BSplineCurve) GC = c.BSpline();
Standard_Integer iNbPol = GC->NbPoles();
Standard_Real tf = GC->FirstParameter();
Standard_Real tl = GC->LastParameter();
Standard_Real r = (dfUl - dfUf) / (tl - tf);
r *= iNbPol;
if ( iNbPol < 2 || r < 1.)
// Degenerate
continue;
else
{
const Standard_Integer aNbPolMax = 200;
Standard_Integer incr = 1;
if(iNbPol > aNbPolMax)
{
Standard_Integer nb = iNbPol;
while(nb > aNbPolMax)
{
incr++;
nb = (iNbPol-1) / incr;
}
}
Handle(TColgp_HArray1OfPnt) aPoles = new (TColgp_HArray1OfPnt) (1, iNbPol);
GC->Poles(aPoles->ChangeArray1());
gp_Pnt aPolePrev = aPoles->Value(1), aPoleNext;
Standard_Real dfDistPrev = 0., dfDistNext;
Standard_Integer iPol;
for (iPol = 1; iPol <= iNbPol; iPol += incr)
{
if (iPol <= iNbPol - incr)
{
aPoleNext = aPoles->Value(iPol+incr);
dfDistNext = aPolePrev.Distance(aPoleNext);
}
else
dfDistNext = 0.;
aPoints.Append (aPolePrev);
aWeight.Append (dfDistPrev+dfDistNext);
dfDistPrev = dfDistNext;
aPolePrev = aPoleNext;
}
}
}
break;
@@ -351,41 +371,41 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
case GeomAbs_Hyperbola:
case GeomAbs_Parabola:
if (c.GetType() == GeomAbs_Line)
// Two points on straight segment
iNbPoints=2;
// Two points on straight segment
iNbPoints=2;
else
// Four points on otheranalitical curves
iNbPoints=4;
// Four points on otheranalitical curves
iNbPoints=4;
default:
{
// Put some points on other curves
if (iNbPoints==0)
iNbPoints = 15 + c.NbIntervals(GeomAbs_C3);
Standard_Real dfDelta = (dfUl-dfUf)/(iNbPoints-1);
Standard_Integer iPoint;
Standard_Real dfU;
gp_Pnt aPointPrev = c.Value(dfUf), aPointNext;
Standard_Real dfDistPrev = 0., dfDistNext;
for (iPoint=1, dfU=dfUf+dfDelta;
iPoint<=iNbPoints;
iPoint++, dfU+=dfDelta)
{
if (iPoint<iNbPoints)
{
aPointNext = c.Value(dfU);
dfDistNext = aPointPrev.Distance(aPointNext);
}
else
dfDistNext = 0.;
aPoints.Append (aPointPrev);
aWeight.Append (dfDistPrev+dfDistNext);
dfDistPrev = dfDistNext;
aPointPrev = aPointNext;
}
// Put some points on other curves
if (iNbPoints==0)
iNbPoints = 15 + c.NbIntervals(GeomAbs_C3);
Standard_Real dfDelta = (dfUl-dfUf)/(iNbPoints-1);
Standard_Integer iPoint;
Standard_Real dfU;
gp_Pnt aPointPrev = c.Value(dfUf), aPointNext;
Standard_Real dfDistPrev = 0., dfDistNext;
for (iPoint=1, dfU=dfUf+dfDelta;
iPoint<=iNbPoints;
iPoint++, dfU+=dfDelta)
{
if (iPoint<iNbPoints)
{
aPointNext = c.Value(dfU);
dfDistNext = aPointPrev.Distance(aPointNext);
}
else
dfDistNext = 0.;
aPoints.Append (aPointPrev);
aWeight.Append (dfDistPrev+dfDistNext);
dfDistPrev = dfDistNext;
aPointPrev = aPointNext;
}
} // default:
} // switch (c.GetType()) ...
} // for (ex.Init(S,TopAbs_EDGE); ex.More() && control; ex.Next()) ...
if (aPoints.Length() < 3) {
return;
}
@@ -414,14 +434,14 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
gp_XYZ p=aPoints(iPoint).XYZ()-aBaryCenter;
Standard_Real w=aWeight(iPoint)/dfMaxWeight;
aMat(1,1)+=w*p.X()*p.X();
aMat(1,2)+=w*p.X()*p.Y();
aMat(1,3)+=w*p.X()*p.Z();
aMat(1,2)+=w*p.X()*p.Y();
aMat(1,3)+=w*p.X()*p.Z();
aMat(2,1)+=w*p.Y()*p.X();
aMat(2,2)+=w*p.Y()*p.Y();
aMat(2,3)+=w*p.Y()*p.Z();
aMat(2,2)+=w*p.Y()*p.Y();
aMat(2,3)+=w*p.Y()*p.Z();
aMat(3,1)+=w*p.Z()*p.X();
aMat(3,2)+=w*p.Z()*p.Y();
aMat(3,3)+=w*p.Z()*p.Z();
aMat(3,2)+=w*p.Z()*p.Y();
aMat(3,3)+=w*p.Z()*p.Z();
aVec(1) -= w*p.X();
aVec(2) -= w*p.Y();
aVec(3) -= w*p.Z();
@@ -450,26 +470,27 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
if (!isSolved || myTolerance < dfDist) {
gp_Pnt aFirstPnt=aPoints(1);
for (iPoint=2; iPoint<=aPoints.Length(); iPoint++) {
gp_Vec aDir(aFirstPnt,aPoints(iPoint));
const gp_Pnt& aNextPnt = aPoints(iPoint);
gp_Vec aDir(aFirstPnt, aNextPnt);
Standard_Real dfSide=aDir.Magnitude();
if (dfSide<myTolerance) {
continue; // degeneration
continue; // degeneration
}
for (Standard_Integer iP1=iPoint+1; iP1<=aPoints.Length(); iP1++) {
gp_Vec aCross = gp_Vec(aFirstPnt,aPoints(iP1)) ^ aDir ;
if (aCross.Magnitude() > dfSide*myTolerance) {
Handle(Geom_Plane) aPlane2 = new Geom_Plane(aFirstPnt, aCross);
Standard_Real dfDist2 = Controle (aPoints, aPlane2);
if (dfDist2 < myTolerance) {
myTolReached = dfDist2;
mySurface = aPlane2;
return;
}
if (dfDist2 < dfDist) {
dfDist = dfDist2;
aPlane = aPlane2;
}
}
gp_Vec aCross = gp_Vec(aFirstPnt,aPoints(iP1)) ^ aDir ;
if (aCross.Magnitude() > dfSide*myTolerance) {
Handle(Geom_Plane) aPlane2 = new Geom_Plane(aFirstPnt, aCross);
Standard_Real dfDist2 = Controle (aPoints, aPlane2);
if (dfDist2 < myTolerance) {
myTolReached = dfDist2;
mySurface = aPlane2;
return;
}
if (dfDist2 < dfDist) {
dfDist = dfDist2;
aPlane = aPlane2;
}
}
}
}
}
@@ -537,3 +558,4 @@ TopLoc_Location BRepLib_FindSurface::Location() const
return myLocation;
}

View File

@@ -23,6 +23,7 @@
#include <BRepCheck_Analyzer.hxx>
#include <BRepCheck_Result.hxx>
#include <BRepCheck_ListIteratorOfListOfStatus.hxx>
#include <BRepCheck_SurfNormAnalyzer.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
@@ -243,6 +244,60 @@ static void Print(Standard_OStream& OS,
}
//
//=======================================================================
//function : checknorm
//purpose : Checks the normals of faces
//=======================================================================
static Standard_Integer checknorm(Draw_Interpretor& di,
Standard_Integer narg, const char** a)
{
if (narg < 3) {
return 1;
}
Standard_Real tol = 1.e-2;
TopoDS_Shape S = DBRep::Get(a[2]);
if(S.IsNull())
{
di << "Null shape \n";
return 1;
}
TopExp_Explorer anExp(S, TopAbs_FACE);
if(!anExp.More())
{
di << "There are no faces in shape /n";
return 1;
}
//
if(narg > 3)
{
tol = atof(a[3]);
}
//
BRepCheck_SurfNormAnalyzer aNormChecker(S, tol);
if(aNormChecker.IsValid())
{
di << "All faces seem to be valid \n" ;
return 0;
}
const TopTools_ListOfShape& aBadFaces = aNormChecker.BadFaces();
//
di << " number of problematic faces : " << aBadFaces.Extent() << "\n";
//
char Name[32];
Standard_Integer ipp=0;
TopTools_ListIteratorOfListOfShape itf;
for (itf.Initialize(aBadFaces); itf.More(); itf.Next()) {
ipp++;
Sprintf(Name,"%s_%d",a[1], ipp);
DBRep::Set(Name, itf.Value());
di << Name << " " ;
}
di << "\n";
return 0;
}
//=======================================================================
//function : computetolerance
//purpose :
@@ -1677,5 +1732,11 @@ theCommands.Add("listfuseedge",
"listfuseedge shape",
__FILE__,
listfuseedge,g);
theCommands.Add("checknorm",
"checknorm name shape tol",
__FILE__,
checknorm,g);
}

View 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;
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;
}
static BRepIntCurveSurface_Inter theAlg;
static double tol=1e-6;
static int nbpi=0;
static gp_Pnt curp;
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;
}

View 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();
{
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))) {
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;
}
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();
cfirst = Max(cfirst, tmin);
clast = Min(clast, tmax);
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;
}
Extrema_GenExtCS Ext(C, *myS, NbT, NbU, NbV, cfirst, clast, ufirst, ulast,
vfirst, vlast, mytolC, mytolS);
cfirst = Max(cfirst, tmin);
clast = Min(clast, tmax);
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);
}
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;

View 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);

View 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;
}
//

View 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

View 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);
}

View File

@@ -170,6 +170,7 @@ is
Degree(myclass; C : IntCurveCurve) returns Integer from Standard;
---C++: inline
end CurveTool;

View 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();
}

View 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);
}
*/

View File

@@ -65,8 +65,8 @@ GeomAbs_SurfaceType IntCurvesFace_Intersector::SurfaceType() const
//purpose :
//=======================================================================
IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
const Standard_Real aTol)
:
const Standard_Real aTol)
:
Tol(aTol),
done(Standard_False),
nbpnt(0),
@@ -95,7 +95,7 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
Standard_Boolean bFlag;
//
{
Standard_Real dU, dV, dA, dB, aR, aTresh;
Standard_Real dU, dV, dA, dB, aTresh;
bFlag=Standard_True;
//
aTresh=100.;
@@ -104,18 +104,12 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
dA=dU;
dB=dV;
if (dV>dU) {
dA=dV;
dB=dU;
dA=dV;
dB=dU;
}
//
aR=dA/dB;
if (dB<Precision::PConfusion()) {
bFlag=!bFlag;
}
else {
if (aR>aTresh) {
bFlag=!bFlag;
}
if (dB < Precision::PConfusion() || dA > dB * aTresh) {
bFlag=!bFlag;
}
}
//
@@ -125,7 +119,7 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
if(nbsu>40) nbsu = 40;
if(nbsv>40) nbsv = 40;
PtrOnPolyhedron = (IntCurveSurface_ThePolyhedronOfHInter *)
new IntCurveSurface_ThePolyhedronOfHInter(Hsurface,nbsu,nbsv,U0,V0,U1,V1);
new IntCurveSurface_ThePolyhedronOfHInter(Hsurface,nbsu,nbsv,U0,V0,U1,V1);
}
//
/*

File diff suppressed because it is too large Load Diff

View 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

View 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

View 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,

View 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

View 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) {

File diff suppressed because it is too large Load Diff

View 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);
}
}
}
}

View 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

File diff suppressed because it is too large Load Diff

View File

@@ -20,10 +20,10 @@
#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&);

View File

@@ -76,6 +76,7 @@ is
Add(me: in out; W: Wire from TopoDS;
F: Face from TopoDS)
returns Boolean from Standard
---Purpose: Adds the wire <W> on the face <F>.
raises NoSuchObject from Standard,
-- if <F> does not belong to the original shape.
@@ -88,6 +89,7 @@ is
Add(me: in out; Lwires: ListOfShape from TopTools;
F: Face from TopoDS)
returns Boolean from Standard
---Purpose: Adds the list of wires <Lwires> on the face <F>.
raises NoSuchObject from Standard,
-- if <F> does not belong to the original shape.
@@ -131,11 +133,11 @@ is
-- -- Private implementation methods
AddOpenWire(me: in out; W: Wire from TopoDS; F: Face from TopoDS)
returns Boolean from Standard
is static private;
AddClosedWire(me: in out; W: Wire from TopoDS; F: Face from TopoDS)
AddClosedWire(me: in out; W: Wire from TopoDS; F: Face from TopoDS) returns Boolean from Standard
is static private;

View File

@@ -60,8 +60,9 @@ static Standard_Boolean IsInside(const TopoDS_Face&,
static Standard_Boolean IsInside(const TopoDS_Face&,
const TopoDS_Wire&);
static void ChoixUV(const TopoDS_Edge&,
static Standard_Boolean ChoixUV(const TopoDS_Edge&,
const TopoDS_Face&,
const TopoDS_Vertex&,
const TopTools_MapOfShape&,
TopTools_MapIteratorOfMapOfShape&,
gp_Pnt2d&,
@@ -231,7 +232,7 @@ void LocOpe_SplitShape::Add(const TopoDS_Vertex& V,
//purpose : adds the list of wires on the face <F>
//=======================================================================
void LocOpe_SplitShape::Add(const TopTools_ListOfShape& Lwires,
Standard_Boolean LocOpe_SplitShape::Add(const TopTools_ListOfShape& Lwires,
const TopoDS_Face& F)
{
@@ -250,26 +251,27 @@ void LocOpe_SplitShape::Add(const TopTools_ListOfShape& Lwires,
TopoDS_Vertex Vfirst,Vlast;
BRepTools::Update(F);
// Standard_Boolean nbInside = 0;
TopTools_ListOfShape aLInside;
for (; itl.More(); itl.Next())
{
const TopoDS_Face& fac = TopoDS::Face(itl.Value());
Standard_Boolean AllWiresInside = Standard_True;
//Standard_Boolean AllWiresInside = Standard_True;
TopTools_ListIteratorOfListOfShape itwires(Lwires);
for (; itwires.More(); itwires.Next())
{
const TopoDS_Wire& aWire = TopoDS::Wire(itwires.Value());
if (!IsInside(fac, aWire))
if (IsInside(fac, aWire))
{
AllWiresInside = Standard_False;
break;
//nbInside++;
aLInside.Append(aWire);
}
}
if (AllWiresInside)
break;
}
if (!itl.More()) {
Standard_ConstructionError::Raise();
if (!aLInside.Extent()) {
return Standard_False;
}
TopoDS_Face FaceRef = TopoDS::Face(itl.Value());
@@ -288,7 +290,7 @@ void LocOpe_SplitShape::Add(const TopTools_ListOfShape& Lwires,
TopTools_DataMapOfShapeShape VerWireMap;
Standard_Integer i;
TopExp_Explorer ExploF, ExploW;
for (itl.Initialize(Lwires); itl.More(); itl.Next())
for (itl.Initialize(aLInside); itl.More(); itl.Next())
{
const TopoDS_Wire& aSection = TopoDS::Wire(itl.Value());
TopoDS_Vertex Ver [2];
@@ -317,7 +319,7 @@ void LocOpe_SplitShape::Add(const TopTools_ListOfShape& Lwires,
}
TopTools_DataMapOfShapeListOfShape VerSecMap;
for (itl.Initialize(Lwires); itl.More(); itl.Next())
for (itl.Initialize(aLInside); itl.More(); itl.Next())
{
const TopoDS_Wire& aWire = TopoDS::Wire(itl.Value());
TopoDS_Vertex V1, V2;
@@ -514,7 +516,7 @@ void LocOpe_SplitShape::Add(const TopTools_ListOfShape& Lwires,
///////////////////
// JAG 10.11.95 Codage des regularites
for (itl.Initialize(Lwires); itl.More(); itl.Next())
for (itl.Initialize(aLInside); itl.More(); itl.Next())
for (ExploW.Init(itl.Value(), TopAbs_EDGE); ExploW.More(); ExploW.Next())
{
const TopoDS_Edge& edg = TopoDS::Edge(ExploW.Current());
@@ -522,6 +524,7 @@ void LocOpe_SplitShape::Add(const TopTools_ListOfShape& Lwires,
BB.Continuity(edg,F,F,GeomAbs_CN);
}
}
return Standard_True;
}
@@ -530,12 +533,13 @@ void LocOpe_SplitShape::Add(const TopTools_ListOfShape& Lwires,
//purpose :
//=======================================================================
void LocOpe_SplitShape::Add(const TopoDS_Wire& W,
Standard_Boolean LocOpe_SplitShape::Add(const TopoDS_Wire& W,
const TopoDS_Face& F)
{
if (myDone) {
Standard_ConstructionError::Raise();
return Standard_False;
//Standard_ConstructionError::Raise();
}
@@ -547,16 +551,18 @@ void LocOpe_SplitShape::Add(const TopoDS_Wire& W,
try {
OCC_CATCH_SIGNALS
if (!LocOpe::Closed(W,F)) {
AddOpenWire(W,F);
if(!AddOpenWire(W,F))
return Standard_False;
}
else {
AddClosedWire(W,F);
if(!AddClosedWire(W,F))
return Standard_False;
}
} catch (Standard_Failure ) {
#ifdef DEB
cout << "Warning: SpliShape internal problem detected, some faces may be lost. Check input edges/wires" <<endl;
#endif
return;
return Standard_False;
}
// JAG 10.11.95 Codage des regularites
BRep_Builder B;
@@ -566,16 +572,16 @@ void LocOpe_SplitShape::Add(const TopoDS_Wire& W,
B.Continuity(edg,F,F,GeomAbs_CN);
}
}
return Standard_True;
}
//=======================================================================
//function : AddClosedWire
//purpose :
//=======================================================================
void LocOpe_SplitShape::AddClosedWire(const TopoDS_Wire& W,
Standard_Boolean LocOpe_SplitShape::AddClosedWire(const TopoDS_Wire& W,
const TopoDS_Face& F)
{
TopExp_Explorer exp;
@@ -598,7 +604,8 @@ void LocOpe_SplitShape::AddClosedWire(const TopoDS_Wire& W,
}
if (!itl.More()) {
Standard_ConstructionError::Raise();
return Standard_False;
//Standard_ConstructionError::Raise();
}
BRep_Builder B;
@@ -648,7 +655,7 @@ void LocOpe_SplitShape::AddClosedWire(const TopoDS_Wire& W,
B.Add(newRef,W.Oriented(TopAbs::Reverse(orWire)));
lf.Append(newRef);
lf.Append(newFace);
return Standard_True;
}
@@ -657,14 +664,15 @@ void LocOpe_SplitShape::AddClosedWire(const TopoDS_Wire& W,
//purpose :
//=======================================================================
void LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W,
Standard_Boolean 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 +688,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;
@@ -713,7 +723,8 @@ void LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W,
}
}
if (!itl.More()) {
Standard_ConstructionError::Raise();
return Standard_False;
//Standard_ConstructionError::Raise();
}
TopoDS_Face FaceRef = TopoDS::Face(itl.Value());
@@ -816,19 +827,19 @@ void LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W,
if (LastEdge.Orientation() == TopAbs_FORWARD) {
C2d->D1(l,plast,dlast);
if (dlast.Magnitude() < gp::Resolution())
{
//if (dlast.Magnitude() < gp::Resolution())
//{
gp_Pnt2d PrevPnt = C2d->Value(l - dpar);
dlast.SetXY(plast.XY() - PrevPnt.XY());
}
//}
}
else {
C2d->D1(f,plast,dlast);
if (dlast.Magnitude() < gp::Resolution())
{
//if (dlast.Magnitude() < gp::Resolution())
//{
gp_Pnt2d NextPnt = C2d->Value(f + dpar);
dlast.SetXY(NextPnt.XY() - plast.XY());
}
//}
dlast.Reverse();
}
@@ -874,28 +885,31 @@ void LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W,
if (itm.Key().Orientation() == TopAbs_FORWARD) {
C2d->D1(l,plast,dlast);
if (dlast.Magnitude() < gp::Resolution())
{
//if (dlast.Magnitude() < gp::Resolution())
//{
gp_Pnt2d PrevPnt = C2d->Value(l - dpar);
dlast.SetXY(plast.XY() - PrevPnt.XY());
}
//}
}
else {
C2d->D1(f,plast,dlast);
if (dlast.Magnitude() < gp::Resolution())
{
//if (dlast.Magnitude() < gp::Resolution())
//{
gp_Pnt2d NextPnt = C2d->Value(f + dpar);
dlast.SetXY(NextPnt.XY() - plast.XY());
}
//}
dlast.Reverse();
}
}
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);
//ChoixUV(LastEdge, TopoDS::Face(aLocalFace), PossE,
// itm, plast, dlast, toll);
if(!ChoixUV(LastEdge, TopoDS::Face(aLocalFace), Vlast, PossE,
itm, plast, dlast, toll))
return Standard_False;
}
if (nbPoss >= 1) {
@@ -961,9 +975,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());
@@ -1084,6 +1098,7 @@ void LocOpe_SplitShape::AddOpenWire(const TopoDS_Wire& W,
}
}
return Standard_True;
}
@@ -1363,8 +1378,9 @@ static Standard_Boolean IsInside(const TopoDS_Face& F,
//purpose :
//=======================================================================
static void ChoixUV(const TopoDS_Edge& Last,
Standard_Boolean ChoixUV(const TopoDS_Edge& Last,
const TopoDS_Face& F,
const TopoDS_Vertex& theVCommon,
const TopTools_MapOfShape& Poss,
TopTools_MapIteratorOfMapOfShape& It,
gp_Pnt2d& plst,
@@ -1380,48 +1396,49 @@ static void ChoixUV(const TopoDS_Edge& Last,
BRepAdaptor_Surface surf(F,Standard_False); // no restriction
surf.D0 (plst.X(), plst.Y(), aPlst);
Standard_Real tol;
Standard_Real tolV = BRep_Tool::Tolerance(theVCommon) + Precision::Confusion();
TopoDS_Vertex vtx;
gp_Dir2d ref2d(dlst);
gp_XY aNext2d(0.,0.0);
Handle(Geom2d_Curve) C2d;
Standard_Real dpar;
Standard_Integer index = 0, imin=0;
Standard_Real angmax = -M_PI, dist, ang;
Standard_Real dmin = Precision::Infinite();
Standard_Real aTol = Max (surf.UResolution (tolV), surf.VResolution (tolV));
for (It.Initialize(Poss); It.More(); It.Next()) {
index++;
C2d = BRep_Tool::CurveOnSurface(TopoDS::Edge(It.Key()),F,f,l);
dpar = (l - f)*0.01;
dpar = Min(aTol,(l - f)*0.01);
if (It.Key().Orientation() == TopAbs_FORWARD) {
// p2d = C2d->Value(f);
C2d->D1(f,p2d,v2d);
if (v2d.Magnitude() < gp::Resolution())
{
gp_Pnt2d NextPnt = C2d->Value(f + dpar);
v2d.SetXY(NextPnt.XY() - p2d.XY());
}
vtx = TopExp::FirstVertex(TopoDS::Edge(It.Key()));
p2d = C2d->Value(f);
//C2d->D1(f,p2d,v2d);
//if (v2d.Magnitude() < gp::Resolution())
//{
gp_Pnt2d NextPnt = C2d->Value(f + dpar);
v2d.SetXY(NextPnt.XY() - p2d.XY());
//}
vtx = TopExp::FirstVertex(TopoDS::Edge(It.Key()));
}
else {
// p2d = C2d->Value(l);
p2d = C2d->Value(l);
C2d->D1(l,p2d,v2d);
if (v2d.Magnitude() < gp::Resolution())
{
// if (v2d.Magnitude() < gp::Resolution())
// {
gp_Pnt2d PrevPnt = C2d->Value(l - dpar);
v2d.SetXY(p2d.XY() - PrevPnt.XY());
}
// }
v2d.Reverse();
vtx = TopExp::LastVertex(TopoDS::Edge(It.Key()));
}
surf.D0 (p2d.X(), p2d.Y(), aPCur);
tol = BRep_Tool::Tolerance(vtx);
Standard_Real tol = BRep_Tool::Tolerance(vtx);
tol = Max(toll, tol); tol *= tol;
dist = aPCur.SquareDistance(aPlst);
@@ -1433,43 +1450,49 @@ static void ChoixUV(const TopoDS_Edge& Last,
ang = -M_PI;
}
//if ((dist < dmin - tol) ||
//(dist <= dmin+tol && ang > angmax)) {
if ((dist < tol) && (ang > angmax)) {
if ((dist < tol) && (ang > angmax)) {// && !Last.IsSame(It.Key())) {
imin = index;
// dmin = dist;
angmax = ang;
dmin = dist;
}
}
if(!imin)
return Standard_False;
for (index = 1, It.Initialize(Poss); It.More(); It.Next()) {
if (index == imin) {
C2d = BRep_Tool::CurveOnSurface(TopoDS::Edge(It.Key()),F,f,l);
dpar = (l - f)*0.01;
TopoDS_Edge aNextEdge = TopoDS::Edge(It.Key());
C2d = BRep_Tool::CurveOnSurface(aNextEdge,F,f,l);
vtx = TopExp::LastVertex(aNextEdge, Standard_True);
Standard_Real tolV2 = BRep_Tool::Tolerance(vtx);
Standard_Real aTol2d = Max (surf.UResolution (tolV2), surf.VResolution (tolV2));
dpar = Min(aTol2d,(l - f)*0.01);
if (It.Key().Orientation() == TopAbs_FORWARD) {
// plst = C2d->Value(l);
C2d->D1(l,plst,dlst);
if (dlst.Magnitude() < gp::Resolution())
{
plst = C2d->Value(l);
//C2d->D1(l,plst,dlst);
//if (dlst.Magnitude() < gp::Resolution())
//{
gp_Pnt2d PrevPnt = C2d->Value(l - dpar);
dlst.SetXY(plst.XY() - PrevPnt.XY());
}
//}
}
else {
// plst = C2d->Value(f);
plst = C2d->Value(f);
C2d->D1(f,plst,dlst);
if (dlst.Magnitude() < gp::Resolution())
{
//if (dlst.Magnitude() < gp::Resolution())
//{
gp_Pnt2d NextPnt = C2d->Value(f + dpar);
dlst.SetXY(NextPnt.XY() - plst.XY());
}
//}
dlst.Reverse();
}
break;
}
index++;
}
return (imin);
}
//=======================================================================

View 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]);
@@ -1095,7 +1095,7 @@ void FindInternalIntersections(const TopoDS_Edge& theEdge,
Standard_Real /*theFpar, theLpar,*/ aFpar, aLpar;
const Handle(Geom_Curve)& theCurve = BRep_Tool::Curve(theEdge, thePar[0], thePar[1]);
GeomAdaptor_Curve theGAcurve(theCurve, thePar[0], thePar[1]);
Standard_Real aDistMax = Precision::Confusion();
TopExp_Explorer Explo(theFace, TopAbs_EDGE);
for (; Explo.More(); Explo.Next())
{
@@ -1117,6 +1117,7 @@ void FindInternalIntersections(const TopoDS_Edge& theEdge,
aNbExt = anExtrema.NbExt();
Standard_Real MaxTol = Max(BRep_Tool::Tolerance(theEdge), BRep_Tool::Tolerance(anEdge));
for (i = 1; i <= aNbExt; i++)
{
Standard_Real aDist = Sqrt(anExtrema.SquareDistance(i));
@@ -1163,7 +1164,11 @@ void FindInternalIntersections(const TopoDS_Edge& theEdge,
gp_Pnt aPoint = aCurve->Value(anIntPar);
if (aPoint.Distance(thePnt[0]) > BRep_Tool::Tolerance(theVertices[0]) &&
aPoint.Distance(thePnt[1]) > BRep_Tool::Tolerance(theVertices[1]))
{
SplitPars.Append(theIntPar);
if( aDist > aDistMax)
aDistMax = aDist;
}
}
}
}
@@ -1208,6 +1213,8 @@ void FindInternalIntersections(const TopoDS_Edge& theEdge,
LastPar = SplitPars(i);
gp_Pnt LastPoint = theCurve->Value(LastPar);
LastVertex = BRepLib_MakeVertex(LastPoint);
BRep_Builder aB;
aB.UpdateVertex(LastVertex, aDistMax);
}
else
{
@@ -1217,11 +1224,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;

View 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)
{

View 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)
{

View 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;
}

View 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.

View 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;
}

View 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,13 +149,16 @@ 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);
}
ConnectWiresToWires (iwires, toler, shared, wires);
for (i = 1; i <= edges->Length(); i++)
if (iwires->Value(i).Orientation() == TopAbs_REVERSED)
@@ -199,6 +202,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 +232,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 +249,8 @@ 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()));
if( Vf.IsNull() || Vl.IsNull())
return;
gp_Pnt pf, pl;
pf = BRep_Tool::Pnt(Vf);
pl = BRep_Tool::Pnt(Vl);
@@ -247,14 +263,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 +282,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);
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);
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);
TopoDS_Vertex Vprev, Vfol, V; //connection vertex
Vprev = sae.LastVertex (E1);
Vfol = sae.FirstVertex (E2);
//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);
}
}
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
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 (lwire == -1) done = 1;
else {
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 +432,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 +471,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);

View File

@@ -0,0 +1,124 @@
puts "================"
puts "OCC25416"
puts "================"
puts ""
#######################################################################
# Face/Face intersection algorithm gives different results for different order of the arguments
#######################################################################
# Check if list of xdistcs-command is valid
proc checkList {List Tolerance D_good Limit_Tol} {
set L1 [llength ${List}]
set L2 10
set L3 5
set N [expr (${L1} - ${L2})/${L3} + 1]
for {set i 1} {${i} <= ${N}} {incr i} {
set j1 [expr ${L2} + (${i}-1)*${L3}]
set j2 [expr ${j1} + 2]
set T [lindex ${List} ${j1}]
set D [lindex ${List} ${j2}]
#puts "i=${i} j1=${j1} j2=${j2} T=${T} D=${D}"
if { [expr abs(${D} - ${D_good})] > ${Tolerance} } {
puts "Error: T=${T} D=${D}"
}
if { ${Tolerance} > ${Limit_Tol} } {
if { [expr abs(${D} - ${D_good})] > ${Limit_Tol}
&& [expr abs(${D} - ${D_good})] <= ${Tolerance} } {
puts "Attention (critical value of tolerance) : T=${T} D=${D}"
}
}
}
}
puts "##############################"
puts "#!!!Search \"Attention\" keyword on this web-page for additional checking!!!"
puts "##############################"
puts ""
puts ""
# bopcurves command
restore [locate_data_file bug25416_f1.brep] f1
restore [locate_data_file bug25416_f2.brep] f2
#############################
set log [bopcurves f1 f2 -2d]
#############################
regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} ${log} full Toler NbCurv
#This value must be equal to the analogical value in bug25292_31 and bug25292_32 of "bugs modalg_5" testgrid.
set MaxTol 1.e-7
#This value must be equal to the analogical value in bug25292_31 and bug25292_32 of "bugs modalg_5" testgrid.
set GoodNbCurv 1
if {${Toler} > ${MaxTol}} {
puts "Error: Tolerance is too big!"
}
if {${NbCurv} != ${GoodNbCurv}} {
puts "Error: Curve Number is bad!"
}
#-------------
mksurface s1 f1
mksurface s2 f2
erase s1 s2
for {set i 1} {$i <= ${NbCurv}} {incr i} {
set log [dump c_$i]
set dumptrimres [regexp {Trimmed curve\nParameters : +([-0-9.+eE]+) +([-0-9.+eE]+)} ${log} full U1 U2]
if {${dumptrimres} == 0} {
regexp {Degree +([-0-9.+eE]+), +([-0-9.+eE]+) Poles, +([-0-9.+eE]+)} ${log} full Degree Poles KnotsPoles
puts "Degree=${Degree}"
puts "Poles=${Poles}"
puts "KnotsPoles=${KnotsPoles}"
puts ""
set Knot 1
set exp_string "Knots :\n\n +${Knot} : +(\[-0-9.+eE\]+) +(\[-0-9.+eE\]+)"
regexp ${exp_string} ${log} full U1 Mult1
set Knot ${KnotsPoles}
set exp_string " +${Knot} : +(\[-0-9.+eE\]+) +(\[-0-9.+eE\]+)"
regexp ${exp_string} ${log} full U2 Mult2
}
puts "U1=${U1}"
puts "U2=${U2}"
if {[expr {$U2 - $U1}] < 1.0e-20} {
puts "Error: Wrong curve's range!"
}
dlog reset
dlog on
xdistcs c_$i s1 ${U1} ${U2} 10
set Log2 [dlog get]
set List2 [split ${Log2} {TD= \t\n}]
set Tolerance 1.0e-7
set Limit_Tol 1.0e-7
set D_good 0.
checkList ${List2} ${Tolerance} ${D_good} ${Limit_Tol}
dlog reset
dlog on
xdistcs c_$i s2 ${U1} ${U2} 10
set Log2 [dlog get]
set List2 [split ${Log2} {TD= \t\n}]
set Tolerance 1.0e-7
set Limit_Tol 1.0e-7
set D_good 0.
checkList ${List2} ${Tolerance} ${D_good} ${Limit_Tol}
}
smallview
fit
set only_screen_axo 1

View File

@@ -0,0 +1,20 @@
puts "==========="
puts "OCC25697"
puts "==========="
puts ""
##########################################################################################
# Regression : Section obtained after command "bsection" in Test Harness is incorrect.
##########################################################################################
restore [locate_data_file bug25697_shell_for_seam.brep] s1
restore [locate_data_file bug25697_prism.brep] p1
bsection result s1 p1 -n2d2
regexp {nb alone Vertices : +([-0-9.+eE]+)} [checksection result] full nb_alone_Vertices
if { ${nb_alone_Vertices} == 2 } {
puts "OK: Good result done by Boolean Operation algorithm"
} else {
puts "Error: Wrong result done by Boolean Operation algorithm"
}
set length 107.503

View File

@@ -0,0 +1,63 @@
puts "=========="
puts "OCC25697"
puts "=========="
puts ""
########################################################################################
# Regression : Section obtained after command "bsection" in Test Harness is incorrect.
########################################################################################
restore [locate_data_file bug25697_shell_for_seam.brep] b1
restore [locate_data_file bug25697_prism.brep] b2
explode b1 f
copy b1_1 b1
explode b2 f
copy b2_1 b2
#################################
set log [bopcurves b1 b2 -2d1]
#################################
regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} ${log} full Toler NbCurv
set MaxTol 1.e-7
set GoodNbCurv 3
if { ${Toler} > ${MaxTol} } {
puts "Error: Tolerance is too big!"
}
if { ${NbCurv} != ${GoodNbCurv} } {
puts "Error: Curve Number is bad!"
}
#---------------
mksurface s1 b1
mksurface s2 b2
for {set i 1} {$i <= ${NbCurv}} {incr i} {
bounds c_$i u1 u2
dump u1 u2
dlog reset
dlog on
xdistcs c_$i s1 u1 u2 10
set Log2 [dlog get]
set List2 [split ${Log2} {TD= \t\n}]
set Tolerance 1.0e-7
set Limit_Tol 1.0e-7
set D_good 0.
checkList ${List2} ${Tolerance} ${D_good} ${Limit_Tol}
dlog reset
dlog on
xdistcs c_$i s2 u1 u2 10
set Log2 [dlog get]
set List2 [split ${Log2} {TD= \t\n}]
set Tolerance 1.0e-7
set Limit_Tol 1.0e-7
set D_good 0.
checkList ${List2} ${Tolerance} ${D_good} ${Limit_Tol}
}
smallview
fit
set only_screen_axo 1