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

Compare commits

...

40 Commits

Author SHA1 Message Date
gka
0bded24d8c 0029159: Sewing fail when using a maximum tolerance
Patch for OCCT670. Computed tolerance of the edge is set directly in the TEdge if value of computed maximal distance between 3D curve and curve on the surface less then tolerance of edge computed in the SameParameter method.
2018-03-12 12:53:39 +03:00
ifv
5cbd484b7d 0029162: Geom2dInt_GInter algorithm does not find intersection of ellipse and line 2017-10-17 15:20:11 +03:00
ifv
78bb148e04 Commit for #28771 (thickshell produces wrong result) 2017-05-29 12:54:19 +03:00
ifv
e5ed77c989 Commit for #28771 2017-05-23 16:12:17 +03:00
nbv
c45a54c355 0028724: Extrema between circle and plane cannot be found
The main reason of the regression is that the Extrema algorithm finds the truth extrema point but cannot adjust it to the range of given circle. It is connected with the fact that Geom(2d)Adaptor_Curve::IsPeriodic() method returns false for given circle because adaptor contains a piece of the circle which is not closed.

New algorithm of IsPeriodic() method will return the information about periodicity of the curve itself (independently of first and last parameter of adaptor).

The documentation about Geom(2d)_TrimmedCurve and Geom_RectangularTrimmedSurface has been updated in frame of the information about IsPeriodic-methods.

(cherry picked from commit b3cba642626bf141475c6e614fdc1df5e93cfcf7)
2017-05-15 10:54:26 +03:00
nbv
b8e5ce678e 0028725: Degradation in performance of BRepExtrema_DistShapeShape
If Curve-Curve-Extrema algorithm returned small number of extremas then unification of every extrema will been made as it was made before the patch #27665 (without Cell-filter).
2017-05-15 10:54:24 +03:00
emv
ece2d8b143 0028683: Wrong result of CUT operation
1. Partial porting of the patches for the issues #0026738 and #0028017:
   Careful treatment of the SD vertices created on the Face/Face intersection stage.

2. Avoid creation of the small section edges.

3. Test case for the issue.

4. Adjusting test cases for current behavior.
2017-04-28 12:12:46 +03:00
nbv
52e7e5b5fd Fix for issue #28491 2017-03-02 12:02:19 +03:00
ifv
73b74714ee Commit for SENR-17-065: wrong calculation of sprops for face
Fix bug in expressions for calculation of inertia moments Ixx, Iyy, Izz in both methods
GProp_SGProps::Compute(...)
2017-02-28 13:07:02 +03:00
nbv
4a258f6654 Patch for the issue #28373. 2017-01-20 11:12:10 +03:00
msv
5d989d42c5 0027862: Exception in BRepOffsetAPI_MakePipeShell
Check if the shape is not null before querying its ShapeType.
2016-09-12 10:21:53 +03:00
nbv
861f38f969 Fix for issue #27665 2016-07-25 13:06:02 +03:00
nbv
d6e98f99a7 Line-Plane extrema has been added in analytical case. 2016-07-18 11:28:26 +03:00
ifv
2a56652429 0026038: Wrong result done by extrema for the circle and plane
Test cases for issue CR26038

(cherry picked from commit 9dfbbfe673)
2016-07-18 10:22:45 +03:00
ifv
67b1b0e720 0027679: Wrong offset: overlapping edges, regression comparing with OCCT670 2016-07-15 10:58:28 +03:00
nbv
5c64b759be Porting the fix for issue #27664 2016-07-14 17:27:09 +03:00
gka
373f8e8b7c 0026485: Problem with the normals of a triangulated shape
Use gp::Resolution() instead of Precision::SquareConfustion() in order to normalize normal vectors according to implementation of gp_Vec::Normalize().
2016-02-25 16:41:05 +03:00
nbv
dd65d9dff5 0026841: Boolean operation "bsection" produce invalid result on the attached cases
Porting the fix to OCCT 6.7.0
2015-12-14 17:14:52 +03:00
msv
2748a46ef7 Correct test case bugs fclasses bug23237 to make it stable. 2015-09-30 17:05:52 +03:00
pkv
571d2d532b 0026619: Tolerances of operands are modified using bop
The fix forces creation of new sub-shapes (vertex, edge) when the tolerance of some sub-shape of an argument is to be increased.

This new behavior is turned off by default. It can be turned on using two ways:
1) Setting 'locking' flag of the arguments.
2) Calling the method SetNonDestructive(Standard_True) of the class BOPAlgo_PaveFiller.
2015-09-30 17:05:51 +03:00
nbv
d5eff06bb0 0026496: Error in use the BRepCheck_Analyzer
Implementation Propagate() function from MASTER (in BRepCheck_Wire)
2015-07-29 13:59:44 +03:00
emv
bc6903b48c 0026444: Boolean operation "bcut" gives invalid result between solid and halfspace solid.
Patch for version 670 of OCCT (Git branch CR0_670_FixS).

class BOPAlgo_PaveFiller
method void BOPAlgo_PaveFiller::PutPaveOnCurve
    (const Standard_Integer nV,
     const Standard_Real aTolR3D,
     BOPDS_Curve& aNC,
     const BOPCol_MapOfInteger& aMI,
     BOPCol_DataMapOfIntegerReal& aMVTol,
     const Standard_Integer iCheckExtend)

Do not put the pave on the curve in case if there is already one with the same parameter.
Update tolerance of the existing vertex to reach the new one.

Added test case bugs/modalg_6/bug26444.
2015-07-27 15:32:24 +03:00
gka
00d4616755 Patch for Bug #73"Error of compilation of the OCCT products for 6.7.0.
Method SetValues() with previous list of arguments was added for compatibility
2015-04-07 19:22:24 +03:00
msv
3e056d8e98 0025876: Geom2dAPI_InterCurveCurve returns only one intersection point instead of two intersection points
Extend domain of circle to include all possible solutions.
Test case for issue CR25876
Period 'jump" handling algorithm changed.
2015-03-11 09:11:48 +03:00
ifv
f175c53445 Fix regressions (see #25729 for details) 2015-02-17 11:03:23 +03:00
nbv
b2435ed8e2 Test case for this issue is updated 2015-02-05 17:41:19 +03:00
nbv
859eb523ce 0025772: Boolean operation produces invalid result after patch for 0025416
Patch for bug #0025416 and #0025697

Test cases for the issue #25416 and #25697 have been added.
New test case for this issue has been created.
2015-02-05 13:28:10 +03:00
ifv
967b56d5d8 Fix for 3d offset algorithm 2015-02-02 16:00:19 +03:00
ifv
fda01cadb2 Commit for 2d offset algorithm 2015-02-02 15:58:21 +03:00
nbv
b11453f54f 0025374: [6.8.0beta regression] gp_Trsf2d::SetMirror() looses transformation form
1. Elements of gp_TrsfForm have been documented
2. gp_Trsf2d class has been reverted to non-regression case.

Update of test-cases

Conflicts:
	src/gp/gp.cdl
	tests/de/iges_1/K3
	tests/de/iges_2/B8
	tests/de/iges_2/E6
	tests/de/iges_2/G1
2014-11-24 17:00:56 +03:00
nbv
71c8570833 0025194: It is necessary to orthogonalize transformation matrix in gp_Trsf and gp_Trsf2d classes
1. Method "SetValues()" for gp_Trsf2d class is added.
2. Method Orthogonalize for gp_Trsf2d and gp_Trsf classes was added.
3. Unused arguments from "SetValues()" method for gp_Trsf was deleted.
4. Output of AppParCurves_MultiPoint Dump  was corrected.
5. Method of right projected point choosing was corrected in ProjLib package.
6. Some test cases were changed according to their new behavior.

Conflicts:
	src/BRepFill/BRepFill_LocationLaw.cxx
	src/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx
	tests/de/iges_2/E6
2014-11-24 16:53:05 +03:00
gka
657b3ae503 New classes for BOPAlgo for patch on boolean operations from OCC version 680 2014-11-24 15:46:26 +03:00
nbv
9c77e7cc97 0025416: Wrong section curve
patch #25416 to OCCT 6.7.0
2014-10-31 11:14:55 +03:00
gka
3796cb32b2 Fix for regressions for case infinite box ( case 46) 2014-10-30 19:03:55 +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
191 changed files with 19086 additions and 11488 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

@@ -173,21 +173,30 @@ const gp_Pnt2d& AppParCurves_MultiPoint::Point2d (const Standard_Integer Index)
void AppParCurves_MultiPoint::Dump(Standard_OStream& o) const
{
o << "AppParCurves_MultiPoint dump:" << endl;
o << "It contains " << NbPoints() << " 3d points and " << NbPoints2d() <<" 2d points." << endl;
/*
if (Dimension(i) == 3) {
for (Standard_Integer j = 1; j <= tabPoint->Length(); j++) {
o << " Pole No. " << j << ": " << endl;
o << " Pole x = " << (tabPoint->Value(i)->Point(j)).X() << endl;
o << " Pole y = " << (tabPoint->Value(i)->Point(j)).Y() << endl;
o << " Pole z = " << (tabPoint->Value(i)->Point(j)).Z() << endl;
}
const Standard_Integer aNbPnts3D = NbPoints(),
aNbPnts2D = NbPoints2d();
o << "It contains " << aNbPnts3D << " 3d points and " << aNbPnts2D <<" 2d points." << endl;
if(aNbPnts3D > 0)
{
for(Standard_Integer i = tabPoint->Lower(); i <= tabPoint->Upper(); i++)
{
o << "3D-Point #" << i << endl;
o << " Pole x = " << (tabPoint->Value(i)/*->Point(j)*/).X() << endl;
o << " Pole y = " << (tabPoint->Value(i)/*->Point(j)*/).Y() << endl;
o << " Pole z = " << (tabPoint->Value(i)/*->Point(j)*/).Z() << endl;
}
else {
for (Standard_Integer j = 1; j <= tabPoint->Length(); j++) {
o << " Pole No. " << j << ": " << endl;
o << " Pole x = " << (tabPoint->Value(i)->Point2d(j)).X() << endl;
o << " Pole y = " << (tabPoint->Value(i)->Point2d(j)).Y() << endl;
}
*/
}
if(aNbPnts2D > 0)
{
for(Standard_Integer i = tabPoint2d->Lower(); i <= tabPoint2d->Upper(); i++)
{
o << "2D-Point #" << i << endl;
o << " Pole x = " << (tabPoint2d->Value(i)/*->Point2d(j)*/).X() << endl;
o << " Pole y = " << (tabPoint2d->Value(i)/*->Point2d(j)*/).Y() << endl;
}
}
}

View File

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

View File

@@ -22,9 +22,14 @@
#include <TopoDS_Compound.hxx>
#include <BRep_Builder.hxx>
#include <BOPCol_IndexedMapOfShape.hxx>
#include <BOPDS_ShapeInfo.hxx>
#include <BOPDS_DS.hxx>
#include <BOPTools_AlgoTools.hxx>
//=======================================================================
//function :
//purpose :
@@ -36,7 +41,6 @@ BOPAlgo_Builder::BOPAlgo_Builder()
myMapFence(100, myAllocator),
myPaveFiller(NULL),
myDS(NULL),
//myContext(NULL),
myEntryPoint(0),
myImages(100, myAllocator),
myShapesSD(100, myAllocator),
@@ -57,7 +61,6 @@ BOPAlgo_Builder::BOPAlgo_Builder
myMapFence(100, myAllocator),
myPaveFiller(NULL),
myDS(NULL),
//myContext(NULL),
myEntryPoint(0),
myImages(100, myAllocator),
myShapesSD(100, myAllocator),
@@ -371,18 +374,30 @@ void BOPAlgo_Builder::PerformInternal(const BOPAlgo_PaveFiller& theFiller)
PostTreat();
}
//
// myErrorStatus
//
// 0 - Ok
//
//=======================================================================
//function : PostTreat
//purpose :
//=======================================================================
void BOPAlgo_Builder::PostTreat()
{
//BRepLib::SameParameter(myShape, 1.e-7, Standard_True);
BOPTools_AlgoTools::CorrectTolerances(myShape, 0.05);
BOPTools_AlgoTools::CorrectShapeTolerances(myShape);
Standard_Integer i, aNbS;
TopAbs_ShapeEnum aType;
BOPCol_IndexedMapOfShape aMA;
if (myPaveFiller->NonDestructive()) {
// MapToAvoid
aNbS=myDS->NbSourceShapes();
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
aType=aSI.ShapeType();
if (aType==TopAbs_VERTEX ||
aType==TopAbs_EDGE||
aType==TopAbs_FACE) {
const TopoDS_Shape& aS=aSI.Shape();
aMA.Add(aS);
}
}
}
//
BOPTools_AlgoTools::CorrectTolerances(myShape, aMA, 0.05);
BOPTools_AlgoTools::CorrectShapeTolerances(myShape, aMA);
}

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

@@ -246,8 +246,6 @@ void BOPAlgo_Builder::BuildSplitFaces()
aLE.Append(aSp);
}
//
BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane (aLE, aFF);
//
// 3 Build split faces
BOPAlgo_BuilderFace& aBF=aVBF.Append1();
aBF.SetFace(aF);

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

@@ -46,6 +46,7 @@ uses
Iterator from BOPDS,
PIterator from BOPDS,
PaveBlock from BOPDS,
CommonBlock from BOPDS,
Curve from BOPDS,
IndexedDataMapOfShapeCoupleOfPaveBlocks from BOPDS,
MapOfPaveBlock from BOPDS,
@@ -123,6 +124,11 @@ is
TreatVerticesEE(me:out)
is protected;
MakeSDVerticesFF(me:out;
theDMVLV: DataMapOfIntegerListOfInteger from BOPCol;
theDMNewSD: out DataMapOfIntegerInteger from BOPCol)
is protected;
MakeSplitEdges(me:out)
is protected;
@@ -131,7 +137,13 @@ is
MakePCurves(me:out)
is protected;
MakeSDVertices(me:out;
theVertIndices : ListOfInteger from BOPCol;
theAddInterfs : Boolean from Standard = Standard_True)
returns Integer from Standard
is protected;
ProcessDE(me:out)
is protected;
@@ -179,7 +191,8 @@ is
nF2 : Integer from Standard;
theMI : MapOfInteger from BOPCol;
theMVEF : MapOfInteger from BOPCol;
theMVTol : out DataMapOfIntegerReal from BOPCol)
theMVTol : out DataMapOfIntegerReal from BOPCol;
aDMVLV : out DataMapOfIntegerListOfInteger from BOPCol)
is protected;
---Purpose:
-- Checks and puts paves from <theMVOn> on the curve <theNC>.
@@ -270,7 +283,8 @@ is
theNC : out Curve from BOPDS;
theMI : MapOfInteger from BOPCol;
theMVEF : MapOfInteger from BOPCol;
theMVTol : out DataMapOfIntegerReal from BOPCol)
theMVTol : out DataMapOfIntegerReal from BOPCol;
aDMVLV : out DataMapOfIntegerListOfInteger from BOPCol)
is protected;
---Purpose:
-- Checks and puts paves created in EF intersections on the curve <theNC>.
@@ -281,7 +295,8 @@ is
theMI : MapOfInteger from BOPCol;
theNC : out Curve from BOPDS;
theMVStick : MapOfInteger from BOPCol;
theMVTol : out DataMapOfIntegerReal from BOPCol)
theMVTol : out DataMapOfIntegerReal from BOPCol;
aDMVLV : out DataMapOfIntegerListOfInteger from BOPCol)
is protected;
---Purpose:
-- Puts stick paves on the curve <theNC>
@@ -322,6 +337,7 @@ is
theNC : out Curve from BOPDS;
theMI : MapOfInteger from BOPCol;
theMVTol : out DataMapOfIntegerReal from BOPCol;
aDMVLV : out DataMapOfIntegerListOfInteger from BOPCol;
aType : Integer from Standard = 0)
is protected;
---Purpose:
@@ -377,12 +393,6 @@ is
is protected;
---Purpose:
-- Keeps data for post treatment
RefineFaceInfoOn(me:out)
is protected;
---Purpose:
-- Refines the state On for the all faces having
-- state information
UpdateFaceInfo(me:out;
theDME:out DataMapOfPaveBlockListOfPaveBlock from BOPDS)
@@ -435,12 +445,67 @@ is
---Purpose:
-- Updates pave blocks which have the paves with indices contained
-- in the map <theDMI>.
UpdateVertex(me:out;
nV : Integer from Standard;
aTolNew: Real from Standard)
returns Integer from Standard
is protected;
---Purpose:
-- Updates tolerance vertex nV due to V/E interference;
-- It always creates new vertex if nV is from arguments
-- Returns: DS index of updated vertex.
ComputeTolerance(me:out;
theCB:CommonBlock from BOPDS)
returns Real from Standard
is protected;
UpdatePaveBlocksWithSDVertices(me:out)
is protected;
UpdateCommonBlocksWithSDVertices (me:out)
is protected;
UpdateBlocksWithSharedVertices (me:out)
is protected;
EstimatePaveOnCurve (me:out;
nV : Integer from Standard;
theNC : out Curve from BOPDS;
theTolR3D : Real from Standard)
returns Boolean from Standard
is protected;
UpdateEdgeTolerance(me:out;
nE : Integer from Standard;
aTolNew: Real from Standard)
is protected;
SetNonDestructive(me:out;
theFlag:Boolean from Standard)
is protected;
SetNonDestructive(me:out)
is protected;
NonDestructive(me)
returns Boolean from Standard;
SetIsPrimary(me:out;
theFlag:Boolean from Standard)
is protected;
IsPrimary(me)
returns Boolean from Standard
is protected;
fields
myArguments : ListOfShape from BOPCol is protected;
myDS : PDS from BOPDS is protected;
myIterator : PIterator from BOPDS is protected;
myContext : Context from BOPInt is protected;
mySectionAttribute : SectionAttribute from BOPAlgo is protected;
myNonDestructive : Boolean from Standard is protected;
myIsPrimary : Boolean from Standard is protected;
end PaveFiller;

View File

@@ -27,37 +27,74 @@
//function :
//purpose :
//=======================================================================
BOPAlgo_PaveFiller::BOPAlgo_PaveFiller()
BOPAlgo_PaveFiller::BOPAlgo_PaveFiller()
:
BOPAlgo_Algo()
{
myDS=NULL;
myIterator=NULL;
myNonDestructive=Standard_False;
myIsPrimary=Standard_True;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_PaveFiller::BOPAlgo_PaveFiller(const Handle(NCollection_BaseAllocator)& theAllocator)
BOPAlgo_PaveFiller::BOPAlgo_PaveFiller
(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_Algo(theAllocator)
{
myDS=NULL;
myIterator=NULL;
myNonDestructive=Standard_False;
myIsPrimary=Standard_True;
}
//=======================================================================
//function : ~
//purpose :
//=======================================================================
BOPAlgo_PaveFiller::~BOPAlgo_PaveFiller()
BOPAlgo_PaveFiller::~BOPAlgo_PaveFiller()
{
Clear();
}
//=======================================================================
//function : SetNonDestructive
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::SetNonDestructive(const Standard_Boolean bFlag)
{
myNonDestructive=bFlag;
}
//=======================================================================
//function : NonDestructive
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_PaveFiller::NonDestructive()const
{
return myNonDestructive;
}
//=======================================================================
//function : SetIsPrimary
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::SetIsPrimary(const Standard_Boolean bFlag)
{
myIsPrimary=bFlag;
}
//=======================================================================
//function : IsPrimary
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_PaveFiller::IsPrimary()const
{
return myIsPrimary;
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::Clear()
void BOPAlgo_PaveFiller::Clear()
{
if (myIterator) {
delete myIterator;
@@ -73,7 +110,7 @@
//function : DS
//purpose :
//=======================================================================
const BOPDS_DS& BOPAlgo_PaveFiller::DS()
const BOPDS_DS& BOPAlgo_PaveFiller::DS()
{
return *myDS;
}
@@ -81,7 +118,7 @@
//function : PDS
//purpose :
//=======================================================================
BOPDS_PDS BOPAlgo_PaveFiller::PDS()
BOPDS_PDS BOPAlgo_PaveFiller::PDS()
{
return myDS;
}
@@ -89,7 +126,7 @@
//function : Context
//purpose :
//=======================================================================
Handle(BOPInt_Context) BOPAlgo_PaveFiller::Context()
Handle(BOPInt_Context) BOPAlgo_PaveFiller::Context()
{
return myContext;
}
@@ -97,7 +134,8 @@
//function : SectionAttribute
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::SetSectionAttribute(const BOPAlgo_SectionAttribute& theSecAttr)
void BOPAlgo_PaveFiller::SetSectionAttribute
(const BOPAlgo_SectionAttribute& theSecAttr)
{
mySectionAttribute = theSecAttr;
}
@@ -105,7 +143,7 @@
//function : SetArguments
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::SetArguments(const BOPCol_ListOfShape& theLS)
void BOPAlgo_PaveFiller::SetArguments(const BOPCol_ListOfShape& theLS)
{
myArguments=theLS;
}
@@ -113,7 +151,7 @@
//function : Arguments
//purpose :
//=======================================================================
const BOPCol_ListOfShape& BOPAlgo_PaveFiller::Arguments()const
const BOPCol_ListOfShape& BOPAlgo_PaveFiller::Arguments()const
{
return myArguments;
}
@@ -121,7 +159,7 @@
// function: Init
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::Init()
void BOPAlgo_PaveFiller::Init()
{
myErrorStatus=0;
//
@@ -132,6 +170,7 @@
//
// 0 Clear
Clear();
//
// 1.myDS
myDS=new BOPDS_DS(myAllocator);
@@ -145,6 +184,9 @@
//
// 3 myContext
myContext=new BOPInt_Context;
//
// 4 NonDestructive flag
SetNonDestructive();
//
myErrorStatus=0;
}
@@ -152,7 +194,7 @@
// function: Perform
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::Perform()
void BOPAlgo_PaveFiller::Perform()
{
myErrorStatus=0;
//
@@ -171,27 +213,26 @@
return;
}
//
UpdatePaveBlocksWithSDVertices();
myDS->UpdatePaveBlocks();
// 11
PerformEE();
if (myErrorStatus) {
return;
}
UpdatePaveBlocksWithSDVertices();
// 02
PerformVF();
if (myErrorStatus) {
return;
}
UpdatePaveBlocksWithSDVertices();
// 12
PerformEF();
if (myErrorStatus) {
return;
}
//
MakeSplitEdges();
if (myErrorStatus) {
return;
}
UpdatePaveBlocksWithSDVertices();
//
// 22
PerformFF();
@@ -199,12 +240,22 @@
return;
}
//
UpdateBlocksWithSharedVertices();
//
MakeSplitEdges();
if (myErrorStatus) {
return;
}
//
UpdatePaveBlocksWithSDVertices();
//
MakeBlocks();
if (myErrorStatus) {
return;
}
//
RefineFaceInfoOn();
myDS->ReleasePaveBlocks();
myDS->RefineFaceInfoOn();
//
MakePCurves();
if (myErrorStatus) {
@@ -215,5 +266,5 @@
if (myErrorStatus) {
return;
}
//
}

View File

@@ -22,20 +22,26 @@
#include <Bnd_Box.hxx>
#include <BRep_TVertex.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRepBndLib.hxx>
#include <BOPCol_DataMapOfIntegerInteger.hxx>
#include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
#include <BOPCol_MapOfInteger.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPDS_DS.hxx>
#include <BOPDS_Iterator.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPDS_VectorOfInterfVV.hxx>
#include <BOPDS_ShapeInfo.hxx>
#include <BOPAlgo_Tools.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPAlgo_Tools.hxx>
//=======================================================================
// function: PerformVV
@@ -44,12 +50,8 @@
void BOPAlgo_PaveFiller::PerformVV()
{
Standard_Boolean bWithSubShape;
Standard_Integer n1, n2, iFlag, nX, n, aSize, i, aNbVV, j, iX, k, aNbBlocks;
Standard_Integer n1, n2, iFlag, aSize, k, aNbBlocks;
Handle(NCollection_IncAllocator) aAllocator;
BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItMILI;
BOPCol_ListIteratorOfListOfInteger aItLI, aItLI2;
TopoDS_Vertex aVn;
BOPDS_ShapeInfo aSIn;
//
myErrorStatus=0;
//
@@ -59,8 +61,6 @@
return;
}
//
aSIn.SetShapeType(TopAbs_VERTEX);
BOPDS_VectorOfInterfVV& aVVs=myDS->InterfVV();
aVVs.SetStartSize(aSize);
aVVs.SetIncrement(aSize);
@@ -70,7 +70,6 @@
aAllocator=new NCollection_IncAllocator();
BOPCol_IndexedDataMapOfIntegerListOfInteger aMILI(100, aAllocator);
BOPCol_DataMapOfIntegerListOfInteger aMBlocks(100, aAllocator);
BOPCol_ListOfShape aLV(aAllocator);
//
// 1. Map V/LV
for (; myIterator->More(); myIterator->Next()) {
@@ -93,49 +92,97 @@
for (k=0; k<aNbBlocks; ++k) {
const BOPCol_ListOfInteger& aLI=aMBlocks.Find(k);
//
aLV.Clear();
aItLI.Initialize(aLI);
for (; aItLI.More(); aItLI.Next()) {
nX=aItLI.Value();
const TopoDS_Shape& aV=myDS->Shape(nX);
aLV.Append(aV);
}
//
BOPTools_AlgoTools::MakeVertex(aLV, aVn);
//
// Appennd new vertex to the DS
aSIn.SetShape(aVn);
n=myDS->Append(aSIn);
//
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(n);
Bnd_Box& aBox=aSIDS.ChangeBox();
BRepBndLib::Add(aVn, aBox);
//
// Fill ShapesSD
aItLI.Initialize(aLI);
for (i=0; aItLI.More(); aItLI.Next(), ++i) {
n1=aItLI.Value();
myDS->AddShapeSD(n1, n);
//
aItLI2.Initialize(aLI);
for (j=0; aItLI2.More(); aItLI2.Next(), ++j) {
if (j>i) {
n2=aItLI2.Value();
//
myDS->AddInterf(n1, n2);
iX=aVVs.Append()-1;
BOPDS_InterfVV& aVV=aVVs(iX);
aVV.SetIndices(n1, n2);
aVV.SetIndexNew(n);
}
}
}
MakeSDVertices(aLI);
}
//
BOPCol_DataMapIteratorOfDataMapOfIntegerInteger aItDMII;
//
BOPCol_DataMapOfIntegerInteger& aDMII=myDS->ShapesSD();
aItDMII.Initialize(aDMII);
for (; aItDMII.More(); aItDMII.Next()) {
n1=aItDMII.Key();
myDS->InitPaveBlocksForVertex(n1);
}
aNbVV=aVVs.Extent();
//
//-----------------------------------------------------scope t
aLV.Clear();
aMBlocks.Clear();
aMILI.Clear();
aAllocator.Nullify();
}
//=======================================================================
// function: MakeSDVertices
// purpose:
//=======================================================================
Standard_Integer BOPAlgo_PaveFiller::MakeSDVertices
(const BOPCol_ListOfInteger& theVertIndices,
const Standard_Boolean theAddInterfs)
{
TopoDS_Vertex aVSD, aVn;
Standard_Integer nSD = -1;
BOPCol_ListIteratorOfListOfInteger aItLI(theVertIndices);
BOPCol_ListOfShape aLV;
for (; aItLI.More(); aItLI.Next()) {
Standard_Integer nX = aItLI.Value(), nSD1;
if (myDS->HasShapeSD(nX, nSD1)) {
const TopoDS_Shape& aVSD1 = myDS->Shape(nSD1);
if (nSD == -1) {
aVSD = TopoDS::Vertex(aVSD1);
nSD = nSD1;
}
else {
aLV.Append(aVSD1);
}
}
const TopoDS_Shape& aV = myDS->Shape(nX);
aLV.Append(aV);
}
BOPTools_AlgoTools::MakeVertex(aLV, aVn);
Standard_Integer nV;
if (nSD != -1) {
// update old SD vertex with new value
Handle(BRep_TVertex)& aTVertex =
reinterpret_cast<Handle(BRep_TVertex)&>(const_cast<Handle(TopoDS_TShape)&>(aVSD.TShape()));
aTVertex->Pnt(BRep_Tool::Pnt(aVn));
aTVertex->Tolerance(BRep_Tool::Tolerance(aVn));
aVn = aVSD;
nV = nSD;
}
else {
// Append new vertex to the DS
BOPDS_ShapeInfo aSIn;
aSIn.SetShapeType(TopAbs_VERTEX);
aSIn.SetShape(aVn);
nV = myDS->Append(aSIn);
}
BOPDS_ShapeInfo& aSIDS = myDS->ChangeShapeInfo(nV);
Bnd_Box& aBox = aSIDS.ChangeBox();
BRepBndLib::Add(aVn, aBox);
aBox.SetGap(aBox.GetGap());
//
// Fill ShapesSD
BOPDS_VectorOfInterfVV& aVVs = myDS->InterfVV();
if (theAddInterfs)
aVVs.SetIncrement(theVertIndices.Extent());
//
aItLI.Initialize(theVertIndices);
for (; aItLI.More(); aItLI.Next()) {
Standard_Integer n1 = aItLI.Value();
myDS->AddShapeSD(n1, nV);
//
if (theAddInterfs) {
BOPCol_ListIteratorOfListOfInteger aItLI2 = aItLI;
aItLI2.Next();
for (; aItLI2.More(); aItLI2.Next()) {
Standard_Integer n2 = aItLI2.Value();
//
myDS->AddInterf(n1, n2);
//
Standard_Integer iX = aVVs.Append() - 1;
BOPDS_InterfVV& aVV = aVVs(iX);
aVV.SetIndices(n1, n2);
aVV.SetIndexNew(nV);
}
}
}
return nV;
}

View File

@@ -0,0 +1,241 @@
// Created by: Peter KURNEV
// Copyright (c) 2010-2014 OPEN CASCADE SAS
// Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
// EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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
// 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.
#include <BOPAlgo_PaveFiller.ixx>
#include <Precision.hxx>
#include <gp_Pnt.hxx>
#include <Bnd_Box.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepBndLib.hxx>
#include <BOPDS_ShapeInfo.hxx>
#include <BOPDS_VectorOfListOfPaveBlock.hxx>
#include <BOPDS_MapOfCommonBlock.hxx>
#include <BOPDS_ListOfPaveBlock.hxx>
#include <BOPDS_CommonBlock.hxx>
#include <BOPDS_DS.hxx>
//=======================================================================
//function : SetNonDestructive
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::SetNonDestructive()
{
if (!myIsPrimary) {
return;
}
//
Standard_Boolean bFlag;
BOPCol_ListIteratorOfListOfShape aItLS;
//
bFlag=Standard_False;
aItLS.Initialize(myArguments);
for(; aItLS.More() && (!bFlag); aItLS.Next()) {
const TopoDS_Shape& aS=aItLS.Value();
bFlag=aS.Locked();
}
myNonDestructive=bFlag;
}
//=======================================================================
//function : UpdateEdgeTolerance
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::UpdateEdgeTolerance (const Standard_Integer nE,
const Standard_Real aTol)
{
Standard_Boolean bIsNewShape, bHasShapeSD;
Standard_Integer nV, nVx;
Standard_Real aTolV;
BRep_Builder aBB;
BOPCol_ListIteratorOfListOfInteger aIt;
//
BOPDS_ShapeInfo& aSIE=myDS->ChangeShapeInfo(nE);
const BOPCol_ListOfInteger& aLI=aSIE.SubShapes();
//
if (myNonDestructive) {
bIsNewShape=myDS->IsNewShape(nE);
if (!bIsNewShape) {
return;
}
//
aIt.Initialize(aLI);
for (; aIt.More(); aIt.Next()) {
nV = aIt.Value();
bHasShapeSD=myDS->HasShapeSD(nV, nVx);
if (bHasShapeSD) {
continue;
}
bIsNewShape=myDS->IsNewShape(nV);
if (!bIsNewShape) {
return;
}
}
}
//
const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE);
aBB.UpdateEdge(aE, aTol);
Bnd_Box& aBoxE=aSIE.ChangeBox();
BRepBndLib::Add(aE, aBoxE);
//
aIt.Initialize(aLI);
for (; aIt.More(); aIt.Next()) {
nV = aIt.Value();
bHasShapeSD=myDS->HasShapeSD(nV, nVx);
if (bHasShapeSD) {
nV=nVx;
}
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
aTolV = BRep_Tool::Tolerance(aV);
if (aTolV < aTol) {
aBB.UpdateVertex(aV, aTol);
BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nV);
Bnd_Box& aBoxV = aSIV.ChangeBox();
BRepBndLib::Add(aV, aBoxV);
}
}
}
//=======================================================================
//function : UpdateVertex
//purpose :
//=======================================================================
Standard_Integer BOPAlgo_PaveFiller::UpdateVertex
(const Standard_Integer nV,
const Standard_Real aTolNew)
{
Standard_Integer nVNew;
Standard_Real aTolV;
BRep_Builder aBB;
if (!myNonDestructive) {
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
aTolV = BRep_Tool::Tolerance(aV);
if (aTolV < aTolNew) {
aBB.UpdateVertex(aV, aTolNew);
BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nV);
Bnd_Box& aBoxV = aSIV.ChangeBox();
BRepBndLib::Add(aV, aBoxV);
}
return nV;
}
//
nVNew = nV;
if (myDS->IsNewShape(nVNew) ||
myDS->HasShapeSD(nV, nVNew)) {
// nV is new vertex
const TopoDS_Vertex& aVSD = *(TopoDS_Vertex*)&myDS->Shape(nVNew);
aTolV = BRep_Tool::Tolerance(aVSD);
if (aTolV < aTolNew) {
aBB.UpdateVertex(aVSD, aTolNew);
BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nVNew);
Bnd_Box& aBoxV = aSIV.ChangeBox();
BRepBndLib::Add(aVSD, aBoxV);
}
return nVNew;
}
//
// nV is old vertex
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
aTolV = BRep_Tool::Tolerance(aV);
//
// create new vertex
TopoDS_Vertex aVNew;
gp_Pnt aPV = BRep_Tool::Pnt(aV);
aBB.MakeVertex(aVNew, aPV, Max(aTolV, aTolNew));
//
// append new vertex to DS
BOPDS_ShapeInfo aSIV;
aSIV.SetShapeType(TopAbs_VERTEX);
aSIV.SetShape(aVNew);
nVNew = myDS->Append(aSIV);
//
// bounding box for the new vertex
BOPDS_ShapeInfo& aSIDS = myDS->ChangeShapeInfo(nVNew);
Bnd_Box& aBoxDS = aSIDS.ChangeBox();
BRepBndLib::Add(aVNew, aBoxDS);
//
// add vertex to SD map
myDS->AddShapeSD(nV, nVNew);
//
myDS->InitPaveBlocksForVertex(nV);
//
return nVNew;
}
//=======================================================================
//function : UpdatePaveBlocksWithSDVertices
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::UpdatePaveBlocksWithSDVertices()
{
if (!myNonDestructive) {
return;
}
myDS->UpdatePaveBlocksWithSDVertices();
}
//=======================================================================
//function : UpdateCommonBlocksWithSDVertices
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::UpdateCommonBlocksWithSDVertices()
{
if (!myNonDestructive) {
return;
}
Standard_Integer aNbPBP;
//
BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->ChangePaveBlocksPool();
aNbPBP=aPBP.Extent();
if(!aNbPBP) {
return;
}
//
Standard_Integer i, nV1, nV2;
Standard_Real aTolV;
BOPDS_MapOfCommonBlock aMCB;
BOPDS_ListIteratorOfListOfPaveBlock aItPB;
Handle(BOPDS_PaveBlock) aPB;
//
aTolV = Precision::Confusion();
//
for (i=0; i<aNbPBP; ++i) {
BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
aItPB.Initialize(aLPB);
for (; aItPB.More(); aItPB.Next()) {
aPB=aItPB.Value();
const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
if (aCB.IsNull()) {
continue;
}
//
if (aMCB.Add(aCB)) {
myDS->SortPaveBlocks(aCB);
aPB->Indices(nV1, nV2);
UpdateVertex(nV1, aTolV);
UpdateVertex(nV2, aTolV);
myDS->UpdateCommonBlockWithSDVertices(aCB);
}
}
}
UpdatePaveBlocksWithSDVertices();
}

View File

@@ -36,15 +36,14 @@
// function: PerformVE
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::PerformVE()
void BOPAlgo_PaveFiller::PerformVE()
{
Standard_Boolean bJustAdd;
Standard_Boolean bJustAdd, bHasShapeSD;
Standard_Integer iSize, nV, nE, nVSD, iFlag, nVx, i;
Standard_Real aT, aTolE, aTolV;
Standard_Real aT, aTolVnew;
BOPDS_Pave aPave;
BOPDS_PassKey aPK;
BOPDS_MapOfPassKey aMPK;
BRep_Builder aBB;
//
myErrorStatus=0;
//
@@ -80,7 +79,8 @@
}
//
nVx=nV;
if (myDS->HasShapeSD(nV, nVSD)) {
bHasShapeSD=myDS->HasShapeSD(nV, nVSD);
if (bHasShapeSD) {
nVx=nVSD;
}
//
@@ -89,10 +89,10 @@
continue;
}
//
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape()));
const TopoDS_Vertex& aV=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&aSIE.Shape()));
const TopoDS_Vertex& aVx=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
//
iFlag=myContext->ComputeVE (aV, aE, aT);
iFlag=myContext->ComputeVE (aVx, aE, aT, aTolVnew);
if (!iFlag) {
// 1
i=aVEs.Append()-1;
@@ -101,21 +101,21 @@
aVE.SetParameter(aT);
// 2
myDS->AddInterf(nV, nE);
// 3
//
//
BOPDS_ListOfPaveBlock& aLPB=myDS->ChangePaveBlocks(nE);
Handle(BOPDS_PaveBlock)& aPB=*((Handle_BOPDS_PaveBlock*)&aLPB.First());
//
//
// 3 update vertex V/E if necessary
nVx=UpdateVertex(nV, aTolVnew);
//4
if (myDS->IsNewShape(nVx)) {
aVE.SetIndexNew(nVx);
}
//5 append ext pave to pave block
aPave.SetIndex(nVx);
aPave.SetParameter(aT);
aPB->AppendExtPave(aPave);
aTolV = BRep_Tool::Tolerance(aV);
aTolE = BRep_Tool::Tolerance(aE);
if ( aTolV < aTolE) {
aBB.UpdateVertex(aV, aTolE);
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVx);
Bnd_Box& aBoxDS=aSIDS.ChangeBox();
BRepBndLib::Add(aV, aBoxDS);
}
}
}//for (; myIterator->More(); myIterator->Next()) {
}
}

View File

@@ -59,13 +59,12 @@
#include <BOPDS_BoxBndTree.hxx>
#include <BOPAlgo_Tools.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
//=======================================================================
// function: PerformEE
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::PerformEE()
void BOPAlgo_PaveFiller::PerformEE()
{
Standard_Boolean bJustAdd, bOrder;
Standard_Integer i, iX, iSize, nE1, nE2, aDiscretize;
@@ -156,10 +155,6 @@
continue;
}
//
// -----------f
//DEBft
//printf(" nE1=%d nE2=%d\n", nE1, nE2);
//
IntTools_EdgeEdge aEdgeEdge;
//
aEdgeEdge.SetEdge1 (aE1);
@@ -220,8 +215,10 @@
aPBn2=aPB1;
}
//
IntTools_Range aR11(aPBR1.First(), aSR1.First()), aR12(aSR1.Last(), aPBR1.Last()),
aR21(aPBR2.First(), aSR2.First()), aR22(aSR2.Last(), aPBR2.Last());
IntTools_Range aR11(aPBR1.First(), aSR1.First()),
aR12(aSR1.Last(), aPBR1.Last()),
aR21(aPBR2.First(), aSR2.First()),
aR22(aSR2.Last(), aPBR2.Last());
//
const IntTools_SequenceOfCommonPrts& aCPrts=aEdgeEdge.CommonParts();
//
@@ -248,8 +245,10 @@
aPBn1->Indices(nV[0], nV[1]);
aPBn2->Indices(nV[2], nV[3]);
//
if((bIsOnPave[0] && bIsOnPave[2]) || (bIsOnPave[0] && bIsOnPave[3]) ||
(bIsOnPave[1] && bIsOnPave[2]) || (bIsOnPave[1] && bIsOnPave[3])) {
if((bIsOnPave[0] && bIsOnPave[2]) ||
(bIsOnPave[0] && bIsOnPave[3]) ||
(bIsOnPave[1] && bIsOnPave[2]) ||
(bIsOnPave[1] && bIsOnPave[3])) {
continue;
}
//
@@ -385,12 +384,12 @@
aAllocator.Nullify();
}
//=======================================================================
//function : PerformVertices
//function : PerformVerticesEE
//purpose :
//=======================================================================
Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEE
(BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB,
Handle(NCollection_BaseAllocator)& theAllocator)
Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEE
(BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB,
Handle(NCollection_BaseAllocator)& theAllocator)
{
Standard_Integer aNbV, iRet;
//
@@ -523,9 +522,9 @@
//function : TreatNewVertices
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::TreatNewVertices(
const BOPCol_IndexedDataMapOfShapeInteger& aMapVI,
BOPCol_IndexedDataMapOfShapeListOfShape& myImages)
void BOPAlgo_PaveFiller::TreatNewVertices
(const BOPCol_IndexedDataMapOfShapeInteger& aMapVI,
BOPCol_IndexedDataMapOfShapeListOfShape& myImages)
{
Standard_Integer j, i, aNbV, aNbVSD;
Standard_Real aTol;
@@ -540,7 +539,8 @@
//
BOPDS_BoxBndTreeSelector aSelector;
BOPDS_BoxBndTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
NCollection_UBTreeFiller <Standard_Integer,
Bnd_Box> aTreeFiller(aBBTree);
//
aNbV = aMapVI.Extent();
for (i=1; i<=aNbV; ++i) {
@@ -656,12 +656,11 @@
}
}
}
//=======================================================================
//function : FillShrunkData
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::FillShrunkData(Handle(BOPDS_PaveBlock)& thePB)
void BOPAlgo_PaveFiller::FillShrunkData(Handle(BOPDS_PaveBlock)& thePB)
{
Standard_Integer nE, nV1, nV2, iErr;
Standard_Real aT1, aT2, aTS1, aTS2;
@@ -706,8 +705,8 @@ void BOPAlgo_PaveFiller::ForceInterfVE(const Standard_Integer nV,
Handle(BOPDS_PaveBlock)& aPB,
BOPDS_MapOfPaveBlock& aMPBToUpdate)
{
Standard_Integer aNbPnt, nE;
gp_Pnt aP;
Standard_Integer nI, nE, nVx, nVSD, iFlag;
Standard_Real aT, aTolVNew;
//
nE = aPB->OriginalEdge();
//
@@ -724,60 +723,45 @@ void BOPAlgo_PaveFiller::ForceInterfVE(const Standard_Integer nV,
return;
}
//
if (aPB->Pave1().Index() == nV || aPB->Pave2().Index() == nV) {
if (aPB->Pave1().Index() == nV ||
aPB->Pave2().Index() == nV) {
return;
}
//
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
const TopoDS_Edge& aE = *(TopoDS_Edge*) &myDS->Shape(nE);
aP=BRep_Tool::Pnt(aV);
nVx = nV;
if (myDS->HasShapeSD(nV, nVSD)) {
nVx = nVSD;
}
//
GeomAPI_ProjectPointOnCurve& aProjector=myContext->ProjPC(aE);
aProjector.Perform(aP);
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nVx);
const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE);
//
aNbPnt = aProjector.NbPoints();
if (aNbPnt) {
Standard_Real aT, aDist;
Standard_Integer i;
BRep_Builder aBB;
iFlag = myContext->ComputeVE(aV, aE, aT, aTolVNew);
if (iFlag == 0 || iFlag == -4) {
BOPDS_Pave aPave;
//
aDist=aProjector.LowerDistance();
aT=aProjector.LowerDistanceParameter();
//
BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
i=aVEs.Append()-1;
BOPDS_InterfVE& aVE=aVEs(i);
aVEs.SetIncrement(10);
// 1
nI=aVEs.Append()-1;
BOPDS_InterfVE& aVE=aVEs(nI);
//
aVE.SetIndices(nV, nE);
aVE.SetParameter(aT);
//
// 2
myDS->AddInterf(nV, nE);
//
aBB.UpdateVertex(aV, aDist);
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV);
Bnd_Box& aBox=aSIDS.ChangeBox();
BRepBndLib::Add(aV, aBox);
//
aPave.SetIndex(nV);
// 3 update vertex V/E if necessary
nVx=UpdateVertex(nV, aTolVNew);
// 4
if (myDS->IsNewShape(nVx)) {
aVE.SetIndexNew(nVx);
}
// 5 append ext pave to pave block
aPave.SetIndex(nVx);
aPave.SetParameter(aT);
aPB->AppendExtPave(aPave);
//
aMPBToUpdate.Add(aPB);
}
}
/*
// DEBf
{
TopoDS_Compound aCx;
BRep_Builder aBBx;
aBBx.MakeCompound(aCx);
aItMVCPB.Initialize(theMVCPB);
for (; aItMVCPB.More(); aItMVCPB.Next()) {
const TopoDS_Shape& aS=aItMVCPB.Key();
aBBx.Add(aCx, aS);
}
BRepTools::Write(aCx, "cx");
}
// DEBt
*/

View File

@@ -22,8 +22,6 @@
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Face.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepBndLib.hxx>
#include <BOPCol_MapOfInteger.hxx>
@@ -41,12 +39,11 @@
// function: PerformVF
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::PerformVF()
void BOPAlgo_PaveFiller::PerformVF()
{
Standard_Boolean bJustAdd;
Standard_Integer iSize, nV, nF, nVSD, iFlag, nVx, i;
Standard_Real aT1, aT2, aTolF, aTolV;
BRep_Builder aBB;
Standard_Real aT1, aT2, aTolF, aTolV, aTolVnew;
//
myErrorStatus=0;
//
@@ -89,27 +86,29 @@
aTolV = BRep_Tool::Tolerance(aV);
aTolF = BRep_Tool::Tolerance(aF);
//
iFlag=myContext->ComputeVF(aV, aF, aT1, aT2);
if (!iFlag) {
// 1
i=aVFs.Append()-1;
BOPDS_InterfVF& aVF=aVFs(i);
aVF.SetIndices(nVx, nF);
aVF.SetUV(aT1, aT2);
// 2
myDS->AddInterf(nVx, nF);
//
BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();
aMVIn.Add(nVx);
//
if (aTolV < aTolF) {
aBB.UpdateVertex(aV, aTolF);
BOPDS_ShapeInfo& aSIV = myDS->ChangeShapeInfo(nVx);
Bnd_Box& aBoxV = aSIV.ChangeBox();
BRepBndLib::Add(aV, aBoxV);
}
iFlag=myContext->ComputeVF(aV, aF, aT1, aT2, aTolVnew);
if (iFlag) {
continue;
}
// 1
i=aVFs.Append()-1;
BOPDS_InterfVF& aVF=aVFs(i);
aVF.SetIndices(nVx, nF);
aVF.SetUV(aT1, aT2);
// 2
myDS->AddInterf(nVx, nF);
//
// 3 update vertex V/F if necessary
nVx=UpdateVertex(nVx, aTolVnew);
//
// 4
if (myDS->IsNewShape(nVx)) {
aVF.SetIndexNew(nVx);
}
// update FaceInfo
BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();
aMVIn.Add(nVx);
}// for (; myIterator->More(); myIterator->Next()) {
}// if (iSize) {
else {
@@ -122,13 +121,11 @@
//
TreatVerticesEE();
}
//=======================================================================
//function : TreatVerticesEE
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::TreatVerticesEE()
void BOPAlgo_PaveFiller::TreatVerticesEE()
{
Standard_Integer i, aNbS, aNbEEs, nF, nV, iFlag;
Standard_Real aT1, aT2;
@@ -143,7 +140,6 @@
//
myErrorStatus=0;
//
aNbS=myDS->NbSourceShapes();
//
BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();

View File

@@ -19,6 +19,8 @@
#include <NCollection_IncAllocator.hxx>
#include <Precision.hxx>
#include <Bnd_Box.hxx>
#include <TopoDS_Vertex.hxx>
@@ -53,12 +55,11 @@
#include <BRep_Builder.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
//=======================================================================
//function : PerformEF
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::PerformEF()
void BOPAlgo_PaveFiller::PerformEF()
{
Standard_Integer iSize;
//
@@ -213,11 +214,25 @@
if (bIsOnPave[j]) {
bV[j]=CheckFacePaves(nV[j], aMIFOn, aMIFIn);
if (bV[j]) {
const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV[j])));
BOPTools_AlgoTools::UpdateVertex(aE, aT, aV);
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV[j]);
Bnd_Box& aBoxDS=aSIDS.ChangeBox();
BRepBndLib::Add(aV, aBoxDS);
const TopoDS_Vertex& aV =
(*(TopoDS_Vertex *)(&myDS->Shape(nV[j])));
//
Standard_Real f, l, aTolVnew, aDistPP, aTolPC, aTolV;
//
const Handle(Geom_Curve)& aCur = BRep_Tool::Curve(aE, f, l);
//
gp_Pnt aP1 = BRep_Tool::Pnt(aV);
gp_Pnt aP2 = aCur->Value(aT);
//
aDistPP=aP1.Distance(aP2);
aTolPC=Precision::PConfusion();
aTolV=BRep_Tool::Tolerance(aV);
if (aDistPP > (aTolV+aTolPC)) {
aTolVnew=Max(aTolE, aDistPP);
UpdateVertex(nV[j], aTolVnew);
}
}
else {
bIsOnPave[j] = ForceInterfVF(nV[j], nF);
@@ -268,11 +283,6 @@
myDS->AddInterf(nE, nF);
break;
}
//update tolerance of edge if needed
if (aTolE < aTolF) {
myDS->UpdateEdgeTolerance(nE, aTolF);
aTolE = aTolF;
}
aEF.SetCommonPart(aCPart);
// 2
myDS->AddInterf(nE, nF);
@@ -302,24 +312,19 @@
nF=aItMI.Value();
myDS->UpdateFaceInfoIn(nF);
}
// Refine FaceInfoOn to remove all formal pave blocks
// made during EF processing
//myDS->RefineFaceInfoOn();
//-----------------------------------------------------scope t
aMIEFC.Clear();
aMVCPB.Clear();
aMPBLI.Clear();
aAllocator.Nullify();
//
}
//=======================================================================
//function : PerformVertices1
//purpose :
//=======================================================================
Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEF
(BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB,
Handle(NCollection_BaseAllocator)& theAllocator)
Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEF
(BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB,
Handle(NCollection_BaseAllocator)& theAllocator)
{
Standard_Integer aNbV, iRet;
//
@@ -353,6 +358,8 @@
}
//
// 2 Fuse vertices
aPF.SetIsPrimary(Standard_False);
aPF.SetNonDestructive(myNonDestructive);
aPF.SetArguments(aLS);
aPF.Perform();
iErr=aPF.ErrorStatus();
@@ -432,7 +439,7 @@
}
}
}
// 6 Split PaveBlocksa
// 6 Split PaveBlocks
for (i=1; i<=aNbPBLI; ++i) {
Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i);
nE=aPB->OriginalEdge();
@@ -452,9 +459,10 @@
// function: CheckFacePaves
// purpose:
//=======================================================================
Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves (const Standard_Integer nVx,
const BOPCol_MapOfInteger& aMIFOn,
const BOPCol_MapOfInteger& aMIFIn)
Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves
(const Standard_Integer nVx,
const BOPCol_MapOfInteger& aMIFOn,
const BOPCol_MapOfInteger& aMIFIn)
{
Standard_Boolean bRet;
Standard_Integer nV;
@@ -485,8 +493,9 @@
// function: CheckFacePaves
// purpose:
//=======================================================================
Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves (const TopoDS_Vertex& aVnew,
const BOPCol_MapOfInteger& aMIF)
Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves
(const TopoDS_Vertex& aVnew,
const BOPCol_MapOfInteger& aMIF)
{
Standard_Boolean bRet;
Standard_Integer nV, iFlag;
@@ -510,50 +519,43 @@
//function : ForceInterfVF
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_PaveFiller::ForceInterfVF(const Standard_Integer nV,
const Standard_Integer nF)
Standard_Boolean BOPAlgo_PaveFiller::ForceInterfVF
(const Standard_Integer nV,
const Standard_Integer nF)
{
Standard_Boolean bRet;
Standard_Integer iFlag, nI, nVx;
Standard_Real U, V, aTolVNew;
//
bRet = Standard_False;
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
const TopoDS_Face& aF = *(TopoDS_Face*) &myDS->Shape(nF);
//
GeomAPI_ProjectPointOnSurf& aProj = myContext->ProjPS(aF);
const gp_Pnt& aP = BRep_Tool::Pnt(aV);
aProj.Perform(aP);
if (!aProj.IsDone()) {
return bRet;
}
Standard_Real aDist, U, V;
//
aDist=aProj.LowerDistance();
aProj.LowerDistanceParameters(U, V);
//
gp_Pnt2d aP2d(U, V);
bRet = myContext->IsPointInFace (aF, aP2d);
if (bRet) {
Standard_Integer i;
BRep_Builder aBB;
iFlag = myContext->ComputeVF(aV, aF, U, V, aTolVNew);
if (iFlag == 0 || iFlag == -2) {
bRet=!bRet;
//
BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF();
i=aVFs.Append()-1;
BOPDS_InterfVF& aVF=aVFs(i);
aVFs.SetIncrement(10);
// 1
nI=aVFs.Append()-1;
BOPDS_InterfVF& aVF=aVFs(nI);
//
aVF.SetIndices(nV, nF);
aVF.SetUV(U, V);
//
// 2
myDS->AddInterf(nV, nF);
//
aBB.UpdateVertex(aV, aDist);
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV);
Bnd_Box& aBoxDS=aSIDS.ChangeBox();
BRepBndLib::Add(aV, aBoxDS);
// 3 update vertex V/F if necessary
nVx=UpdateVertex(nV, aTolVNew);
// 4
if (myDS->IsNewShape(nVx)) {
aVF.SetIndexNew(nVx);
}
//
BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
BOPCol_MapOfInteger& aMVIn=aFI.ChangeVerticesIn();
aMVIn.Add(nV);
aMVIn.Add(nVx);
}
//
return bRet;
}

View File

@@ -62,6 +62,7 @@
#include <BOPCol_ListOfInteger.hxx>
#include <BOPCol_IndexedMapOfInteger.hxx>
#include <BOPCol_DataMapOfIntegerReal.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BOPInt_Context.hxx>
#include <BOPInt_Tools.hxx>
@@ -94,6 +95,7 @@ static void ToleranceFF(const BRepAdaptor_Surface& aBAS1,
const BRepAdaptor_Surface& aBAS2,
Standard_Real& aTolFF);
//=======================================================================
//function : PerformFF
//purpose :
@@ -138,22 +140,21 @@ void BOPAlgo_PaveFiller::PerformFF()
const TopoDS_Face& aF1=(*(TopoDS_Face *)(&myDS->Shape(nF1)));
const TopoDS_Face& aF2=(*(TopoDS_Face *)(&myDS->Shape(nF2)));
//
if (aMI.Add(nF1)) {
myDS->UpdateFaceInfoOn(nF1);
myDS->UpdateFaceInfoIn(nF1);
}
if (aMI.Add(nF2)) {
myDS->UpdateFaceInfoOn(nF2);
myDS->UpdateFaceInfoIn(nF2);
}
//
aBAS1.Initialize(aF1, Standard_False);
aBAS2.Initialize(aF2, Standard_False);
//
if (aBAS1.GetType() == GeomAbs_Plane &&
aBAS2.GetType() == GeomAbs_Plane) {
Standard_Boolean bToIntersect;
//
if (aMI.Add(nF1)) {
myDS->UpdateFaceInfoOn(nF1);
myDS->UpdateFaceInfoIn(nF1);
}
if (aMI.Add(nF2)) {
myDS->UpdateFaceInfoOn(nF2);
myDS->UpdateFaceInfoIn(nF2);
}
//
bToIntersect = CheckPlanes(nF1, nF2);
if (!bToIntersect) {
myDS->AddInterf(nF1, nF2);
@@ -292,7 +293,8 @@ void BOPAlgo_PaveFiller::MakeBlocks()
BOPDS_DataMapOfPaveBlockListOfPaveBlock aDMExEdges(100, aAllocator);
BOPCol_DataMapOfIntegerReal aMVTol(100, aAllocator);
BOPCol_DataMapIteratorOfDataMapOfIntegerReal aItMV;
BOPCol_DataMapOfIntegerInteger aDMI(100, aAllocator);
BOPCol_DataMapOfIntegerInteger aDMNewSD(100, aAllocator);
BOPCol_DataMapOfIntegerListOfInteger aDMVLV;
//
for (i=0; i<aNbFF; ++i) {
BOPDS_InterfFF& aFF=aFFs(i);
@@ -319,7 +321,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
if (aMF.Add(nF2)) {
myDS->UpdateFaceInfoOn(nF2);
}
//
BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
//
@@ -360,12 +362,12 @@ void BOPAlgo_PaveFiller::MakeBlocks()
// DEBt
aNC.InitPaveBlock1();
//
PutPavesOnCurve(aMVOnIn, aTolR3D, aNC, nF1, nF2, aMI, aMVEF, aMVTol);
PutPavesOnCurve(aMVOnIn, aTolR3D, aNC, nF1, nF2, aMI, aMVEF, aMVTol, aDMVLV);
//
PutStickPavesOnCurve(aF1, aF2, aMI, aNC, aMVStick, aMVTol);
PutStickPavesOnCurve(aF1, aF2, aMI, aNC, aMVStick, aMVTol, aDMVLV);
//904/F7
if (aNbC == 1) {
PutEFPavesOnCurve(aNC, aMI, aMVEF, aMVTol);
PutEFPavesOnCurve(aNC, aMI, aMVEF, aMVTol, aDMVLV);
}
//
if (aIC.HasBounds()) {
@@ -422,10 +424,11 @@ void BOPAlgo_PaveFiller::MakeBlocks()
const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE);
aTolE = BRep_Tool::Tolerance(aE);
if (aTolR3D > aTolE) {
myDS->UpdateEdgeTolerance(nE, aTolR3D);
UpdateEdgeTolerance(nE, aTolR3D);
}
bInBothFaces = Standard_False;
} else {
}
else {
bInBothFaces = (aFI1.PaveBlocksOn().Contains(aPBOut) ||
aFI1.PaveBlocksIn().Contains(aPBOut))&&
(aFI2.PaveBlocksOn().Contains(aPBOut) ||
@@ -477,15 +480,26 @@ void BOPAlgo_PaveFiller::MakeBlocks()
aTol = aItMV.Value();
//
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV1);
const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*)&aV.TShape());
const Handle(BRep_TVertex)& TV =
*((Handle(BRep_TVertex)*)&aV.TShape());
TV->Tolerance(aTol);
// reset bnd box
BOPDS_ShapeInfo& aSIDS = myDS->ChangeShapeInfo(nV1);
Bnd_Box& aBoxDS = aSIDS.ChangeBox();
aBoxDS = Bnd_Box();
BRepBndLib::Add(aV, aBoxDS);
aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion());
//
if (aDMVLV.IsBound(nV1))
aDMVLV.UnBind(nV1);
}
//
ProcessExistingPaveBlocks(i, aMPBOnIn, aMSCPB, aMVI, aMVB, aMPBAdd);
}//for (i=0; i<aNbFF; ++i) {
//
// post treatment
myErrorStatus=PostTreatFF(aMSCPB, aMVI, aDMExEdges, aDMI, aAllocator);
MakeSDVerticesFF(aDMVLV, aDMNewSD);
myErrorStatus=PostTreatFF(aMSCPB, aMVI, aDMExEdges, aDMNewSD, aAllocator);
if (myErrorStatus) {
return;
}
@@ -493,7 +507,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
// update face info
UpdateFaceInfo(aDMExEdges);
//Update all pave blocks
UpdatePaveBlocks(aDMI);
UpdatePaveBlocks(aDMNewSD);
//-----------------------------------------------------scope t
aMF.Clear();
aMVStick.Clear();
@@ -501,19 +515,43 @@ void BOPAlgo_PaveFiller::MakeBlocks()
aMVOnIn.Clear();
aDMExEdges.Clear();
aMI.Clear();
aDMI.Clear();
aDMNewSD.Clear();
aAllocator.Nullify();
}
//=======================================================================
//function : MakeSDVerticesFF
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::MakeSDVerticesFF
(const BOPCol_DataMapOfIntegerListOfInteger& theDMVLV,
BOPCol_DataMapOfIntegerInteger& theDMNewSD)
{
// Create a new SD vertex for each group of coinciding vertices
// and put new substitutions to theDMNewSD.
BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItG(theDMVLV);
for (; aItG.More(); aItG.Next()) {
const BOPCol_ListOfInteger& aList = aItG.Value();
// make SD vertices w/o creation of interfs
Standard_Integer nSD = MakeSDVertices(aList, Standard_False);
// update theDMNewSD
BOPCol_ListIteratorOfListOfInteger aItL(aList);
for (; aItL.More(); aItL.Next()) {
Standard_Integer nV = aItL.Value();
theDMNewSD.Bind(nV, nSD);
}
}
}
//=======================================================================
//function : PostTreatFF
//purpose :
//=======================================================================
Standard_Integer BOPAlgo_PaveFiller::PostTreatFF
Standard_Integer BOPAlgo_PaveFiller::PostTreatFF
(BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB,
BOPCol_DataMapOfShapeInteger& aMVI,
BOPDS_DataMapOfPaveBlockListOfPaveBlock& aDMExEdges,
BOPCol_DataMapOfIntegerInteger& aDMI,
BOPCol_DataMapOfIntegerInteger& aDMNewSD,
Handle(NCollection_BaseAllocator)& theAllocator)
{
Standard_Integer iRet, aNbS;
@@ -539,6 +577,8 @@ void BOPAlgo_PaveFiller::MakeBlocks()
//
BOPCol_ListOfShape aLS(theAllocator);
BOPAlgo_PaveFiller aPF(theAllocator);
aPF.SetIsPrimary(Standard_False);
aPF.SetNonDestructive(myNonDestructive);
//
BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
//
@@ -582,9 +622,25 @@ void BOPAlgo_PaveFiller::MakeBlocks()
}
//
// 1 prepare arguments
BOPCol_MapOfShape anAddedSD;
for (k=1; k<=aNbS; ++k) {
const TopoDS_Shape& aS=theMSCPB.FindKey(k);
aLS.Append(aS);
// add vertices-candidates for SD from the map aDMNewSD,
// so that they took part in fuse operation.
TopoDS_Iterator itV(aS);
for (; itV.More(); itV.Next()) {
const TopoDS_Shape& aVer = itV.Value();
Standard_Integer iVer = aMVI.Find(aVer);
if (aDMNewSD.IsBound(iVer)) {
Standard_Integer iSD = aDMNewSD.Find(iVer);
const TopoDS_Shape& aVSD = myDS->Shape(iSD);
if (anAddedSD.Add(aVSD)) {
aLS.Append(aVSD);
aMVI.Bind(aVSD, iSD);
}
}
}
}
//
// 2 Fuse shapes
@@ -606,6 +662,8 @@ void BOPAlgo_PaveFiller::MakeBlocks()
aType=aSIx.ShapeType();
//
if (aType==TopAbs_VERTEX) {
Standard_Boolean bIntersectionPoint = theMSCPB.Contains(aSx);
//
if (aPDS->HasShapeSD(nSx, nVSD)) {
aV=aPDS->Shape(nVSD);
}
@@ -623,14 +681,23 @@ void BOPAlgo_PaveFiller::MakeBlocks()
else {
iV=aMVI.Find(aV);
}
// update FF interference
const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromKey(aSx);
iX=aCPB.IndexInterf();
iP=aCPB.Index();
BOPDS_InterfFF& aFF=aFFs(iX);
BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints();
BOPDS_Point& aNP=aVNP(iP);
aNP.SetIndex(iV);
//
if (!bIntersectionPoint) {
// save SD connection
nSx = aMVI.Find(aSx);
aDMNewSD.Bind(nSx, iV);
myDS->AddShapeSD(nSx, iV);
}
else {
// update FF interference
const BOPDS_CoupleOfPaveBlocks &aCPB=theMSCPB.FindFromKey(aSx);
iX=aCPB.IndexInterf();
iP=aCPB.Index();
BOPDS_InterfFF& aFF=aFFs(iX);
BOPDS_VectorOfPoint& aVNP=aFF.ChangePoints();
BOPDS_Point& aNP=aVNP(iP);
aNP.SetIndex(iV);
}
}//if (aType==TopAbs_VERTEX) {
//
else if (aType==TopAbs_EDGE) {
@@ -682,24 +749,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
}
}
//
if (!aNbLPBx) {
aE=aSx;
//
if (!aMVI.IsBound(aE)) {
aSI.SetShapeType(aType);
aSI.SetShape(aE);
iE=myDS->Append(aSI);
aMVI.Bind(aE, iE);
}
else {
iE=aMVI.Find(aE);
}
// append new PaveBlock to aLPBC
aPB1->SetEdge(iE);
aLPBC.Append(aPB1);
} // if (!aNbLPBx) {
//
else {
if (aNbLPBx) {
aItLPB.Initialize(aLPBx);
if (bOld) {
aPave1[0] = aPB1->Pave1();
@@ -742,7 +792,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
}
const BOPDS_Pave& aP1 = !j ? aPB1->Pave1() : aPB1->Pave2();
if (aP1.Parameter() == aPave[j].Parameter() && aP1.Index() != iV) {
aDMI.Bind(aP1.Index(), iV);
aDMNewSD.Bind(aP1.Index(), iV);
}
//
aPave[j].SetIndex(iV);
@@ -778,6 +828,17 @@ void BOPAlgo_PaveFiller::MakeBlocks()
}
}//else if (aType==TopAbs_EDGE)
}//for (; aItLS.More(); aItLS.Next()) {
//
// Update SD for vertices that did not participate in operation
BOPCol_DataMapOfIntegerInteger::Iterator itDM(aDMNewSD);
for (; itDM.More(); itDM.Next())
{
if (aDMNewSD.IsBound(itDM.Value())) {
Standard_Integer iSD = aDMNewSD.Find(itDM.Value());
itDM.ChangeValue() = iSD;
myDS->AddShapeSD(itDM.Key(), iSD);
}
}
return iRet;
}
@@ -785,7 +846,8 @@ void BOPAlgo_PaveFiller::MakeBlocks()
//function : UpdateFaceInfo
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDME)
void BOPAlgo_PaveFiller::UpdateFaceInfo
(BOPDS_DataMapOfPaveBlockListOfPaveBlock& theDME)
{
Standard_Integer i, j, nV1, nF1, nF2,
aNbFF, aNbC, aNbP, aNbS, aNbPBIn;
@@ -875,10 +937,10 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock&
//function : IsExistingVertex
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_PaveFiller::IsExistingVertex
(const gp_Pnt& aP,
const Standard_Real theTolR3D,
const BOPCol_MapOfInteger& aMVOnIn)const
Standard_Boolean BOPAlgo_PaveFiller::IsExistingVertex
(const gp_Pnt& aP,
const Standard_Real theTolR3D,
const BOPCol_MapOfInteger& aMVOnIn)const
{
Standard_Boolean bRet;
Standard_Integer nV, iFlag;
@@ -916,11 +978,11 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock&
//function : IsExistingPaveBlock
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
(const Handle(BOPDS_PaveBlock)& thePB,
const BOPDS_Curve& theNC,
const Standard_Real theTolR3D,
const BOPCol_ListOfInteger& theLSE)
Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
(const Handle(BOPDS_PaveBlock)& thePB,
const BOPDS_Curve& theNC,
const Standard_Real theTolR3D,
const BOPCol_ListOfInteger& theLSE)
{
Standard_Boolean bRet=Standard_True;
//
@@ -962,12 +1024,12 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock&
//function : IsExistingPaveBlock
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
(const Handle(BOPDS_PaveBlock)& thePB,
const BOPDS_Curve& theNC,
const Standard_Real theTolR3D,
const BOPDS_MapOfPaveBlock& theMPBOnIn,
Handle(BOPDS_PaveBlock&) aPBOut)
Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
(const Handle(BOPDS_PaveBlock)& thePB,
const BOPDS_Curve& theNC,
const Standard_Real theTolR3D,
const BOPDS_MapOfPaveBlock& theMPBOnIn,
Handle(BOPDS_PaveBlock&) aPBOut)
{
Standard_Boolean bRet;
Standard_Real aT1, aT2, aTm, aTx;
@@ -1033,12 +1095,13 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock&
//function : PutBoundPaveOnCurve
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::PutBoundPaveOnCurve(const TopoDS_Face& aF1,
const TopoDS_Face& aF2,
const Standard_Real aTolR3D,
BOPDS_Curve& aNC,
BOPCol_MapOfInteger& aMVOnIn,
BOPCol_MapOfInteger& aMVB)
void BOPAlgo_PaveFiller::PutBoundPaveOnCurve
(const TopoDS_Face& aF1,
const TopoDS_Face& aF2,
const Standard_Real aTolR3D,
BOPDS_Curve& aNC,
BOPCol_MapOfInteger& aMVOnIn,
BOPCol_MapOfInteger& aMVB)
{
Standard_Boolean bVF;
Standard_Integer nV, iFlag, nVn, j, aNbEP;
@@ -1136,14 +1199,16 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock&
//function : PutPavesOnCurve
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::PutPavesOnCurve(const BOPCol_MapOfInteger& aMVOnIn,
const Standard_Real aTolR3D,
BOPDS_Curve& aNC,
const Standard_Integer nF1,
const Standard_Integer nF2,
const BOPCol_MapOfInteger& aMI,
const BOPCol_MapOfInteger& aMVEF,
BOPCol_DataMapOfIntegerReal& aMVTol)
void BOPAlgo_PaveFiller::PutPavesOnCurve
(const BOPCol_MapOfInteger& aMVOnIn,
const Standard_Real aTolR3D,
BOPDS_Curve& aNC,
const Standard_Integer nF1,
const Standard_Integer nF2,
const BOPCol_MapOfInteger& aMI,
const BOPCol_MapOfInteger& aMVEF,
BOPCol_DataMapOfIntegerReal& aMVTol,
BOPCol_DataMapOfIntegerListOfInteger& aDMVLV)
{
Standard_Boolean bInBothFaces;
Standard_Integer nV;
@@ -1155,7 +1220,7 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock&
aIt.Initialize(aMVEF);
for (; aIt.More(); aIt.Next()) {
nV=aIt.Value();
PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, 2);
PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, aDMVLV, 2);
}
//Put all other vertices
aIt.Initialize(aMVOnIn);
@@ -1184,7 +1249,7 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock&
}
}
//
PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, 1);
PutPaveOnCurve(nV, aTolR3D, aNC, aMI, aMVTol, aDMVLV, 1);
}
}
@@ -1192,10 +1257,11 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo(BOPDS_DataMapOfPaveBlockListOfPaveBlock&
//function : ExtendedTolerance
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance(const Standard_Integer nV,
const BOPCol_MapOfInteger& aMI,
Standard_Real& aTolVExt,
const Standard_Integer aType)
Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance
(const Standard_Integer nV,
const BOPCol_MapOfInteger& aMI,
Standard_Real& aTolVExt,
const Standard_Integer aType)
{
Standard_Boolean bFound = Standard_False;
if (!(myDS->IsNewShape(nV))) {
@@ -1253,9 +1319,10 @@ Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance(const Standard_Integer nV
//function : GetEFPnts
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::GetEFPnts(const Standard_Integer nF1,
const Standard_Integer nF2,
IntSurf_ListOfPntOn2S& aListOfPnts)
void BOPAlgo_PaveFiller::GetEFPnts
(const Standard_Integer nF1,
const Standard_Integer nF2,
IntSurf_ListOfPntOn2S& aListOfPnts)
{
Standard_Integer nE, nF, nFOpposite, aNbEFs, i;
Standard_Real U1, U2, V1, V2, f, l;
@@ -1326,10 +1393,12 @@ Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance(const Standard_Integer nV
//function : ProcessUnUsedVertices
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::PutEFPavesOnCurve(BOPDS_Curve& aNC,
const BOPCol_MapOfInteger& aMI,
const BOPCol_MapOfInteger& aMVEF,
BOPCol_DataMapOfIntegerReal& aMVTol)
void BOPAlgo_PaveFiller::PutEFPavesOnCurve
(BOPDS_Curve& aNC,
const BOPCol_MapOfInteger& aMI,
const BOPCol_MapOfInteger& aMVEF,
BOPCol_DataMapOfIntegerReal& aMVTol,
BOPCol_DataMapOfIntegerListOfInteger& aDMVLV)
{
if (!aMVEF.Extent()) {
return;
@@ -1367,7 +1436,7 @@ Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance(const Standard_Integer nV
Standard_Integer aNbPoints = aProjPT.NbPoints();
if (aNbPoints) {
aDist = aProjPT.LowerDistance();
PutPaveOnCurve(nV, aDist, aNC, aMI, aMVTol);
PutPaveOnCurve(nV, aDist, aNC, aMI, aMVTol, aDMVLV);
}
}
}
@@ -1376,12 +1445,14 @@ Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance(const Standard_Integer nV
//function : ProcessUnUsedVertices
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::PutStickPavesOnCurve(const TopoDS_Face& aF1,
const TopoDS_Face& aF2,
const BOPCol_MapOfInteger& aMI,
BOPDS_Curve& aNC,
const BOPCol_MapOfInteger& aMVStick,
BOPCol_DataMapOfIntegerReal& aMVTol)
void BOPAlgo_PaveFiller::PutStickPavesOnCurve
(const TopoDS_Face& aF1,
const TopoDS_Face& aF2,
const BOPCol_MapOfInteger& aMI,
BOPDS_Curve& aNC,
const BOPCol_MapOfInteger& aMVStick,
BOPCol_DataMapOfIntegerReal& aMVTol,
BOPCol_DataMapOfIntegerListOfInteger& aDMVLV)
{
BOPCol_MapOfInteger aMV;
aMV.Assign(aMVStick);
@@ -1454,7 +1525,7 @@ Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance(const Standard_Integer nV
// The intersection curve aIC is vanishing curve (the crease)
aD=sqrt(aD2);
//
PutPaveOnCurve(nV, aD, aNC, aMI, aMVTol);
PutPaveOnCurve(nV, aD, aNC, aMI, aMVTol, aDMVLV);
}
}//for (jVU=1; jVU=aNbVU; ++jVU) {
}
@@ -1466,11 +1537,11 @@ Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance(const Standard_Integer nV
//function : GetStickVertices
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::GetStickVertices(const Standard_Integer nF1,
const Standard_Integer nF2,
BOPCol_MapOfInteger& aMVStick,
BOPCol_MapOfInteger& aMVEF,
BOPCol_MapOfInteger& aMI)
void BOPAlgo_PaveFiller::GetStickVertices(const Standard_Integer nF1,
const Standard_Integer nF2,
BOPCol_MapOfInteger& aMVStick,
BOPCol_MapOfInteger& aMVEF,
BOPCol_MapOfInteger& aMI)
{
Standard_Integer nS1, nS2, nVNew, aTypeInt, i;
//
@@ -1565,49 +1636,96 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
//function : PutPaveOnCurve
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::PutPaveOnCurve(const Standard_Integer nV,
const Standard_Real aTolR3D,
BOPDS_Curve& aNC,
const BOPCol_MapOfInteger& aMI,
BOPCol_DataMapOfIntegerReal& aMVTol,
const Standard_Integer iCheckExtend)
void BOPAlgo_PaveFiller::PutPaveOnCurve(const Standard_Integer nV,
const Standard_Real aTolR3D,
BOPDS_Curve& aNC,
const BOPCol_MapOfInteger& aMI,
BOPCol_DataMapOfIntegerReal& aMVTol,
BOPCol_DataMapOfIntegerListOfInteger& aDMVLV,
const Standard_Integer iCheckExtend)
{
Standard_Boolean bIsVertexOnLine;
Standard_Real aT, aTol, aTolNew;
BOPDS_Pave aPave;
Standard_Real aT, aTolV;
//
const TopoDS_Vertex aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV)));
const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&myDS->Shape(nV)));
Handle(BOPDS_PaveBlock)& aPB=aNC.ChangePaveBlock1();
const IntTools_Curve& aIC = aNC.Curve();
//
bIsVertexOnLine=myContext->IsVertexOnLine(aV, aIC, aTolR3D, aT);
if (!bIsVertexOnLine && iCheckExtend) {
aTol = BRep_Tool::Tolerance(aV);
aTolV = BRep_Tool::Tolerance(aV);
//
ExtendedTolerance(nV, aMI, aTol, iCheckExtend);
bIsVertexOnLine=myContext->IsVertexOnLine(aV, aTol, aIC, aTolR3D, aT);
ExtendedTolerance(nV, aMI, aTolV, iCheckExtend);
bIsVertexOnLine=myContext->IsVertexOnLine(aV, aTolV, aIC, aTolR3D, aT);
}
//
if (bIsVertexOnLine) {
aPave.SetIndex(nV);
aPave.SetParameter(aT);
// check if aPB contains the parameter aT
Standard_Boolean bExist;
Standard_Integer nVUsed;
Standard_Real aPTol, aDTol;
//
aPB->AppendExtPave(aPave);
aDTol = 1.e-12;
//
aTol = BRep_Tool::Tolerance(aV);
GeomAdaptor_Curve aGAC(aIC.Curve());
aPTol = aGAC.Resolution(aTolR3D);
//
BOPTools_AlgoTools::UpdateVertex (aIC, aT, aV);
//
if (!aMVTol.IsBound(nV)) {
aTolNew = BRep_Tool::Tolerance(aV);
if (aTolNew > aTol) {
aMVTol.Bind(nV, aTol);
bExist = aPB->ContainsParameter(aT, aPTol, nVUsed);
if (bExist) {
// use existing pave
if (!aDMVLV.IsBound(nVUsed)) {
BOPCol_ListOfInteger aList;
aList.Append(nVUsed);
aDMVLV.Bind(nVUsed, aList);
//
if (!aMVTol.IsBound(nVUsed)) {
const TopoDS_Vertex& aVUsed = (*(TopoDS_Vertex *)(&myDS->Shape(nVUsed)));
aTolV = BRep_Tool::Tolerance(aVUsed);
aMVTol.Bind(nVUsed, aTolV);
}
}
//
BOPCol_ListOfInteger& aList = aDMVLV.ChangeFind(nVUsed);
// avoid repeated elements in the list
BOPCol_ListIteratorOfListOfInteger aItLI(aList);
for (; aItLI.More(); aItLI.Next()) {
if (aItLI.Value() == nV) {
break;
}
}
if (!aItLI.More()) {
aList.Append(nV);
}
// save initial tolerance for the vertex
if (!aMVTol.IsBound(nV)) {
aTolV = BRep_Tool::Tolerance(aV);
aMVTol.Bind(nV, aTolV);
}
}
else {
// add new pave
BOPDS_Pave aPave;
aPave.SetIndex(nV);
aPave.SetParameter(aT);
aPB->AppendExtPave(aPave);
//
gp_Pnt aP1 = aGAC.Value(aT);
aTolV = BRep_Tool::Tolerance(aV);
gp_Pnt aP2 = BRep_Tool::Pnt(aV);
Standard_Real aDist = aP1.Distance(aP2);
if (aDist > aTolV) {
BRep_Builder().UpdateVertex(aV, aDist + aDTol);
//
if (!aMVTol.IsBound(nV)) {
aMVTol.Bind(nV, aTolV);
}
//
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV);
Bnd_Box& aBoxDS=aSIDS.ChangeBox();
BRepBndLib::Add(aV, aBoxDS);
aBoxDS.SetGap(aBoxDS.GetGap() + Precision::Confusion());
}
}
//
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV);
Bnd_Box& aBoxDS=aSIDS.ChangeBox();
BRepBndLib::Add(aV, aBoxDS);
}
}
@@ -1615,7 +1733,7 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
//function : ProcessOldPaveBlocks
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks
void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks
(const Standard_Integer theInt,
const BOPDS_MapOfPaveBlock& aMPBOnIn,
BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB,
@@ -1674,11 +1792,11 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
//function : UpdateExistingPaveBlocks
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::UpdateExistingPaveBlocks
(const Handle(BOPDS_PaveBlock)& aPBf,
BOPDS_ListOfPaveBlock& aLPB,
const Standard_Integer nF1,
const Standard_Integer nF2)
void BOPAlgo_PaveFiller::UpdateExistingPaveBlocks
(const Handle(BOPDS_PaveBlock)& aPBf,
BOPDS_ListOfPaveBlock& aLPB,
const Standard_Integer nF1,
const Standard_Integer nF2)
{
Standard_Integer nE;
Standard_Boolean bCB;
@@ -1781,7 +1899,8 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
IntTools_Range aShrR(aPB->Pave1().Parameter(), aPB->Pave2().Parameter());
const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(aPB->Edge());
//
Standard_Boolean bCom = BOPTools_AlgoTools::IsBlockInOnFace(aShrR, aF, aE, myContext);
Standard_Boolean bCom =
BOPTools_AlgoTools::IsBlockInOnFace(aShrR, aF, aE, myContext);
if (bCom) {
if (bCB) {
aCB = myDS->CommonBlock(aPB);
@@ -1824,7 +1943,7 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
// function: PutClosingPaveOnCurve
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::PutClosingPaveOnCurve(BOPDS_Curve& aNC)
void BOPAlgo_PaveFiller::PutClosingPaveOnCurve(BOPDS_Curve& aNC)
{
Standard_Boolean bIsClosed, bHasBounds, bAdded;
Standard_Integer nVC, j;
@@ -1880,7 +1999,7 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
//function : PreparePostTreatFF
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::PreparePostTreatFF
void BOPAlgo_PaveFiller::PreparePostTreatFF
(const Standard_Integer aInt,
const Handle(BOPDS_PaveBlock)& aPB,
BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB,
@@ -1912,9 +2031,9 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
//function : CheckPlanes
//purpose :
//=======================================================================
Standard_Boolean
BOPAlgo_PaveFiller::CheckPlanes(const Standard_Integer nF1,
const Standard_Integer nF2)const
Standard_Boolean BOPAlgo_PaveFiller::CheckPlanes
(const Standard_Integer nF1,
const Standard_Integer nF2)const
{
Standard_Boolean bToIntersect;
Standard_Integer i, nV2, iCnt;
@@ -1952,9 +2071,10 @@ Standard_Boolean
//function : UpdatePaveBlocks
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::UpdatePaveBlocks(const BOPCol_DataMapOfIntegerInteger& aDMI)
void BOPAlgo_PaveFiller::UpdatePaveBlocks
(const BOPCol_DataMapOfIntegerInteger& aDMNewSD)
{
if (aDMI.IsEmpty()) {
if (aDMNewSD.IsEmpty()) {
return;
}
//
@@ -1984,10 +2104,10 @@ void BOPAlgo_PaveFiller::UpdatePaveBlocks(const BOPCol_DataMapOfIntegerInteger&
aPB->Range(aT[0], aT[1]);
//
for (j = 0; j < 2; ++j) {
if (aDMI.IsBound(nV[j])) {
if (aDMNewSD.IsBound(nV[j])) {
BOPDS_Pave aPave;
//
nV[j] = aDMI.Find(nV[j]);
nV[j] = aDMNewSD.Find(nV[j]);
aPave.SetIndex(nV[j]);
aPave.SetParameter(aT[j]);
//
@@ -2001,7 +2121,7 @@ void BOPAlgo_PaveFiller::UpdatePaveBlocks(const BOPCol_DataMapOfIntegerInteger&
}
//
if (bRebuild) {
nSp = SplitEdge(aPB->Edge(), nV[0], aT[0], nV[1], aT[1]);
nSp = SplitEdge(aPB->OriginalEdge(), nV[0], aT[0], nV[1], aT[1]);
if (bCB) {
aCB->SetEdge(nSp);
}
@@ -2046,3 +2166,120 @@ void BOPAlgo_PaveFiller::UpdatePaveBlocks(const BOPCol_DataMapOfIntegerInteger&
aTolFF = Max(aTolFF, 5.e-6);
}
}
//=======================================================================
//function : UpdateBlocksWithSharedVertices
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::UpdateBlocksWithSharedVertices()
{
if (!myNonDestructive) {
return;
}
//
myErrorStatus=0;
//
Standard_Integer aNbFF;
//
BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
aNbFF=aFFs.Extent();
if (!aNbFF) {
return;
}
//
Standard_Boolean bOnCurve, bHasShapeSD;
Standard_Integer i, nF1, nF2, aNbC, j, nV, nVSD;
Standard_Real aTolR3D, aTolV;
BOPCol_MapOfInteger aMF;
//
for (i=0; i<aNbFF; ++i) {
BOPDS_InterfFF& aFF=aFFs(i);
//
BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves();
aNbC=aVC.Extent();
if (!aNbC) {
continue;
}
//
aFF.Indices(nF1, nF2);
aTolR3D=aFF.TolR3D();
//
if (aMF.Add(nF1)) {
myDS->UpdateFaceInfoOn(nF1);
}
if (aMF.Add(nF2)) {
myDS->UpdateFaceInfoOn(nF2);
}
//
// Collect old vertices that are shared for nF1, nF2 ->aMI;
BOPCol_MapOfInteger aMI;
BOPCol_MapIteratorOfMapOfInteger aItMI;
//
BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
//
const BOPCol_MapOfInteger& aMVOn1=aFI1.VerticesOn();
const BOPCol_MapOfInteger& aMVIn1=aFI1.VerticesIn();
const BOPCol_MapOfInteger& aMVOn2=aFI2.VerticesOn();
const BOPCol_MapOfInteger& aMVIn2=aFI2.VerticesIn();
//
for (j=0; j<2; ++j) {
const BOPCol_MapOfInteger& aMV1=(!j) ? aMVOn1 : aMVIn1;
aItMI.Initialize(aMV1);
for (; aItMI.More(); aItMI.Next()) {
nV=aItMI.Value();
if (myDS->IsNewShape(nV)) {
continue;
}
if (aMVOn2.Contains(nV) || aMVIn2.Contains(nV)) {
aMI.Add(nV);
}
}
}
//
// Try to put vertices aMI on curves
for (j=0; j<aNbC; ++j) {
BOPDS_Curve& aNC=aVC.ChangeValue(j);
//const IntTools_Curve& aIC=aNC.Curve();
//
aItMI.Initialize(aMI);
for (; aItMI.More(); aItMI.Next()) {
nV=aItMI.Value();
//
bHasShapeSD=myDS->HasShapeSD(nV, nVSD);
if (bHasShapeSD) {
continue;
}
//
bOnCurve=EstimatePaveOnCurve(nV, aNC, aTolR3D);
if (!bOnCurve) {
continue;
}
//
const TopoDS_Vertex& aV=*((TopoDS_Vertex *)&myDS->Shape(nV));
aTolV=BRep_Tool::Tolerance(aV);
//
UpdateVertex(nV, aTolV);
}
}//for (j=0; j<aNbC; ++j) {
}//for (i=0; i<aNbFF; ++i) {
//
UpdateCommonBlocksWithSDVertices();
}
//=======================================================================
//function : EstimatePaveOnCurve
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_PaveFiller::EstimatePaveOnCurve
(const Standard_Integer nV,
BOPDS_Curve& aNC,
const Standard_Real aTolR3D)
{
Standard_Boolean bIsVertexOnLine;
Standard_Real aT;
//
const TopoDS_Vertex& aV=*((TopoDS_Vertex *)&myDS->Shape(nV));
const IntTools_Curve& aIC=aNC.Curve();
//
bIsVertexOnLine=myContext->IsVertexOnLine(aV, aIC, aTolR3D, aT);
return bIsVertexOnLine;
}

View File

@@ -51,6 +51,8 @@
#include <BOPDS_FaceInfo.hxx>
#include <BOPDS_MapOfPaveBlock.hxx>
#include <BOPDS_Curve.hxx>
#include <Precision.hxx>
#include <BOPDS_MapOfCommonBlock.hxx>
static void UpdateVertices(const TopoDS_Edge& aE,
const TopoDS_Face& aF);
@@ -59,7 +61,7 @@ static void UpdateVertices(const TopoDS_Edge& aE,
// function: MakeSplitEdges
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::MakeSplitEdges()
void BOPAlgo_PaveFiller::MakeSplitEdges()
{
Standard_Integer aNbPBP;
//
@@ -72,48 +74,55 @@ static void UpdateVertices(const TopoDS_Edge& aE,
}
//
Standard_Boolean bCB, bV1, bV2;
Standard_Integer i, nE, nV1, nV2, nSp, aNbPB, nOrE;
Standard_Integer i, nE, nV1, nV2, nSp, aNbPB;
Standard_Real aT1, aT2;
Handle(NCollection_IncAllocator) aAllocator;
BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBCB;
Handle(BOPDS_PaveBlock) aPB, aPBx;
//-----------------------------------------------------scope f
BOPDS_MapOfPaveBlock aMPB;
BOPDS_ListIteratorOfListOfPaveBlock aItPB;
//
aAllocator=new NCollection_IncAllocator();
UpdateCommonBlocksWithSDVertices();
//
BOPDS_MapOfPaveBlock aMPB(100,aAllocator);
aNbPBP=aPBP.Extent();
//
for (i=0; i<aNbPBP; ++i) {
BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
//
aNbPB=aLPB.Extent();
//DEBf
if (aNbPB) {
aPBx=aLPB.First();
nOrE=aPBx->OriginalEdge();
}
//DEBt
//
if (aNbPB==1) {
aPB=aLPB.First();
aPB->Indices(nV1, nV2);
bV1=myDS->IsNewShape(nV1);
bV2=myDS->IsNewShape(nV2);
bCB=myDS->IsCommonBlock(aPB);
//
if (!(bV1 || bV2)) {
nE=aPB->OriginalEdge();
aPB->SetEdge(nE);
continue;
if (!(bV1 || bV2)) { // no new vertices here
if (!myNonDestructive || (myNonDestructive && !bCB)) {
nE=aPB->OriginalEdge();
aPB->SetEdge(nE);
continue;
}
}
}
//
aItPB.Initialize(aLPB);
for (; aItPB.More(); aItPB.Next()) {
aPB=aItPB.Value();
nE=aPB->OriginalEdge();
const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
if (aSIE.HasFlag()){
continue;
}
//
const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
bCB=!aCB.IsNull();
if (bCB) {
myDS->SortPaveBlocks(aCB);
aPB=aCB->PaveBlock1();
//
aPB->Indices(nV1, nV2);
}
//
if (aMPB.Add(aPB)) {
@@ -121,9 +130,13 @@ static void UpdateVertices(const TopoDS_Edge& aE,
aPB->Indices(nV1, nV2);
aPB->Range(aT1, aT2);
//
nSp = SplitEdge(nE, nV1, aT1, nV2, aT2);
//
nSp=SplitEdge(nE, nV1, aT1, nV2, aT2);
//
if (bCB) {
Standard_Real aTolCB;
//
aTolCB=ComputeTolerance(aCB);
myDS->UpdateEdgeTolerance(nSp, aTolCB);
aCB->SetEdge(nSp);
}
else {
@@ -132,12 +145,53 @@ static void UpdateVertices(const TopoDS_Edge& aE,
}// if (aMPB.Add(aPB)) {
}// for (; aItPB.More(); aItPB.Next()) {
}// for (i=0; i<aNbPBP; ++i) {
//
//-----------------------------------------------------scope t
aMPB.Clear();
aAllocator.Nullify();
}
//=======================================================================
//function : ComputeTolerance
//purpose :
//=======================================================================
Standard_Real BOPAlgo_PaveFiller::ComputeTolerance
(const Handle(BOPDS_CommonBlock)& theCB)
{
Standard_Integer nE, nF;
Standard_Real aTol, aTolMax;
BOPDS_ListIteratorOfListOfPaveBlock aItPB;
BOPCol_ListIteratorOfListOfInteger aItLI;
//
const Handle(BOPDS_PaveBlock)& aPBR = theCB->PaveBlock1();
nE = aPBR->OriginalEdge();
const TopoDS_Edge& aEOr = *(TopoDS_Edge*)&myDS->Shape(nE);
aTolMax = BRep_Tool::Tolerance(aEOr);
//
const BOPDS_ListOfPaveBlock& aLPB = theCB->PaveBlocks();
aItPB.Initialize(aLPB);
for (; aItPB.More(); aItPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
if (aPB == aPBR) {
continue;
}
//
nE = aPB->OriginalEdge();
const TopoDS_Edge& aE = *(TopoDS_Edge*)&myDS->Shape(nE);
aTol = BRep_Tool::Tolerance(aE);
if (aTol > aTolMax) {
aTolMax=aTol;
}
}
//
const BOPCol_ListOfInteger& aLFI = theCB->Faces();
aItLI.Initialize(aLFI);
for (; aItLI.More(); aItLI.Next()) {
nF = aItLI.Value();
const TopoDS_Face& aF = *(TopoDS_Face*)&myDS->Shape(nF);
//
aTol=BRep_Tool::Tolerance(aF);
if (aTol > aTolMax) {
aTolMax=aTol;
}
}
return aTolMax;
}
//=======================================================================
// function: SplitEdge
// purpose:
@@ -179,7 +233,7 @@ Standard_Integer BOPAlgo_PaveFiller::SplitEdge(const Standard_Integer nE,
// function: MakePCurves
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::MakePCurves()
void BOPAlgo_PaveFiller::MakePCurves()
{
Standard_Integer i, nF1, nF2, aNbC, k, nE, aNbFF, aNbFI;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
@@ -264,48 +318,6 @@ Standard_Integer BOPAlgo_PaveFiller::SplitEdge(const Standard_Integer nE,
}
}
//=======================================================================
// function: RefineFaceInfoOn
// purpose:
//=======================================================================
void BOPAlgo_PaveFiller::RefineFaceInfoOn()
{
Standard_Integer aNbPBP;
//
myErrorStatus=0;
//
BOPDS_VectorOfListOfPaveBlock& aPBP=myDS->ChangePaveBlocksPool();
aNbPBP=aPBP.Extent();
if(!aNbPBP) {
return;
}
//
Standard_Boolean bV1, bV2;
Standard_Integer i, nV1, nV2, aNbPB;
Handle(BOPDS_PaveBlock) aPB;
//
for (i=0; i<aNbPBP; ++i) {
BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
//
aNbPB=aLPB.Extent();
if (aNbPB==1) {
aPB=aLPB.First();
aPB->Indices(nV1, nV2);
bV1=myDS->IsNewShape(nV1);
bV2=myDS->IsNewShape(nV2);
//
if (!(bV1 || bV2)) {
if (!myDS->IsCommonBlock(aPB)) {
// the PB seems to be untouced
aLPB.Clear();
continue;
}
}//if (!(bV1 || bV2)) {
}//if (aNbPB==1) {
}//for (i=0; i<aNbPBP; ++i) {
myDS->RefineFaceInfoOn();
}
//=======================================================================
//function : UpdateVertices
//purpose : update tolerances of vertices comparing extremities of

View File

@@ -99,6 +99,8 @@ static
//
// 2.
BOPDS_ListOfPaveBlock& aLPBD=myDS->ChangePaveBlocks(nE);
if (aLPBD.IsEmpty())
continue;
aPBD=aLPBD.First();
//
FillPaves(nV, nE, nF, aLPBOut, aPBD);
@@ -226,7 +228,7 @@ static
aPB->SetEdge(nSp);
}
else {
//aPB->SetEdge(nDE);
myDS->ChangeShapeInfo(nDE).SetReference(-1);
aLPB.Clear();
break;
}
@@ -244,7 +246,7 @@ static
const Handle(BOPDS_PaveBlock)& aPBD)
{
Standard_Boolean bXDir, bIsDone, bReject;
Standard_Integer nE, aNbPoints, j;
Standard_Integer nE, aNbPoints, j, anInd;
Standard_Real aTD1, aTD2, aT1, aT2, aTolInter, aX, aDT;
Standard_Real aTolCmp;
gp_Pnt2d aP2d1, aP2d2, aP2D;
@@ -330,7 +332,7 @@ static
}
//
bReject=Standard_False;
if (aPBD->ContainsParameter(aX, aDT)) {
if (aPBD->ContainsParameter(aX, aDT, anInd)) {
continue;
}
aPave.SetParameter(aX);

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,
@@ -133,7 +133,7 @@ static
//function : SplitBlock
//purpose :
//=======================================================================
void BOPAlgo_WireSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB)
void BOPAlgo_WireSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB)
{
Standard_Boolean bNothingToDo;
Standard_Integer aIx, aNb, i, aCntIn, aCntOut;
@@ -150,8 +150,6 @@ static
const BOPCol_ListOfShape& myEdges=aCB.Shapes();
//
// 1.Filling mySmartMap
BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane(myEdges, myFace);
//
aIt.Initialize(myEdges);
for(; aIt.More(); aIt.Next()) {
const TopoDS_Edge& aE=(*(TopoDS_Edge *)&aIt.Value());
@@ -326,245 +324,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

@@ -15,3 +15,4 @@ BOPAlgo_WireSplitter_1.cxx
BOPAlgo_ListOfCheckResult.hxx
BOPAlgo_Builder_2Cnt.hxx
BOPAlgo_PaveFiller_11.cxx

View File

@@ -42,6 +42,7 @@ uses
ListOfInteger from BOPCol,
MapOfInteger from BOPCol,
BaseAllocator from BOPCol,
DataMapOfIntegerListOfInteger from BOPCol,
--
ShapeInfo from BOPDS,
IndexRange from BOPDS,
@@ -580,7 +581,21 @@ is
---Purpose:
--- Updates tolerance of the sub-shapes of the shape with index <theIndex>.
---
UpdatePaveBlocksWithSDVertices(me:out);
UpdatePaveBlockWithSDVertices(me:out;
thePB:PaveBlock from BOPDS);
UpdateCommonBlockWithSDVertices(me:out;
theCB:CommonBlock from BOPDS);
InitPaveBlocksForVertex(me:out;
theNV:Integer from Standard);
ReleasePaveBlocks(me:out);
---Purpose:
-- Clears information about PaveBlocks for the untouched edges.
fields
myAllocator : BaseAllocator from BOPCol is protected;
myArguments : ListOfShape from BOPCol is protected;
@@ -597,6 +612,8 @@ fields
--
--same domain shapes
myShapesSD : DataMapOfIntegerInteger from BOPCol is protected;
--
myMapVE: DataMapOfIntegerListOfInteger from BOPCol is protected;
--
--interferences
myInterfTB : MapOfPassKey from BOPDS is protected;

View File

@@ -46,17 +46,15 @@
#include <BOPTools_AlgoTools.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <BOPDS_MapOfPave.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
//
static
inline void ResetShape(const TopoDS_Shape& aS);
static
inline void ResetShapes(const TopoDS_Shape& aS);
static
void TotalShapes(const TopoDS_Shape& aS,
Standard_Integer& aNbS);
Standard_Integer& aNbS,
BOPCol_MapOfShape& aMS);
static
Standard_Real ComputeParameter(const TopoDS_Vertex& aV,
@@ -79,6 +77,7 @@ BOPDS_DS::BOPDS_DS()
myMapPBCB(100, myAllocator),
myFaceInfoPool(myAllocator),
myShapesSD(100, myAllocator),
myMapVE(100, myAllocator),
myInterfTB(100, myAllocator),
myInterfVV(myAllocator),
myInterfVE(myAllocator),
@@ -105,6 +104,7 @@ BOPDS_DS::BOPDS_DS(const Handle(NCollection_BaseAllocator)& theAllocator)
myMapPBCB(100, myAllocator),
myFaceInfoPool(myAllocator),
myShapesSD(100, myAllocator),
myMapVE(100, myAllocator),
myInterfTB(100, myAllocator),
myInterfVV(myAllocator),
myInterfVE(myAllocator),
@@ -140,6 +140,7 @@ void BOPDS_DS::Clear()
myPaveBlocksPool.Clear();
myFaceInfoPool.Clear();
myShapesSD.Clear();
myMapVE.Clear();
myMapPBCB.Clear();
myInterfTB.Clear();
myInterfVV.Clear();
@@ -148,6 +149,7 @@ void BOPDS_DS::Clear()
myInterfEE.Clear();
myInterfEF.Clear();
myInterfFF.Clear();
}
//=======================================================================
//function : SetArguments
@@ -299,7 +301,6 @@ Standard_Integer BOPDS_DS::Index(const TopoDS_Shape& theS)const
}
return iRet;
}
//=======================================================================
//function : Init
//purpose :
@@ -308,11 +309,12 @@ void BOPDS_DS::Init()
{
Standard_Integer i1, i2, j, aI, aNb, aNbS, aNbE, aNbSx, nV, nW, nE, aNbF;
Standard_Real aTol;
Handle(NCollection_IncAllocator) aAllocator;
TopAbs_ShapeEnum aTS;
BOPDS_IndexRange aR;
BOPCol_ListIteratorOfListOfInteger aIt1, aIt2, aIt3;
BOPCol_ListIteratorOfListOfShape aIt;
BOPDS_IndexRange aR;
Handle(NCollection_IncAllocator) aAllocator;
BOPCol_MapOfShape aMS;
//
// 1 Append Source Shapes
aNb=myArguments.Extent();
@@ -323,21 +325,17 @@ void BOPDS_DS::Init()
myRanges.SetStartSize(aNb);
myRanges.Init();
//
aIt.Initialize(myArguments);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
ResetShapes(aSx);
}
//
aNbS=0;
aIt.Initialize(myArguments);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
//
aNbSx=0;
TotalShapes(aSx, aNbSx);
TotalShapes(aSx, aNbSx, aMS);
//
aNbS=aNbS+aNbSx;
}
aMS.Clear();
//
myLines.SetStartSize(2*aNbS);
myLines.SetIncrement(aNbS);
@@ -376,7 +374,6 @@ void BOPDS_DS::Init()
BOPDS_ShapeInfo& aSI=ChangeShapeInfo(j);
//
const TopoDS_Shape& aS=aSI.Shape();
ResetShape(aS);
//
aTS=aSI.ShapeType();
//
@@ -523,7 +520,56 @@ void BOPDS_DS::Init()
}//for (j=0; j<myNbSourceShapes; ++j) {
//
aMI.Clear();
//
aAllocator.Nullify();
//-----------------------------------------------------
//
for (nE=0; nE<myNbSourceShapes; ++nE) {
BOPDS_ShapeInfo& aSI=ChangeShapeInfo(nE);
if (aSI.ShapeType()!=TopAbs_EDGE) {
continue;
}
//
const BOPCol_ListOfInteger& aLV=aSI.SubShapes();
aIt1.Initialize(aLV);
for (; aIt1.More(); aIt1.Next()) {
nV=aIt1.Value();
if (myMapVE.IsBound(nV)) {
BOPCol_ListOfInteger& aLE=myMapVE.ChangeFind(nV);
aLE.Append(nE);
}
else {
BOPCol_ListOfInteger aLE(myAllocator);
//
aLE.Append(nE);
myMapVE.Bind(nV, aLE);
}
}
}
//
BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItDMILI;
aItDMILI.Initialize(myMapVE);
for(; aItDMILI.More(); aItDMILI.Next()) {
BOPCol_MapOfInteger aMFence;
BOPCol_ListOfInteger aLEx;
//
nV=aItDMILI.Key();
BOPCol_ListOfInteger& aLE=aItDMILI.ChangeValue();
aIt1.Initialize(aLE);
for (; aIt1.More(); aIt1.Next()) {
nE=aIt1.Value();
if(aMFence.Add(nE)) {
aLEx.Append(nE);
}
}
//
aLE.Clear();
aIt1.Initialize(aLEx);
for (; aIt1.More(); aIt1.Next()) {
nE=aIt1.Value();
aLE.Append(nE);
}
}
//-----------------------------------------------------scope_1 t
//
// 3 myPaveBlocksPool
@@ -542,9 +588,9 @@ void BOPDS_DS::Init()
//purpose :
//=======================================================================
void BOPDS_DS::InitShape(const Standard_Integer aI,
const TopoDS_Shape& aS,
Handle(NCollection_BaseAllocator)& theAllocator,
BOPCol_DataMapOfShapeInteger& aMSI)
const TopoDS_Shape& aS,
Handle(NCollection_BaseAllocator)& theAllocator,
BOPCol_DataMapOfShapeInteger& aMSI)
{
Standard_Integer aIx;
TopoDS_Iterator aIt;
@@ -610,7 +656,7 @@ Standard_Boolean BOPDS_DS::HasInterf(const Standard_Integer theI) const
//purpose :
//=======================================================================
Standard_Boolean BOPDS_DS::HasInterfShapeSubShapes(const Standard_Integer theI1,
const Standard_Integer theI2)const
const Standard_Integer theI2)const
{
Standard_Boolean bRet;
Standard_Integer n2;
@@ -635,7 +681,7 @@ Standard_Boolean BOPDS_DS::HasInterfShapeSubShapes(const Standard_Integer theI1,
//purpose :
//=======================================================================
Standard_Boolean BOPDS_DS::HasInterfSubShapes(const Standard_Integer theI1,
const Standard_Integer theI2)const
const Standard_Integer theI2)const
{
Standard_Boolean bRet;
Standard_Integer n1;
@@ -696,6 +742,7 @@ const BOPDS_ListOfPaveBlock& BOPDS_DS::PaveBlocks(const Standard_Integer theI)co
}
return sLPB;
}
//=======================================================================
//function : ChangePaveBlocks
//purpose :
@@ -1027,7 +1074,7 @@ const Handle(BOPDS_CommonBlock)& BOPDS_DS::CommonBlock
//purpose :
//=======================================================================
void BOPDS_DS::SetCommonBlock(const Handle(BOPDS_PaveBlock)& thePB,
const Handle(BOPDS_CommonBlock)& theCB)
const Handle(BOPDS_CommonBlock)& theCB)
{
if (IsCommonBlock(thePB)) {
Handle(BOPDS_CommonBlock)& aCB = myMapPBCB.ChangeFind(thePB);
@@ -1157,8 +1204,8 @@ void BOPDS_DS::UpdateFaceInfoOn(const Standard_Integer theI)
//purpose :
//=======================================================================
void BOPDS_DS::FaceInfoOn(const Standard_Integer theF,
BOPDS_IndexedMapOfPaveBlock& theMPB,
BOPCol_MapOfInteger& theMI)
BOPDS_IndexedMapOfPaveBlock& theMPB,
BOPCol_MapOfInteger& theMI)
{
Standard_Integer nS, nSD, nV1, nV2;
BOPCol_ListIteratorOfListOfInteger aIt;
@@ -1196,22 +1243,42 @@ void BOPDS_DS::FaceInfoOn(const Standard_Integer theF,
//purpose :
//=======================================================================
void BOPDS_DS::FaceInfoIn(const Standard_Integer theF,
BOPDS_IndexedMapOfPaveBlock& theMPB,
BOPCol_MapOfInteger& theMI)
BOPDS_IndexedMapOfPaveBlock& theMPB,
BOPCol_MapOfInteger& theMI)
{
Standard_Integer i, aNbVF, aNbEF, nV, nE;
Standard_Integer i, aNbVF, aNbEF, nV, nE, nVSD;
BOPDS_ListIteratorOfListOfPaveBlock aItPB;
TopoDS_Iterator aItS;
//
// 1. Pure internal vertices on the face
const TopoDS_Shape& aF=Shape(theF);
aItS.Initialize(aF);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aSx=aItS.Value();
if (aSx.ShapeType()==TopAbs_VERTEX){
nV=Index(aSx);
if (HasShapeSD(nV, nVSD)) {
nV=nVSD;
}
theMI.Add(nV);
}
}
//
// 2. aVFs
BOPDS_VectorOfInterfVF& aVFs=InterfVF();
aNbVF=aVFs.Extent();
for (i=0; i<aNbVF; ++i) {
BOPDS_InterfVF& aVF=aVFs(i);
if(aVF.Contains(theF)) {
nV=aVF.OppositeIndex(theF);
if (HasShapeSD(nV, nVSD)) {
nV=nVSD;
}
theMI.Add(nV);
}
}
//
// 3. aEFs
BOPDS_VectorOfInterfEF& aEFs=InterfEF();
aNbEF=aEFs.Extent();
for (i=0; i<aNbEF; ++i) {
@@ -1273,7 +1340,7 @@ void BOPDS_DS::RefineFaceInfoOn()
//purpose :
//=======================================================================
void BOPDS_DS::AloneVertices(const Standard_Integer theI,
BOPCol_ListOfInteger& theLI)const
BOPCol_ListOfInteger& theLI)const
{
if (HasFaceInfo(theI)) {
//
@@ -1286,7 +1353,8 @@ void BOPDS_DS::AloneVertices(const Standard_Integer theI,
const BOPDS_FaceInfo& aFI=FaceInfo(theI);
//
for (i=0; i<2; ++i) {
const BOPDS_IndexedMapOfPaveBlock& aMPB=(!i) ? aFI.PaveBlocksIn() : aFI.PaveBlocksSc();
const BOPDS_IndexedMapOfPaveBlock& aMPB=(!i) ?
aFI.PaveBlocksIn() : aFI.PaveBlocksSc();
aItMPB.Initialize(aMPB);
for (; aItMPB.More(); aItMPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
@@ -1315,9 +1383,9 @@ void BOPDS_DS::AloneVertices(const Standard_Integer theI,
//purpose :
//=======================================================================
void BOPDS_DS::VerticesOnIn(const Standard_Integer nF1,
const Standard_Integer nF2,
BOPCol_MapOfInteger& aMI,
BOPDS_MapOfPaveBlock& aMPB)const
const Standard_Integer nF2,
BOPCol_MapOfInteger& aMI,
BOPDS_MapOfPaveBlock& aMPB)const
{
Standard_Integer i, nV, nV1, nV2;
BOPCol_MapIteratorOfMapOfInteger aIt;
@@ -1354,7 +1422,7 @@ void BOPDS_DS::VerticesOnIn(const Standard_Integer nF1,
for (; aIt.More(); aIt.Next()) {
nV=aIt.Value();
if (aMVOn2.Contains(nV) || aMVIn2.Contains(nV)) {
aMI.Add(nV);
aMI.Add(nV);
}
}
}
@@ -1364,9 +1432,9 @@ void BOPDS_DS::VerticesOnIn(const Standard_Integer nF1,
//purpose :
//=======================================================================
void BOPDS_DS::SharedEdges(const Standard_Integer nF1,
const Standard_Integer nF2,
BOPCol_ListOfInteger& theLI,
const Handle(NCollection_BaseAllocator)& aAllocator)
const Standard_Integer nF2,
BOPCol_ListOfInteger& theLI,
const Handle(NCollection_BaseAllocator)& aAllocator)
{
Standard_Integer nE, nSp;
BOPCol_ListIteratorOfListOfInteger aItLI;
@@ -1448,7 +1516,7 @@ void BOPDS_DS::AddShapeSD(const Standard_Integer theIndex,
//purpose :
//=======================================================================
Standard_Boolean BOPDS_DS::HasShapeSD(const Standard_Integer theIndex,
Standard_Integer& theIndexSD)const
Standard_Integer& theIndexSD)const
{
Standard_Boolean bRet;
//
@@ -1494,8 +1562,9 @@ void BOPDS_DS::Dump()const
// function: CheckCoincidence
// purpose:
//=======================================================================
Standard_Boolean BOPDS_DS::CheckCoincidence(const Handle(BOPDS_PaveBlock)& aPB1,
const Handle(BOPDS_PaveBlock)& aPB2)
Standard_Boolean BOPDS_DS::CheckCoincidence
(const Handle(BOPDS_PaveBlock)& aPB1,
const Handle(BOPDS_PaveBlock)& aPB2)
{
Standard_Boolean bRet;
Standard_Integer nE1, nE2, aNbPoints;
@@ -1575,7 +1644,7 @@ void BOPDS_DS::SortPaveBlocks(const Handle(BOPDS_CommonBlock)& aCB)
// purpose:
//=======================================================================
Standard_Boolean BOPDS_DS::IsToSort(const Handle(BOPDS_CommonBlock)& aCB,
Standard_Integer& theI)
Standard_Integer& theI)
{
Standard_Boolean bRet;
bRet = Standard_False;
@@ -1617,7 +1686,7 @@ Standard_Boolean BOPDS_DS::IsToSort(const Handle(BOPDS_CommonBlock)& aCB,
// purpose:
//=======================================================================
Standard_Boolean BOPDS_DS::IsSubShape(const Standard_Integer theI1,
const Standard_Integer theI2)
const Standard_Integer theI2)
{
Standard_Boolean bRet;
Standard_Integer nS;
@@ -1638,13 +1707,12 @@ Standard_Boolean BOPDS_DS::IsSubShape(const Standard_Integer theI1,
return bRet;
}
//=======================================================================
// function: Paves
// purpose:
//=======================================================================
void BOPDS_DS::Paves(const Standard_Integer theEdge,
BOPDS_ListOfPave& theLP)
BOPDS_ListOfPave& theLP)
{
Standard_Integer aNb, i;
BOPDS_Pave *pPaves;
@@ -1679,13 +1747,12 @@ void BOPDS_DS::Paves(const Standard_Integer theEdge,
theLP.Append(pPaves[i]);
}
}
//=======================================================================
// function: UpdateTolerance
// purpose:
//=======================================================================
void BOPDS_DS::UpdateEdgeTolerance(const Standard_Integer nE,
const Standard_Real aTol)
const Standard_Real aTol)
{
Standard_Integer nV;
Standard_Real aTolV;
@@ -1712,57 +1779,24 @@ void BOPDS_DS::UpdateEdgeTolerance(const Standard_Integer nE,
}
}
}
//=======================================================================
//function : TotalShapes
//purpose :
//=======================================================================
void TotalShapes(const TopoDS_Shape& aS,
Standard_Integer& aNbS)
Standard_Integer& aNbS,
BOPCol_MapOfShape& aMS)
{
TopoDS_Shape *pS;
//
pS=(TopoDS_Shape *)&aS;
if (!pS->Checked()) {
if (aMS.Add(aS)) {
TopoDS_Iterator aIt;
//
pS->Checked(1);
++aNbS;
aIt.Initialize(aS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
TotalShapes(aSx, aNbS);
TotalShapes(aSx, aNbS, aMS);
}
}
}
//=======================================================================
//function : ResetShape
//purpose :
//=======================================================================
void ResetShape(const TopoDS_Shape& aS)
{
TopoDS_Shape *pS;
//
pS=(TopoDS_Shape *)&aS;
pS->Checked(0);
}
//=======================================================================
//function : ResetShape
//purpose :
//=======================================================================
void ResetShapes(const TopoDS_Shape& aS)
{
TopoDS_Iterator aIt;
//
ResetShape(aS);
aIt.Initialize(aS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
ResetShape(aSx);
}
}
#include <Geom_Curve.hxx>
//=======================================================================
//function : ComputeParameter
//purpose :
@@ -1832,3 +1866,127 @@ void SortShell(const int n, BOPDS_Pave *a)
}//for (i=0; i<nd; ++i)
}//while (1)
}
//=======================================================================
//function : UpdatePaveBlocksWithSDVertices
//purpose :
//=======================================================================
void BOPDS_DS::UpdatePaveBlocksWithSDVertices()
{
Standard_Integer i, aNbPBP;
BOPDS_ListIteratorOfListOfPaveBlock aItPB;
//
BOPDS_VectorOfListOfPaveBlock& aPBP=myPaveBlocksPool;
//
aNbPBP=aPBP.Size();
for (i = 0; i < aNbPBP; ++i) {
BOPDS_ListOfPaveBlock& aLPB = aPBP(i);
//
aItPB.Initialize(aLPB);
for (; aItPB.More(); aItPB.Next()) {
Handle(BOPDS_PaveBlock)& aPB = aItPB.ChangeValue();
UpdatePaveBlockWithSDVertices(aPB);
}// for (; aItPB.More(); aItPB.Next()) {
}// for (i = 0; i < aNbPBP; ++i) {
}
//=======================================================================
//function : UpdatePaveBlockWithSDVertices
//purpose :
//=======================================================================
void BOPDS_DS::UpdatePaveBlockWithSDVertices
(const Handle(BOPDS_PaveBlock)& thePB)
{
Standard_Integer nV1, nV2;
BOPDS_Pave aPave1, aPave2;
//
aPave1 = thePB->Pave1();
aPave2 = thePB->Pave2();
//
nV1 = aPave1.Index();
nV2 = aPave2.Index();
//
if (HasShapeSD(nV1, nV1)) {
aPave1.SetIndex(nV1);
thePB->SetPave1(aPave1);
}
//
if (HasShapeSD(nV2, nV2)) {
aPave2.SetIndex(nV2);
thePB->SetPave2(aPave2);
}
}
//=======================================================================
//function : UpdateCommonBlockWithSDVertices
//purpose :
//=======================================================================
void BOPDS_DS::UpdateCommonBlockWithSDVertices
(const Handle(BOPDS_CommonBlock)& theCB)
{
const BOPDS_ListOfPaveBlock& aLPB = theCB->PaveBlocks();
BOPDS_ListIteratorOfListOfPaveBlock aItPB(aLPB);
for (; aItPB.More(); aItPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
UpdatePaveBlockWithSDVertices(aPB);
}
}
//=======================================================================
//function : InitPaveBlocksForVertex
//purpose :
//=======================================================================
void BOPDS_DS::InitPaveBlocksForVertex(const Standard_Integer theNV)
{
Standard_Integer nE;
BOPCol_ListIteratorOfListOfInteger aItLE;
//
if (myMapVE.IsBound(theNV)) {
const BOPCol_ListOfInteger& aLE=myMapVE.Find(theNV);
aItLE.Initialize(aLE);
for (; aItLE.More(); aItLE.Next()) {
nE=aItLE.Value();
ChangePaveBlocks(nE);
}
}
}
//=======================================================================
//function : ReleasePaveBlocks
//purpose :
//=======================================================================
void BOPDS_DS::ReleasePaveBlocks()
{
// It is necessary to remove the reference to PaveBlocks for the untouched
// edges to avoid creation of the same images for them.
// Pave blocks for this reference should be cleared.
// This will allow to differ the small edges, for which it is
// impossible to build pave block from the normal edges for which the
// pave block have been created, but stayed untouched.
// The small edge, for which no pave blocks have been created,
// should be avoided in the result, thus the reference to empty list
// of pave blocks will stay to mark the edge as Deleted.
BOPDS_VectorOfListOfPaveBlock& aPBP = ChangePaveBlocksPool();
Standard_Integer aNbPBP = aPBP.Extent();
if (!aNbPBP) {
return;
}
//
for (Standard_Integer i = 0; i < aNbPBP; ++i) {
BOPDS_ListOfPaveBlock& aLPB = aPBP(i);
if (aLPB.Extent() == 1) {
const Handle(BOPDS_PaveBlock)& aPB = aLPB.First();
if (!IsCommonBlock(aPB)) {
Standard_Integer nV1, nV2;
aPB->Indices(nV1, nV2);
if (!IsNewShape(nV1) && !IsNewShape(nV2)) {
// Both vertices are original, thus the PB is untouched.
// Remove reference for the original edge
Standard_Integer nE = aPB->OriginalEdge();
if (nE >= 0) {
ChangeShapeInfo(nE).SetReference(-1);
}
// Clear contents of the list
aLPB.Clear();
}
}
}
}
}

View File

@@ -186,13 +186,15 @@ is
ContainsParameter(me;
thePrm:Real from Standard;
theTol:Real from Standard)
theTol:Real from Standard;
theInd:out Integer from Standard)
returns Boolean from Standard;
---Purpose:
--- Query
--- Returns true if the extra paves contain the pave
--- with given value of the parameter <thePrm>
--- <theTol> - the value of the tolerance to compare
--- <theInd> - the Index of the found pave
--
-- shrunk data

View File

@@ -234,21 +234,19 @@ static
//purpose :
//=======================================================================
Standard_Boolean BOPDS_PaveBlock::ContainsParameter(const Standard_Real theT,
const Standard_Real theTol)const
const Standard_Real theTol,
Standard_Integer& theInd) const
{
Standard_Boolean bRet;
Standard_Real dT;
BOPDS_ListIteratorOfListOfPave aIt;
//
bRet=Standard_False;
bRet = Standard_False;
aIt.Initialize(myExtPaves);
for (; aIt.More(); aIt.Next()) {
dT=aIt.Value().Parameter()-theT;
if (dT<0.) {
dT=-dT;
}
if (dT<theTol) {
bRet=!bRet;
const BOPDS_Pave& aPave = aIt.Value();
bRet = (Abs(aPave.Parameter() - theT) < theTol);
if (bRet) {
theInd = aPave.Index();
break;
}
}

View File

@@ -150,16 +150,14 @@ is
--- 2. the edge does not contain 3d curve and pcurves (-2)
--- 3. projection algorithm failed (-3)
---
--ComputeVE (me:mutable;
--aV : Vertex from TopoDS;
--aE : Edge from TopoDS;
--aT :out Real from Standard;
--bToUpdateVertex:out Boolean from Standard;
--aDist :out Real from Standard)
--returns Integer from Standard;
---Purpose:
--- Computes parameter aT of the vertex aV on
ComputeVE (me:mutable;
aV : Vertex from TopoDS;
aE : Edge from TopoDS;
aT :out Real from Standard;
aTolVnew:out Real from Standard)
returns Integer from Standard;
---Purpose:
--- Computes parameter of the vertex aV on
--- the edge aE.
--- Returns zero if the distance between vertex
--- and edge is less than sum of tolerances,
@@ -168,15 +166,7 @@ is
--- 1. the edge is degenerated (-1)
--- 2. the edge does not contain 3d curve and pcurves (-2)
--- 3. projection algorithm failed (-3)
---
--- Output parameters
--- bToUpdateVertex - the flag that indicates whether the
--- vertex tolerance should be modified or not
--- aDist - the value of the distance between the vertex
--- and the edge
ComputeVF (me:mutable;
aV : Vertex from TopoDS;
aF : Face from TopoDS;
@@ -192,8 +182,26 @@ is
--- 1. projection algorithm failed (-1)
--- 2. distance is more than sum of tolerances (-2)
--- 3. projection point out or on the boundaries of face (-3)
---
ComputeVF (me:mutable;
aV : Vertex from TopoDS;
aF : Face from TopoDS;
U : out Real from Standard;
V : out Real from Standard;
aTolVnew:out Real from Standard)
returns Integer from Standard;
---Purpose:
--- Computes UV parameters of the vertex aV on face aF
--- Returns zero if the distance between vertex and face is
--- less than or equal the sum of tolerances and the projection
--- point lays inside boundaries of the face.
--- For following conditions returns negative value
--- 1. projection algorithm failed (-1)
--- 2. distance is more than sum of tolerances (-2)
--- 3. projection point out or on the boundaries of face (-3)
---
StatePointFace(me:mutable;
aF : Face from TopoDS;
aP2D : Pnt2d from gp)

View File

@@ -432,13 +432,28 @@
}
return 0;
}
//=======================================================================
//function : ComputeVE
//purpose :
//=======================================================================
Standard_Integer BOPInt_Context::ComputeVE(const TopoDS_Vertex& aV1,
const TopoDS_Edge& aE2,
Standard_Real& aT)
Standard_Integer BOPInt_Context::ComputeVE(const TopoDS_Vertex& aV1,
const TopoDS_Edge& aE2,
Standard_Real& aT)
{
Standard_Real aTolVnew;
//
return ComputeVE(aV1, aE2, aT, aTolVnew);
}
//=======================================================================
//function : ComputeVE
//purpose :
//=======================================================================
Standard_Integer BOPInt_Context::ComputeVE(const TopoDS_Vertex& aV1,
const TopoDS_Edge& aE2,
Standard_Real& aT,
Standard_Real& aTolVnew)
{
if (BRep_Tool::Degenerated(aE2)) {
return -1;
@@ -469,6 +484,8 @@
aTolE2=BRep_Tool::Tolerance(aE2);
aTolSum = aTolV1 + aTolE2 + Precision::Confusion();
//
aTolVnew=aDist+aTolE2;
//
aT=aProjector.LowerDistanceParameter();
if (aDist > aTolSum) {
return -4;
@@ -476,13 +493,27 @@
return 0;
}
//=======================================================================
//function : ComputeVS
//function : ComputeVF
//purpose :
//=======================================================================
Standard_Integer BOPInt_Context::ComputeVF(const TopoDS_Vertex& aV1,
const TopoDS_Face& aF2,
Standard_Real& U,
Standard_Real& V)
Standard_Integer BOPInt_Context::ComputeVF(const TopoDS_Vertex& aV1,
const TopoDS_Face& aF2,
Standard_Real& U,
Standard_Real& V)
{
Standard_Real aTolVnew;
//
return ComputeVF(aV1, aF2, U, V, aTolVnew);
}
//=======================================================================
//function : ComputeVF
//purpose :
//=======================================================================
Standard_Integer BOPInt_Context::ComputeVF(const TopoDS_Vertex& aV1,
const TopoDS_Face& aF2,
Standard_Real& U,
Standard_Real& V,
Standard_Real& aTolVnew)
{
Standard_Real aTolV1, aTolF2, aTolSum, aDist;
gp_Pnt aP;
@@ -500,10 +531,13 @@
// 2. Check the distance between the projection point and
// the original point
aDist=aProjector.LowerDistance();
//
aTolV1=BRep_Tool::Tolerance(aV1);
aTolF2=BRep_Tool::Tolerance(aF2);
aTolSum=aTolV1+aTolF2;
//
aTolSum=aTolV1 + aTolF2 + Precision::Confusion();
aTolVnew=aDist+aTolF2;
//
if (aDist > aTolSum) {
// the distance is too large
return -2;
@@ -632,40 +666,44 @@
//function : IsValidBlockForFaces
//purpose :
//=======================================================================
Standard_Boolean BOPInt_Context::IsValidBlockForFaces (const Standard_Real aT1,
const Standard_Real aT2,
const IntTools_Curve& aC,
const TopoDS_Face& aF1,
const TopoDS_Face& aF2,
const Standard_Real aTol)
Standard_Boolean BOPInt_Context::IsValidBlockForFaces(const Standard_Real theT1,
const Standard_Real theT2,
const IntTools_Curve& theC,
const TopoDS_Face& theF1,
const TopoDS_Face& theF2,
const Standard_Real theTol)
{
Standard_Boolean bFlag1, bFlag2;
//
Handle(Geom2d_Curve) aPC1 = aC.FirstCurve2d();
Handle(Geom2d_Curve) aPC2 = aC.SecondCurve2d();
if( !aPC1.IsNull() && !aPC2.IsNull() ) {
Standard_Real aMidPar = IntTools_Tools::IntermediatePoint(aT1, aT2);
gp_Pnt2d aPnt2D;
const Standard_Integer aNbElem = 2;
const Handle(Geom2d_Curve) &aPC1 = theC.FirstCurve2d();
const Handle(Geom2d_Curve) &aPC2 = theC.SecondCurve2d();
const Handle(Geom_Curve) &aC3D = theC.Curve();
const Handle(Geom2d_Curve)* anArrPC[aNbElem] = { &aPC1, &aPC2 };
const TopoDS_Face* anArrF[aNbElem] = { &theF1, &theF2 };
aPC1->D0(aMidPar, aPnt2D);
bFlag1 = IsPointInOnFace(aF1, aPnt2D);
const Standard_Real aMidPar = IntTools_Tools::IntermediatePoint(theT1, theT2);
const gp_Pnt aP(aC3D->Value(aMidPar));
if( !bFlag1 )
return bFlag1;
Standard_Boolean bFlag = Standard_True;
gp_Pnt2d aPnt2D;
aPC2->D0(aMidPar, aPnt2D);
bFlag2 = IsPointInOnFace(aF2, aPnt2D);
return bFlag2;
for (Standard_Integer i = 0; (i < 2) && bFlag; ++i)
{
const Handle(Geom2d_Curve) &aPC = *anArrPC[i];
const TopoDS_Face &aF = *anArrF[i];
if (!aPC.IsNull())
{
aPC->D0(aMidPar, aPnt2D);
bFlag = IsPointInOnFace(aF, aPnt2D);
}
else
{
bFlag = IsValidPointForFace(aP, aF, theTol);
}
}
//
bFlag1=IsValidBlockForFace (aT1, aT2, aC, aF1, aTol);
if (!bFlag1) {
return bFlag1;
}
bFlag2=IsValidBlockForFace (aT1, aT2, aC, aF2, aTol);
return bFlag2;
return bFlag;
}
//=======================================================================
//function : IsVertexOnLine

View File

@@ -541,19 +541,19 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
const char** a)
{
if (n<3) {
di << " use bopcurves F1 F2\n";
di << " use bopcurves F1 F2 [-2d/-2d1/-2d2]\n";
return 1;
}
//
TopoDS_Shape S1 = DBRep::Get(a[1]);
TopoDS_Shape S2 = DBRep::Get(a[2]);
TopAbs_ShapeEnum aType;
//
if (S1.IsNull() || S2.IsNull()) {
di << " Null shapes is not allowed \n";
return 1;
}
//
aType=S1.ShapeType();
if (aType != TopAbs_FACE) {
di << " Type mismatch F1\n";
@@ -564,38 +564,53 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
di << " Type mismatch F2\n";
return 1;
}
//
const TopoDS_Face& aF1=*(TopoDS_Face*)(&S1);
const TopoDS_Face& aF2=*(TopoDS_Face*)(&S2);
//
Standard_Boolean aToApproxC3d, aToApproxC2dOnS1, aToApproxC2dOnS2, anIsDone;
Standard_Integer i, aNbCurves;
Standard_Real anAppTol, aTolR;
TCollection_AsciiString aNm("c_");
aToApproxC3d=Standard_True;
aToApproxC2dOnS1=Standard_False;
aToApproxC2dOnS2=Standard_False;
anAppTol=0.0000001;
//
anAppTol = 0.0000001;
aToApproxC3d = Standard_True;
aToApproxC2dOnS1 = Standard_False;
aToApproxC2dOnS2 = Standard_False;
//
if (n > 3) {
if (!strcasecmp(a[3],"-2d")) {
aToApproxC2dOnS1 = Standard_True;
aToApproxC2dOnS2 = Standard_True;
}
else if (!strcasecmp(a[3],"-2d1")) {
aToApproxC2dOnS1 = Standard_True;
}
else if (!strcasecmp(a[3],"-2d2")) {
aToApproxC2dOnS2 = Standard_True;
}
else {
di << "Wrong key. To build 2d curves use: bopcurves F1 F2 -2d/-2d1/-2d2 \n";
return 1;
}
}
//
IntTools_FaceFace aFF;
//
aFF.SetParameters (aToApproxC3d,
aToApproxC2dOnS1,
aToApproxC2dOnS2,
anAppTol);
//
aFF.Perform (aF1, aF2);
//
anIsDone=aFF.IsDone();
if (!anIsDone) {
di << " anIsDone=" << (Standard_Integer) anIsDone << "\n";
return 1;
}
aFF.PrepareLines3D();
//
aFF.PrepareLines3D(Standard_False);
const IntTools_SequenceOfCurves& aSCs=aFF.Lines();
//
@@ -607,25 +622,60 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
di << " has no 3d curve\n";
return 1;
}
else
{
di << aNbCurves << " curve(s) found.\n";
}
for (i=1; i<=aNbCurves; i++) {
const IntTools_Curve& anIC=aSCs(i);
Handle (Geom_Curve) aC3D=anIC.Curve();
Handle (Geom_Curve) aC3D = anIC.Curve();
if (aC3D.IsNull()) {
di << " has Null 3d curve# " << i << "%d\n";
di << " has Null 3d curve# " << i << "\n";
continue;
}
TCollection_AsciiString anIndx(i), aNmx;
aNmx=aNm+anIndx;
Standard_CString name= aNmx.ToCString();
DrawTrSurf::Set(name, aC3D);
di << name << " ";
}
aNmx = aNm + anIndx;
Standard_CString nameC = aNmx.ToCString();
DrawTrSurf::Set(nameC, aC3D);
di << nameC << " ";
//
Handle(Geom2d_Curve) aPC1 = anIC.FirstCurve2d();
Handle(Geom2d_Curve) aPC2 = anIC.SecondCurve2d();
//
if (!aPC1.IsNull() || !aPC2.IsNull()) {
di << "(";
//
if (!aPC1.IsNull()) {
TCollection_AsciiString pc1N("c2d1_"), pc1Nx;
pc1Nx = pc1N + anIndx;
Standard_CString nameC2d1 = pc1Nx.ToCString();
//
DrawTrSurf::Set(nameC2d1, aPC1);
di << nameC2d1;
}
//
if (!aPC2.IsNull()) {
TCollection_AsciiString pc2N("c2d2_"), pc2Nx;
pc2Nx = pc2N + anIndx;
Standard_CString nameC2d2 = pc2Nx.ToCString();
//
DrawTrSurf::Set(nameC2d2, aPC2);
//
if (!aPC1.IsNull()) {
di << ", ";
}
di << nameC2d2;
}
di << ") ";
}
}
//
di << "\n";
return 0;
}

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

@@ -44,7 +44,7 @@ uses
--raises
is
ComputeVV(myclass;
ComputeVV(myclass;
aV1:Vertex from TopoDS;
aP2:Pnt from gp;
aTolP2:Real from Standard)
@@ -74,7 +74,7 @@ is
theF2: Face from TopoDS;
theCurve:Curve from IntTools;
thePC1:Boolean from Standard;
thePC2:Boolean from Standard);
thePC2:Boolean from Standard);
MakeContainer(myclass;
theType:ShapeEnum from TopAbs;
@@ -283,31 +283,7 @@ is
OrientFacesOnShell (myclass;
theS :out Shape from TopoDS);
CorrectTolerances (myclass;
theS: Shape from TopoDS;
theTolMax: Real from Standard =0.0001);
---Purpose:
--- Provides valid values of tolerances for the shape <theS>
--- <theTolMax> is max value of the tolerance that can be
--- accepted for correction. If real value of the tolerance
--- will be greater than <aTolMax>, the correction does not
--- perform.
---
CorrectCurveOnSurface (myclass;
theS: Shape from TopoDS;
theTolMax: Real from Standard =0.0001);
---Purpose:
--- Provides valid values of tolerances for the shape <theS>
--- in terms of BRepCheck_InvalidCurveOnSurface.
---
CorrectPointOnCurve (myclass;
theS: Shape from TopoDS;
theTolMax: Real from Standard =0.0001);
---Purpose:
--- Provides valid values of tolerances for the shape <theS>
--- in terms of BRepCheck_InvalidPointOnCurve.
---
--fields
--copy from BOPTools_AlgoTools.cdl
MakeNewVertex (myclass;
@@ -433,18 +409,61 @@ is
returns Boolean from Standard;
---Purpose:
--- Checks if it is possible to compute shrunk range for the edge <aE>.
---
CorrectShapeTolerances (myclass;
theS: Shape from TopoDS);
---Purpose:
--- Corrects tolerance values of the sub-shapes of the shape <theS> if needed.
---
---
Dimension(myclass;
theS:Shape from TopoDS)
returns Integer from Standard;
---Purpose:
--- Retutns dimension of the shape <theS>.
CorrectTolerances (myclass;
theS: Shape from TopoDS;
theTolMax: Real from Standard =0.0001);
---Purpose:
--- Provides valid values of tolerances for the shape <theS>
--- <theTolMax> is max value of the tolerance that can be
--- accepted for correction. If real value of the tolerance
--- will be greater than <aTolMax>, the correction does not
--- perform.
---
CorrectCurveOnSurface (myclass;
theS: Shape from TopoDS;
theTolMax: Real from Standard =0.0001);
---Purpose:
--- Provides valid values of tolerances for the shape <theS>
--- in terms of BRepCheck_InvalidCurveOnSurface.
---
CorrectPointOnCurve (myclass;
theS: Shape from TopoDS;
theTolMax: Real from Standard =0.0001);
---Purpose:
--- Provides valid values of tolerances for the shape <theS>
--- in terms of BRepCheck_InvalidPointOnCurve.
---
CorrectShapeTolerances (myclass;
theS: Shape from TopoDS);
---Purpose:
--- Corrects tolerance values of the sub-shapes of the shape <theS> if needed.
---
CorrectTolerances (myclass;
theS: Shape from TopoDS;
theMapToAvoid:IndexedMapOfShape from BOPCol;
theTolMax: Real from Standard =0.0001);
CorrectCurveOnSurface (myclass;
theS: Shape from TopoDS;
theMapToAvoid:IndexedMapOfShape from BOPCol;
theTolMax: Real from Standard =0.0001);
CorrectPointOnCurve (myclass;
theS: Shape from TopoDS;
theMapToAvoid:IndexedMapOfShape from BOPCol;
theTolMax: Real from Standard =0.0001);
CorrectShapeTolerances (myclass;
theS: Shape from TopoDS;
theMapToAvoid:IndexedMapOfShape from BOPCol);
end AlgoTools;

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

@@ -81,11 +81,13 @@
static
void CheckEdge (const TopoDS_Edge& E,
const Standard_Real aMaxTol);
const Standard_Real aMaxTol,
const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
const TopoDS_Face& S,
const Standard_Real aMaxTol);
const Standard_Real aMaxTol,
const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
Standard_Boolean Validate(const Adaptor3d_Curve& CRef,
const Adaptor3d_Curve& Other,
@@ -94,10 +96,12 @@ static
Standard_Real& aNewTolerance);
static
void CorrectVertexTolerance(const TopoDS_Edge& aE);
void CorrectVertexTolerance(const TopoDS_Edge& aE,
const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
void CorrectWires(const TopoDS_Face& aF);
void CorrectWires(const TopoDS_Face& aF,
const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
Standard_Real IntersectCurves2d(const gp_Pnt& aPV,
@@ -106,28 +110,112 @@ static
const TopoDS_Edge& aE2);
static
void UpdateEdges(const TopoDS_Face& aF);
void UpdateEdges(const TopoDS_Face& aF,
const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
void UpdateVertices(const TopoDS_Edge& aE);
void UpdateVertices(const TopoDS_Edge& aE,
const BOPCol_IndexedMapOfShape& aMapToAvoid);
static
void UpdateShape(const TopoDS_Shape& aS,
const Standard_Real aTol,
const BOPCol_IndexedMapOfShape& aMapToAvoid);
//=======================================================================
// Function : CorrectTolerances
// purpose :
//=======================================================================
void BOPTools_AlgoTools::CorrectTolerances(const TopoDS_Shape& aShape,
const Standard_Real aMaxTol)
void BOPTools_AlgoTools::CorrectTolerances(const TopoDS_Shape& aShape,
const Standard_Real aMaxTol)
{
BOPTools_AlgoTools::CorrectPointOnCurve(aShape, aMaxTol);
BOPTools_AlgoTools::CorrectCurveOnSurface(aShape, aMaxTol);
BOPCol_IndexedMapOfShape aMapToAvoid;
//
CorrectTolerances(aShape, aMapToAvoid, aMaxTol);
}
//=======================================================================
// Function : CorrectShapeTolerances
// purpose :
//=======================================================================
void BOPTools_AlgoTools::CorrectShapeTolerances
(const TopoDS_Shape& aShape)
{
BOPCol_IndexedMapOfShape aMapToAvoid;
//
BOPTools_AlgoTools::CorrectShapeTolerances(aShape, aMapToAvoid);
}
//=======================================================================
// Function : CorrectPointOnCurve
// purpose :
//=======================================================================
void BOPTools_AlgoTools::CorrectPointOnCurve(const TopoDS_Shape& S,
const Standard_Real aMaxTol)
void BOPTools_AlgoTools::CorrectPointOnCurve
(const TopoDS_Shape& S,
const Standard_Real aMaxTol)
{
BOPCol_IndexedMapOfShape aMapToAvoid;
//
BOPTools_AlgoTools::CorrectPointOnCurve(S, aMapToAvoid, aMaxTol);
}
//=======================================================================
// Function : CorrectCurveOnSurface
// purpose :
//=======================================================================
void BOPTools_AlgoTools::CorrectCurveOnSurface
(const TopoDS_Shape& S,
const Standard_Real aMaxTol)
{
BOPCol_IndexedMapOfShape aMapToAvoid;
//
BOPTools_AlgoTools::CorrectCurveOnSurface(S, aMapToAvoid, aMaxTol);
}
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//=======================================================================
// Function : CorrectTolerances
// purpose :
//=======================================================================
void BOPTools_AlgoTools::CorrectTolerances
(const TopoDS_Shape& aShape,
const BOPCol_IndexedMapOfShape& aMapToAvoid,
const Standard_Real aMaxTol)
{
BOPTools_AlgoTools::CorrectPointOnCurve(aShape, aMapToAvoid, aMaxTol);
BOPTools_AlgoTools::CorrectCurveOnSurface(aShape, aMapToAvoid,aMaxTol);
}
//=======================================================================
// Function : CorrectShapeTolerances
// purpose :
//=======================================================================
void BOPTools_AlgoTools::CorrectShapeTolerances
(const TopoDS_Shape& aShape,
const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
TopExp_Explorer aExp;
Standard_Integer aDim;
//
aDim=Dimension(aShape);
if (aDim == 1) {
aExp.Init(aShape, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Edge& aE = *(TopoDS_Edge*)&aExp.Current();
UpdateVertices(aE, aMapToAvoid);
}
}
else {
aExp.Init(aShape, TopAbs_FACE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Face& aF = *(TopoDS_Face*)&aExp.Current();
UpdateEdges(aF, aMapToAvoid);
}
}
}
//=======================================================================
// Function : CorrectPointOnCurve
// purpose :
//=======================================================================
void BOPTools_AlgoTools::CorrectPointOnCurve
(const TopoDS_Shape& S,
const BOPCol_IndexedMapOfShape& aMapToAvoid,
const Standard_Real aMaxTol)
{
Standard_Integer i, aNb;
TopTools_IndexedMapOfShape Edges;
@@ -135,16 +223,17 @@ static
aNb=Edges.Extent();
for (i=1; i<=aNb; i++) {
const TopoDS_Edge& E= TopoDS::Edge(Edges(i));
CheckEdge(E, aMaxTol);
CheckEdge(E, aMaxTol, aMapToAvoid);
}
}
//=======================================================================
// Function : CorrectCurveOnSurface
// purpose :
//=======================================================================
void BOPTools_AlgoTools::CorrectCurveOnSurface(const TopoDS_Shape& S,
const Standard_Real aMaxTol)
void BOPTools_AlgoTools::CorrectCurveOnSurface
(const TopoDS_Shape& S,
const BOPCol_IndexedMapOfShape& aMapToAvoid,
const Standard_Real aMaxTol)
{
Standard_Integer i, aNbFaces, j, aNbEdges;
TopTools_IndexedMapOfShape Faces;
@@ -154,14 +243,14 @@ static
for (i=1; i<=aNbFaces; i++) {
const TopoDS_Face& F= TopoDS::Face(Faces(i));
//
CorrectWires(F);
CorrectWires(F, aMapToAvoid);
//
TopTools_IndexedMapOfShape Edges;
TopExp::MapShapes (F, TopAbs_EDGE, Edges);
aNbEdges=Edges.Extent();
for (j=1; j<=aNbEdges; j++) {
const TopoDS_Edge& E= TopoDS::Edge(Edges(j));
CorrectEdgeTolerance (E, F, aMaxTol);
CorrectEdgeTolerance (E, F, aMaxTol, aMapToAvoid);
}
}
}
@@ -169,14 +258,15 @@ static
// Function : CorrectWires
// purpose :
//=======================================================================
void CorrectWires(const TopoDS_Face& aFx)
void CorrectWires(const TopoDS_Face& aFx,
const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
Standard_Integer i, aNbV;
Standard_Real aTol, aTol2, aD2, aD2max, aT1, aT2, aT, aTol2d;
gp_Pnt aP, aPV;
gp_Pnt2d aP2D;
TopoDS_Face aF;
BRep_Builder aBB;
//BRep_Builder aBB;
TopTools_IndexedDataMapOfShapeListOfShape aMVE;
TopTools_ListIteratorOfListOfShape aIt, aIt1;
//
@@ -232,7 +322,8 @@ void CorrectWires(const TopoDS_Face& aFx)
}
if (aD2max>aTol2) {
aTol=sqrt(aD2max);
aBB.UpdateVertex(aV, aTol);
UpdateShape(aV, aTol, aMapToAvoid);
//aBB.UpdateVertex(aV, aTol);
}
}
}
@@ -294,7 +385,8 @@ Standard_Real IntersectCurves2d(const gp_Pnt& aPV,
//=======================================================================
void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
const TopoDS_Face& S,
const Standard_Real aMaxTol)
const Standard_Real aMaxTol,
const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
//
// 1. Minimum of conditions to Perform
@@ -435,9 +527,9 @@ void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
}
//
if (aNewTol<aMaxTol) {
TE->UpdateTolerance(aNewTol+Delta);
//
CorrectVertexTolerance(myShape);
UpdateShape(myShape, aNewTol+Delta, aMapToAvoid);
//TE->UpdateTolerance(aNewTol+Delta);
CorrectVertexTolerance(myShape, aMapToAvoid);
}
}
@@ -453,8 +545,9 @@ void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
//return;//BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
}
if (aNewTol<aMaxTol) {
TE->UpdateTolerance(aNewTol+Delta);
CorrectVertexTolerance(myShape);
UpdateShape(myShape, aNewTol+Delta, aMapToAvoid);
//TE->UpdateTolerance(aNewTol+Delta);
CorrectVertexTolerance(myShape, aMapToAvoid);
}
}
}
@@ -501,8 +594,9 @@ void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
if (okx) {
//return;//BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface);
if (aNewTol<aMaxTol) {
TE->UpdateTolerance(aNewTol+Delta);
CorrectVertexTolerance(myShape);
UpdateShape(myShape, aNewTol+Delta, aMapToAvoid);
//TE->UpdateTolerance(aNewTol+Delta);
CorrectVertexTolerance(myShape, aMapToAvoid);
}
}
}
@@ -511,37 +605,12 @@ void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
} // end of 2. Tolerances in InContext
}
//=======================================================================
// Function : CorrectShapeTolerances
// purpose :
//=======================================================================
void BOPTools_AlgoTools::CorrectShapeTolerances(const TopoDS_Shape& aShape)
{
TopExp_Explorer aExp;
Standard_Integer aDim;
//
aDim=Dimension(aShape);
if (aDim == 1) {
aExp.Init(aShape, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Edge& aE = *(TopoDS_Edge*)&aExp.Current();
UpdateVertices(aE);
}
} else {
aExp.Init(aShape, TopAbs_FACE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Face& aF = *(TopoDS_Face*)&aExp.Current();
UpdateEdges(aF);
}
}
}
//=======================================================================
//function : CorrectVertexTolerance
//purpose :
//=======================================================================
void CorrectVertexTolerance(const TopoDS_Edge& aE)
void CorrectVertexTolerance(const TopoDS_Edge& aE,
const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
Standard_Integer k, aNbV;
Standard_Real aTolE, aTolV;
@@ -555,8 +624,9 @@ void CorrectVertexTolerance(const TopoDS_Edge& aE)
const TopoDS_Vertex& aV=TopoDS::Vertex(aVMap(k));
aTolV=BRep_Tool::Tolerance(aV);
if (aTolV<aTolE) {
Handle(BRep_TVertex)& aTV = *((Handle(BRep_TVertex)*)&aV.TShape());
aTV->UpdateTolerance(aTolE);
UpdateShape(aV, aTolE, aMapToAvoid);
//Handle(BRep_TVertex)& aTV = *((Handle(BRep_TVertex)*)&aV.TShape());
//aTV->UpdateTolerance(aTolE);
}
}
}
@@ -677,12 +747,13 @@ Standard_Boolean Validate(const Adaptor3d_Curve& CRef,
return aFlag;
}
//=======================================================================
// Function : CheckEdge
// purpose : Correct tolerances for Vertices on Edge
//=======================================================================
void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol)
void CheckEdge (const TopoDS_Edge& Ed,
const Standard_Real aMaxTol,
const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
TopoDS_Edge E=Ed;
E.Orientation(TopAbs_FORWARD);
@@ -726,8 +797,10 @@ void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol)
aD2=prep.SquareDistance(Controlp);
if (aD2 > Tol) {
aNewTolerance=sqrt(aD2)+dd;
if (aNewTolerance<aMaxTol)
TV->UpdateTolerance(aNewTolerance);
if (aNewTolerance<aMaxTol) {
UpdateShape(aVertex, aNewTolerance, aMapToAvoid);
//TV->UpdateTolerance(aNewTolerance);
}
}
}
itpr.Next();
@@ -747,8 +820,10 @@ void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol)
if (aD2 > Tol) {
aNewTolerance=sqrt(aD2)+dd;
if (aNewTolerance<aMaxTol)
TV->UpdateTolerance(aNewTolerance);
if (aNewTolerance<aMaxTol) {
UpdateShape(aVertex, aNewTolerance, aMapToAvoid);
//TV->UpdateTolerance(aNewTolerance);
}
}
}
}
@@ -757,16 +832,16 @@ void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol)
}
}
}
//=======================================================================
// Function : UpdateVertices
// purpose :
//=======================================================================
void UpdateVertices(const TopoDS_Edge& aE)
void UpdateVertices(const TopoDS_Edge& aE,
const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
Standard_Real aTolE, aTolV;
TopoDS_Iterator aItE;
BRep_Builder aBB;
//BRep_Builder aBB;
//
aTolE = BRep_Tool::Tolerance(aE);
aItE.Initialize(aE);
@@ -774,7 +849,8 @@ void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol)
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aItE.Value();
aTolV = BRep_Tool::Tolerance(aV);
if (aTolV < aTolE) {
aBB.UpdateVertex(aV, aTolE);
UpdateShape(aV, aTolE, aMapToAvoid);
//aBB.UpdateVertex(aV, aTolE);
}
}
}
@@ -782,11 +858,12 @@ void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol)
// Function : UpdateEdges
// purpose :
//=======================================================================
void UpdateEdges(const TopoDS_Face& aF)
void UpdateEdges(const TopoDS_Face& aF,
const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
Standard_Real aTolF, aTolE, aTolV;
TopoDS_Iterator aItF, aItW, aItE;
BRep_Builder aBB;
//BRep_Builder aBB;
//
aTolE = aTolF = BRep_Tool::Tolerance(aF);
aItF.Initialize(aF);
@@ -798,18 +875,45 @@ void CheckEdge (const TopoDS_Edge& Ed, const Standard_Real aMaxTol)
const TopoDS_Edge& aE = *(TopoDS_Edge*)&aItW.Value();
aTolE = BRep_Tool::Tolerance(aE);
if (aTolE < aTolF) {
aBB.UpdateEdge(aE, aTolF);
UpdateShape(aE, aTolF,aMapToAvoid);
//aBB.UpdateEdge(aE, aTolF);
aTolE = aTolF;
}
UpdateVertices(aE);
UpdateVertices(aE, aMapToAvoid);
}
}
else {
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aItF.Value();
aTolV = BRep_Tool::Tolerance(aV);
if (aTolV < aTolE) {
aBB.UpdateVertex(aV, aTolF);
UpdateShape(aV, aTolF,aMapToAvoid);
//aBB.UpdateVertex(aV, aTolF);
}
}
}
}
//=======================================================================
//function : UpdateShape
//purpose :
//=======================================================================
void UpdateShape(const TopoDS_Shape& aS,
const Standard_Real aTol,
const BOPCol_IndexedMapOfShape& aMapToAvoid)
{
if (aMapToAvoid.Contains(aS)) {
return;
}
//
TopAbs_ShapeEnum aType;
BRep_Builder aBB;
//
aType=aS.ShapeType();
if (aType==TopAbs_EDGE) {
const TopoDS_Edge& aE = *((TopoDS_Edge*)&aS);
aBB.UpdateEdge(aE, aTol);
}
else if (aType==TopAbs_VERTEX) {
const TopoDS_Vertex& aV = *((TopoDS_Vertex*)&aS);
aBB.UpdateVertex(aV, aTol);
}
}

View File

@@ -424,6 +424,9 @@ void BRep_Builder::MakeFace(TopoDS_Face& F,
const Standard_Real Tol) const
{
Handle(BRep_TFace) TF = new BRep_TFace();
if(!F.IsNull() && F.Locked()) {
Standard_NullObject::Raise("BRep_Builder::MakeFace");
}
TF->Surface(S);
TF->Tolerance(Tol);
MakeShape(F,TF);
@@ -439,6 +442,9 @@ void BRep_Builder::MakeFace(TopoDS_Face& F,
const Handle(Poly_Triangulation)& T) const
{
Handle(BRep_TFace) TF = new BRep_TFace();
if(!F.IsNull() && F.Locked()) {
Standard_NullObject::Raise("BRep_Builder::MakeFace");
}
TF->Triangulation(T);
MakeShape(F, TF);
}
@@ -455,6 +461,9 @@ void BRep_Builder::MakeFace(TopoDS_Face& F,
const Standard_Real Tol) const
{
Handle(BRep_TFace) TF = new BRep_TFace();
if(!F.IsNull() && F.Locked()) {
Standard_NullObject::Raise("BRep_Builder::MakeFace");
}
TF->Surface(S);
TF->Tolerance(Tol);
TF->Location(L);
@@ -473,6 +482,9 @@ void BRep_Builder::UpdateFace(const TopoDS_Face& F,
const Standard_Real Tol) const
{
const Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &F.TShape());
if(!F.IsNull() && F.Locked()) {
Standard_NullObject::Raise("BRep_Builder::UpdateFace");
}
TF->Surface(S);
TF->Tolerance(Tol);
TF->Location(L.Predivided(F.Location()));
@@ -488,6 +500,11 @@ void BRep_Builder::UpdateFace(const TopoDS_Face& F,
void BRep_Builder::UpdateFace(const TopoDS_Face& F,
const Handle(Poly_Triangulation)& T) const
{
const Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &F.TShape());
if(TF->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateFace");
}
(*((Handle(BRep_TFace)*) &F.TShape()))->Triangulation(T);
F.TShape()->Modified(Standard_True);
}
@@ -501,6 +518,11 @@ void BRep_Builder::UpdateFace(const TopoDS_Face& F,
void BRep_Builder::UpdateFace(const TopoDS_Face& F,
const Standard_Real Tol) const
{
const Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &F.TShape());
if(TF->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateFace");
}
(*((Handle(BRep_TFace)*) &F.TShape()))->Tolerance(Tol);
F.TShape()->Modified(Standard_True);
}
@@ -514,6 +536,11 @@ void BRep_Builder::UpdateFace(const TopoDS_Face& F,
void BRep_Builder::NaturalRestriction(const TopoDS_Face& F,
const Standard_Boolean N) const
{
const Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &F.TShape());
if(TF->Locked())
{
Standard_NullObject::Raise("BRep_Builder::NaturalRestriction");
}
(*((Handle(BRep_TFace)*) &F.TShape()))->NaturalRestriction(N);
F.TShape()->Modified(Standard_True);
}
@@ -527,6 +554,10 @@ void BRep_Builder::NaturalRestriction(const TopoDS_Face& F,
void BRep_Builder::MakeEdge(TopoDS_Edge& E) const
{
Handle(BRep_TEdge) TE = new BRep_TEdge();
if(!E.IsNull() && E.Locked())
{
Standard_NullObject::Raise("BRep_Builder::MakeEdge");
}
TE->Closed(Standard_False);
MakeShape(E,TE);
}
@@ -544,7 +575,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
const TopLoc_Location l = L.Predivided(E.Location());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateEdge");
}
UpdateCurves(TE->ChangeCurves(),C,l);
if (!C.IsNull()) TE->Closed(C->IsClosed());
@@ -565,6 +599,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
const Standard_Real Tol) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateEdge");
}
const TopLoc_Location l = L.Predivided(E.Location());
UpdateCurves(TE->ChangeCurves(),C,S,l);
@@ -588,6 +626,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
const gp_Pnt2d& Pl) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateEdge");
}
const TopLoc_Location l = L.Predivided(E.Location());
UpdateCurves(TE->ChangeCurves(),C,S,l,Pf,Pl);
@@ -610,6 +652,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
const Standard_Real Tol) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateEdge");
}
const TopLoc_Location l = L.Predivided(E.Location());
UpdateCurves(TE->ChangeCurves(),C1,C2,S,l);
@@ -636,6 +682,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
const gp_Pnt2d& Pl) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateEdge");
}
const TopLoc_Location l = L.Predivided(E.Location());
UpdateCurves(TE->ChangeCurves(),C1,C2,S,l,Pf,Pl);
@@ -657,7 +707,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
const TopLoc_Location& L) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateEdge");
}
BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves();
BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr);
@@ -694,6 +747,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
const TopLoc_Location& L) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateEdge");
}
const TopLoc_Location l = L.Predivided(E.Location());
Standard_Boolean isModified = Standard_False;
@@ -741,6 +798,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
const TopLoc_Location& L) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateEdge");
}
const TopLoc_Location l = L.Predivided(E.Location());
Standard_Boolean isModified = Standard_False;
@@ -800,6 +861,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
const TopLoc_Location& L) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateEdge");
}
TopLoc_Location l = L.Predivided(E.Location());
BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves();
@@ -854,6 +919,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
const TopLoc_Location& L) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateEdge");
}
TopLoc_Location l = L.Predivided(E.Location());
BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves();
@@ -890,6 +959,10 @@ void BRep_Builder::UpdateEdge(const TopoDS_Edge& E,
const Standard_Real Tol) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateEdge");
}
TE->UpdateTolerance(Tol);
TE->Modified(Standard_True);
}
@@ -924,7 +997,10 @@ void BRep_Builder::Continuity(const TopoDS_Edge& E,
const GeomAbs_Shape C)const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::Continuity");
}
const TopLoc_Location l1 = L1.Predivided(E.Location());
const TopLoc_Location l2 = L2.Predivided(E.Location());
@@ -941,7 +1017,11 @@ void BRep_Builder::Continuity(const TopoDS_Edge& E,
void BRep_Builder::SameParameter(const TopoDS_Edge& E,
const Standard_Boolean S) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::SameParameter");
}
TE->SameParameter(S);
TE->Modified(Standard_True);
}
@@ -955,6 +1035,10 @@ void BRep_Builder::SameRange(const TopoDS_Edge& E,
const Standard_Boolean S) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::SameRange");
}
TE->SameRange(S);
TE->Modified(Standard_True);
}
@@ -968,6 +1052,10 @@ void BRep_Builder::Degenerated(const TopoDS_Edge& E,
const Standard_Boolean D) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::Degenerated");
}
TE->Degenerated(D);
if (D) {
// set a null 3d curve
@@ -989,7 +1077,10 @@ void BRep_Builder::Range(const TopoDS_Edge& E,
{
// set the range to all the representations if Only3d=FALSE
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::Range");
}
BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves();
BRep_ListIteratorOfListOfCurveRepresentation itcr(lcr);
Handle(BRep_GCurve) GC;
@@ -1032,6 +1123,10 @@ void BRep_Builder::Range(const TopoDS_Edge& E,
const Standard_Real Last) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::Range");
}
const TopLoc_Location l = L.Predivided(E.Location());
BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves();
@@ -1074,7 +1169,10 @@ void BRep_Builder::Transfert(const TopoDS_Edge& Ein,
const TopoDS_Edge& Eout) const
{
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &Ein.TShape());
if(TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::Transfert");
}
const Standard_Real tol = TE->Tolerance();
BRep_ListOfCurveRepresentation& lcr = TE->ChangeCurves();
@@ -1123,7 +1221,10 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V,
const Standard_Real Tol) const
{
const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape());
if(TV->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateVertex");
}
TV->Pnt(P.Transformed(V.Location().Inverted().Transformation()));
TV->UpdateTolerance(Tol);
TV->Modified(Standard_True);
@@ -1146,7 +1247,10 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V,
const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape());
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TV->Locked() || TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateVertex");
}
TopLoc_Location L = E.Location().Predivided(V.Location());
// Search the vertex in the edge
@@ -1227,8 +1331,10 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V,
const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape());
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &E.TShape());
if(TV->Locked() || TE->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateVertex");
}
// Search the vertex in the edge
TopAbs_Orientation ori = TopAbs_INTERNAL;
@@ -1294,7 +1400,10 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& Ve,
const Standard_Real Tol) const
{
const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &Ve.TShape());
if(TV->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateVertex");
}
TopLoc_Location L;
const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,L);
L = L.Predivided(Ve.Location());
@@ -1314,6 +1423,10 @@ void BRep_Builder::UpdateVertex(const TopoDS_Vertex& V,
const Standard_Real Tol) const
{
const Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape());
if(TV->Locked())
{
Standard_NullObject::Raise("BRep_Builder::UpdateVertex");
}
TV->UpdateTolerance(Tol);
TV->Modified(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.
@@ -32,6 +32,7 @@
#include <BRep_PolygonOnClosedTriangulation.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Wire.hxx>
#include <TopExp_Explorer.hxx>
#include <TopExp.hxx>
#include <TopTools_MapOfShape.hxx>
@@ -52,6 +53,10 @@
#include <Poly_Polygon2D.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <NCollection_Map.hxx>
#include <NCollection_IncAllocator.hxx>
#include <TopTools_ShapeMapHasher.hxx>
//modified by NIZNHY-PKV Fri Oct 17 14:13:29 2008f
static
Standard_Boolean IsPlane(const Handle(Geom_Surface)& aS);
@@ -314,40 +319,42 @@ Handle(Geom2d_Curve) BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
GP = Handle(Geom_Plane)::DownCast(S);
//fin modif du 21-05-97
if (!GP.IsNull()) {
if (!GP.IsNull())
{
Handle(GeomAdaptor_HCurve) HC;
Handle(GeomAdaptor_HSurface) HS;
HC = new GeomAdaptor_HCurve();
HS = new GeomAdaptor_HSurface();
TopLoc_Location LC;
TopLoc_Location aCurveLocation;
Standard_Real f, l;// for those who call with (u,u).
Handle(Geom_Curve) C3d =
BRep_Tool::Curve(E,/*LC,*/f,l); // transforming plane instead of curve
// we can loose scale factor of Curve transformation (eap 13 May 2002)
Handle(Geom_Curve) C3d = BRep_Tool::Curve(E, aCurveLocation, f, l);
LC = L/*.Predivided(LC)*/;
if (C3d.IsNull())
{
return nullPCurve;
}
if (C3d.IsNull()) return nullPCurve;
aCurveLocation = L.Predivided(aCurveLocation);
Handle(Geom_Plane) Plane = GP;
if (!LC.IsIdentity()) {
const gp_Trsf& T = LC.Transformation();
if (!aCurveLocation.IsIdentity())
{
const gp_Trsf& T = aCurveLocation.Transformation();
Handle(Geom_Geometry) GPT = GP->Transformed(T);
Plane = *((Handle(Geom_Plane)*)&GPT);
}
GeomAdaptor_Surface& GAS = HS->ChangeSurface();
GAS.Load(Plane);
Handle(Geom_Curve) ProjOnPlane =
GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,f,l),
Plane,
Plane->Position().Direction(),
Standard_True);
GeomAdaptor_Curve& GAC = HC->ChangeCurve();
GAC.Load(ProjOnPlane);
@@ -1139,6 +1146,12 @@ Standard_Boolean BRep_Tool::HasContinuity(const TopoDS_Edge& E)
gp_Pnt BRep_Tool::Pnt(const TopoDS_Vertex& V)
{
Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &V.TShape());
if (TV.IsNull())
{
Standard_NullObject::Raise("BRep_Tool:: TopoDS_Vertex hasn't gp_Pnt");
}
gp_Pnt P = TV->Pnt();
P.Transform(V.Location().Transformation());
return P;
@@ -1151,7 +1164,14 @@ gp_Pnt BRep_Tool::Pnt(const TopoDS_Vertex& V)
Standard_Real BRep_Tool::Tolerance(const TopoDS_Vertex& V)
{
Standard_Real p = (*((Handle(BRep_TVertex)*)&V.TShape()))->Tolerance();
Handle(BRep_TVertex)& aTVert = *((Handle(BRep_TVertex)*)&V.TShape());
if (aTVert.IsNull())
{
Standard_NullObject::Raise("BRep_Tool:: TopoDS_Vertex hasn't gp_Pnt");
}
Standard_Real p = aTVert->Tolerance();
Standard_Real pMin = Precision::Confusion();
if (p > pMin) return p;
else return pMin;
@@ -1431,24 +1451,43 @@ gp_Pnt2d BRep_Tool::Parameters(const TopoDS_Vertex& V,
}
//=======================================================================
//function : IsClosed
//purpose : Returns <True> if S if flaged Closed, if S is a
// Solid,Shell or Compound returns <True> is S has no free boundaries.
//purpose :
//=======================================================================
Standard_Boolean BRep_Tool::IsClosed(const TopoDS_Shape& S)
Standard_Boolean BRep_Tool::IsClosed (const TopoDS_Shape& theShape)
{
if (S.ShapeType() == TopAbs_SHELL || S.ShapeType() == TopAbs_SOLID ||
S.ShapeType() == TopAbs_COMPOUND) {
TopTools_MapOfShape M;
TopExp_Explorer exp;
for (exp.Init(S,TopAbs_EDGE); exp.More(); exp.Next()) {
// for (TopExp_Explorer exp(S,TopAbs_EDGE); exp.More(); exp.Next()) {
if (theShape.ShapeType() == TopAbs_SHELL || theShape.ShapeType() == TopAbs_SOLID)
{
NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher> aMap (101, new NCollection_IncAllocator);
TopExp_Explorer exp (theShape.Oriented(TopAbs_FORWARD), TopAbs_EDGE);
Standard_Boolean hasBound = Standard_False;
for (; exp.More(); exp.Next())
{
const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
if (BRep_Tool::Degenerated(E)) continue;
if (!M.Add(E)) M.Remove(E);
if (BRep_Tool::Degenerated(E) || E.Orientation() == TopAbs_INTERNAL || E.Orientation() == TopAbs_EXTERNAL)
continue;
hasBound = Standard_True;
if (!aMap.Add(E))
aMap.Remove(E);
}
if ( M.IsEmpty()) return 1;
return hasBound && aMap.IsEmpty();
}
return (S.Closed());
else if (theShape.ShapeType() == TopAbs_WIRE)
{
NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher> aMap (101, new NCollection_IncAllocator);
TopExp_Explorer exp (theShape.Oriented(TopAbs_FORWARD), TopAbs_VERTEX);
Standard_Boolean hasBound = Standard_False;
for (; exp.More(); exp.Next())
{
const TopoDS_Shape& V = exp.Current();
if (V.Orientation() == TopAbs_INTERNAL || V.Orientation() == TopAbs_EXTERNAL)
continue;
hasBound = Standard_True;
if (!aMap.Add(V))
aMap.Remove(V);
}
return hasBound && aMap.IsEmpty();
}
return theShape.Closed();
}
//modified by NIZNHY-PKV Fri Oct 17 14:09:58 2008 f
@@ -1480,3 +1519,4 @@ Standard_Boolean IsPlane(const Handle(Geom_Surface)& aS)
//
return bRet;
}

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

@@ -124,6 +124,7 @@
#include <BRepBuilderAPI_CellFilter.hxx>
#include <BRepBuilderAPI_BndBoxTreeSelector.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <BRep_TEdge.hxx>
//=======================================================================
//function : SameRange
@@ -934,11 +935,25 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirs
if (dist > dist2)
dist2 = dist;
}
maxTol = Max(sqrt(dist2), Precision::Confusion());
maxTol = Max(sqrt(dist2) * (1. + 1e-7), Precision::Confusion());
//maxTol = Max(sqrt(dist2), Precision::Confusion());
}
}
if(maxTol >= 0. && maxTol < tolReached)
{
if (tolReached > MaxTolerance())
{
// Set tolerance directly to overwrite too large tolerance
static_cast<BRep_TEdge*>(edge.TShape().operator->())->Tolerance(maxTol);
}
else
{
// just update tolerance with computed distance
aBuilder.UpdateEdge(edge, maxTol);
}
}
aBuilder.SameParameter(edge,Standard_True);
}
}

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

View File

@@ -1549,7 +1549,8 @@ static void Propagate(const TopTools_IndexedDataMapOfShapeListOfShape& mapVE,
for (; itrc.More(); itrc.Next())
{
const TopoDS_Shape& Edge = itrc.Value();
mapE.Add(Edge);
if (!mapE.Contains(Edge))
mapE.Add(Edge);
TopExp_Explorer ex(Edge, TopAbs_VERTEX);
for (; ex.More(); ex.Next())
@@ -1565,7 +1566,10 @@ static void Propagate(const TopTools_IndexedDataMapOfShapeListOfShape& mapVE,
{
const TopoDS_Shape& E = itl.Value();
if (!Edge.IsSame(E) && !mapE.Contains(E))
{
mapE.Add(E);
nextEdges.Append(E);
}
}
}
}

2
src/BRepCheck/FILES Normal file
View File

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

View File

@@ -23,6 +23,10 @@
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
static const Standard_Real Probing_Start = 0.123;
static const Standard_Real Probing_End = 0.7;
static const Standard_Real Probing_Step = 0.2111;
//=======================================================================
//function : BRepClass_FaceExplorer
//purpose :
@@ -31,7 +35,7 @@
BRepClass_FaceExplorer::BRepClass_FaceExplorer(const TopoDS_Face& F) :
myFace(F),
myCurEdgeInd(1),
myCurEdgePar(0.123)
myCurEdgePar(Probing_Start)
{
myFace.Orientation(TopAbs_FORWARD);
}
@@ -56,7 +60,7 @@ Standard_Boolean BRepClass_FaceExplorer::Segment(const gp_Pnt2d& P,
Standard_Real& Par)
{
myCurEdgeInd = 1;
myCurEdgePar = 0.123;
myCurEdgePar = Probing_Start;
return OtherSegment(P, L, Par);
}
@@ -75,7 +79,7 @@ Standard_Boolean BRepClass_FaceExplorer::OtherSegment(const gp_Pnt2d& P,
Standard_Real aFPar;
Standard_Real aLPar;
Handle(Geom2d_Curve) aC2d;
Standard_Real aTolParConf = Precision::PConfusion();
Standard_Real aTolParConf2 = Precision::PConfusion() * Precision::PConfusion();
gp_Pnt2d aPOnC;
Standard_Real aParamIn;
@@ -103,32 +107,51 @@ Standard_Boolean BRepClass_FaceExplorer::OtherSegment(const gp_Pnt2d& P,
} else if (Precision::IsPositiveInfinite(aLPar))
aLPar = aFPar + 1.;
for (; myCurEdgePar < 0.7 ;myCurEdgePar += 0.2111) {
for (; myCurEdgePar < Probing_End ;myCurEdgePar += Probing_Step) {
aParamIn = myCurEdgePar*aFPar + (1. - myCurEdgePar)*aLPar;
aC2d->D0(aParamIn, aPOnC);
Par = aPOnC.Distance(P);
gp_Vec2d aTanVec;
aC2d->D1(aParamIn, aPOnC, aTanVec);
Par = aPOnC.SquareDistance(P);
if (Par > aTolParConf) {
if (Par > aTolParConf2) {
gp_Vec2d aLinVec(P, aPOnC);
gp_Dir2d aLinDir(aLinVec);
Standard_Real aTanMod = aTanVec.SquareMagnitude();
if (aTanMod < aTolParConf2)
continue;
aTanVec /= Sqrt(aTanMod);
Standard_Real aSinA = aTanVec.Crossed(aLinDir.XY());
const Standard_Real SmallAngle = 0.001;
if (Abs(aSinA) < SmallAngle)
{
// The line from the input point P to the current point on edge
// is tangent to the edge curve. This condition is bad for classification.
// Therefore try to go to another point in the hope that there will be
// no tangent. If there tangent is preserved then leave the last point in
// order to get this edge chanse to participate in classification.
if (myCurEdgePar + Probing_Step < Probing_End)
continue;
}
L = gp_Lin2d(P, aLinDir);
// Check if ends of a curve lie on a line.
aC2d->D0(aFPar, aPOnC);
if (L.Distance(aPOnC) > aTolParConf) {
if (L.SquareDistance(aPOnC) > aTolParConf2) {
aC2d->D0(aLPar, aPOnC);
if (L.Distance(aPOnC) > aTolParConf) {
myCurEdgePar += 0.2111;
if (L.SquareDistance(aPOnC) > aTolParConf2) {
myCurEdgePar += Probing_Step;
if (myCurEdgePar >= 0.7) {
if (myCurEdgePar >= Probing_End) {
myCurEdgeInd++;
myCurEdgePar = 0.123;
myCurEdgePar = Probing_Start;
}
Par = Sqrt(Par);
return Standard_True;
}
}
@@ -139,7 +162,7 @@ Standard_Boolean BRepClass_FaceExplorer::OtherSegment(const gp_Pnt2d& P,
// This curve is not valid for line construction. Go to another edge.
myCurEdgeInd++;
myCurEdgePar = 0.123;
myCurEdgePar = Probing_Start;
}
// nothing found, return an horizontal 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.
@@ -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

@@ -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.
@@ -14,6 +14,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepFill_LocationLaw.ixx>
#include <BRepTools_WireExplorer.hxx>
@@ -36,6 +37,7 @@
#include <TColgp_Array1OfVec2d.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <Precision.hxx>
#include <BRepBuilderAPI_Transform.hxx>
//=======================================================================
@@ -606,10 +608,11 @@ void BRepFill_LocationLaw::CurvilinearBounds(const Standard_Integer Index,
gp_Trsf fila;
fila.SetValues(M(1,1), M(1,2), M(1,3), V.X(),
M(2,1), M(2,2), M(2,3), V.Y(),
M(3,1), M(3,2), M(3,3), V.Z(),
1.e-12, 1.e-14);
TopLoc_Location Loc(fila);
W.Location(Loc.Multiplied(W.Location()));
M(3,1), M(3,2), M(3,3), V.Z());
//TopLoc_Location Loc(fila);
//W.Location(Loc.Multiplied(W.Location()));
W = BRepBuilderAPI_Transform(W, fila, Standard_True); //copy
///////////////////////////////////////////
}
else {
W.Nullify();

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

@@ -1934,6 +1934,14 @@ void UpdateDetromp (TopTools_ListOfShape& Detromp1,
TopoDS_Vertex V1,V2;
Handle(Geom2d_Curve) Bis = Bisec.Value();
Standard_Boolean ForceAdd = Standard_False;
Handle(Geom2d_TrimmedCurve) aTC = Handle(Geom2d_TrimmedCurve)::DownCast(Bis);
if(!aTC.IsNull() && aTC->BasisCurve()->IsPeriodic())
{
gp_Pnt2d Pf = Bis->Value(Bis->FirstParameter());
gp_Pnt2d Pl = Bis->Value(Bis->LastParameter());
ForceAdd = Pf.Distance(Pl) <= Precision::Confusion();
}
U1 = Bis->FirstParameter();
@@ -1948,7 +1956,7 @@ void UpdateDetromp (TopTools_ListOfShape& Detromp1,
V2 = TopoDS::Vertex(Vertices.Value(ii));
gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
if (!Trim.IsInside(P)) {
if (!Trim.IsInside(P) || ForceAdd) {
if (!V1.IsNull()) {
Detromp1.Append(V1);
Detromp2.Append(V1);
@@ -1966,7 +1974,7 @@ void UpdateDetromp (TopTools_ListOfShape& Detromp1,
if (!EOnE) {
if (!Precision::IsInfinite(U2)) {
gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
if (!Trim.IsInside(P)) {
if (!Trim.IsInside(P) || ForceAdd) {
if (!V1.IsNull()) {
Detromp1.Append(V1);
Detromp2.Append(V1);
@@ -2143,19 +2151,20 @@ void TrimEdge (const TopoDS_Edge& E,
#ifdef DRAW
if ( AffichEdge) {
sprintf(name,"TRIMEDGE_%d",NbTRIMEDGES);
sprintf(name,"TRIMEDGE_%d",++NbTRIMEDGES);
DBRep::Set(name,NewEdge);
}
if (Affich2d) {
if (Affich2d || AffichEdge) {
if(!AffichEdge) ++NbTRIMEDGES;
TopLoc_Location L;
Standard_Real f,l;
Handle(Geom_Surface) Surf;
Handle(Geom2d_Curve) C;
BRep_Tool::CurveOnSurface(NewEdge,C,Surf,L,f,l);
sprintf(name,"OFFSET2d_%d",NbTRIMEDGES++);
sprintf(name,"OFFSET2d_%d",NbTRIMEDGES);
Handle(Geom2d_TrimmedCurve) C2d = new Geom2d_TrimmedCurve(C,f,l);
Handle(DrawTrSurf_Curve2d) dr =
new DrawTrSurf_Curve2d(C2d,Standard_False);
new DrawTrSurf_Curve2d(C2d,Standard_False);
dr->SetColor(Draw_bleu);
Draw::Set(name,dr);
}

View File

@@ -168,8 +168,7 @@ void BRepFill_Pipe::Perform(const TopoDS_Wire& Spine,
myLoc->Law(1)->D0(first, M, V);
fila.SetValues(M(1,1), M(1,2), M(1,3), V.X(),
M(2,1), M(2,2), M(2,3), V.Y(),
M(3,1), M(3,2), M(3,3), V.Z(),
1.e-12, 1.e-14);
M(3,1), M(3,2), M(3,3), V.Z());
fila.Multiply(myTrsf);
TopLoc_Location LocFirst(fila);
@@ -183,8 +182,7 @@ void BRepFill_Pipe::Perform(const TopoDS_Wire& Spine,
// try { // Not good, but there are no other means to test SetValues
fila.SetValues(M(1,1), M(1,2), M(1,3), V.X(),
M(2,1), M(2,2), M(2,3), V.Y(),
M(3,1), M(3,2), M(3,3), V.Z(),
1.e-12, 1.e-14);
M(3,1), M(3,2), M(3,3), V.Z());
fila.Multiply(myTrsf);
TopLoc_Location LocLast(fila);
if (! myLoc->IsClosed() || LocFirst != LocLast) {

View File

@@ -2451,11 +2451,12 @@ BRepFill_Sweep::BRepFill_Sweep(const Handle(BRepFill_SectionLaw)& Section,
B.MakeCompound(Comp);
for (isec=1; isec <= NbLaw+1; isec++)
for (ipath=1, IPath=IFirst; ipath<= NbPath+1; ipath++, IPath++) {
if (ipath <= NbPath) myUEdges->SetValue(isec, IPath, UEdge(isec, ipath));
if (isec <= NbLaw) myVEdges->SetValue(isec, IPath, VEdge(isec, ipath));
if ((ipath <= NbPath) && (isec <= NbLaw) &&
(myFaces->Value(isec, IPath).ShapeType() == TopAbs_FACE))
B.Add(Comp, myFaces->Value(isec, IPath));
if (ipath <= NbPath) myUEdges->SetValue(isec, IPath, UEdge(isec, ipath));
if (isec <= NbLaw) myVEdges->SetValue(isec, IPath, VEdge(isec, ipath));
if ((ipath <= NbPath) && (isec <= NbLaw) &&
!myFaces->Value(isec, IPath).IsNull() &&
myFaces->Value(isec, IPath).ShapeType() == TopAbs_FACE)
B.Add(Comp, myFaces->Value(isec, IPath));
}
BRepLib::EncodeRegularity(Comp, myTolAngular);
}

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.
@@ -31,13 +31,17 @@
#include <Precision.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <IntRes2d_IntersectionSegment.hxx>
#include <ElCLib.hxx>
#include <StdFail_NotDone.hxx>
#ifdef DEB
//#define DRAW
#ifdef DRAW
#include <DrawTrSurf.hxx>
#include <DBRep.hxx>
static Standard_Boolean Affich = Standard_False;
static Standard_Boolean AffichInt = Standard_False;
static Standard_Integer intind = 0;
#endif
#endif
@@ -47,7 +51,7 @@ static Standard_Boolean Affich = Standard_False;
//=======================================================================
static void SimpleExpression (const Bisector_Bisec& B,
Handle(Geom2d_Curve)& Bis)
Handle(Geom2d_Curve)& Bis)
{
Bis = B.Value();
@@ -60,8 +64,8 @@ static void SimpleExpression (const Bisector_Bisec& B,
if (BT == STANDARD_TYPE(Bisector_BisecAna)) {
Bis = Handle(Bisector_BisecAna)::DownCast(BasBis)->Geom2dCurve();
Bis = new Geom2d_TrimmedCurve (Bis,
TrBis->FirstParameter(),
TrBis->LastParameter());
TrBis->FirstParameter(),
TrBis->LastParameter());
}
}
}
@@ -83,18 +87,18 @@ BRepFill_TrimEdgeTool::BRepFill_TrimEdgeTool()
//=======================================================================
BRepFill_TrimEdgeTool::BRepFill_TrimEdgeTool
(const Bisector_Bisec& Bisec,
const Handle(Geom2d_Geometry)& S1,
const Handle(Geom2d_Geometry)& S2,
const Standard_Real Offset) :
(const Bisector_Bisec& Bisec,
const Handle(Geom2d_Geometry)& S1,
const Handle(Geom2d_Geometry)& S2,
const Standard_Real Offset) :
myOffset(Offset),
myBisec(Bisec)
myBisec(Bisec)
{
isPoint1 = (S1->DynamicType() == STANDARD_TYPE(Geom2d_CartesianPoint));
isPoint2 = (S2->DynamicType() == STANDARD_TYPE(Geom2d_CartesianPoint));
// return geometries of shapes.
// Standard_Real f,l;
// return geometries of shapes.
// Standard_Real f,l;
if (isPoint1) {
myP1 = Handle(Geom2d_Point)::DownCast(S1)->Pnt2d();
}
@@ -102,10 +106,10 @@ myBisec(Bisec)
myC1 = Handle(Geom2d_Curve)::DownCast(S1);
#ifdef DRAW
if ( Affich) {
//POP pour NT
//POP pour NT
char* myC1name = "myC1";
DrawTrSurf::Set(myC1name,myC1);
// DrawTrSurf::Set("myC1",myC1);
// DrawTrSurf::Set("myC1",myC1);
}
#endif
}
@@ -118,7 +122,7 @@ myBisec(Bisec)
if ( Affich) {
char* myC2name = "myC2";
DrawTrSurf::Set(myC2name,myC2);
// DrawTrSurf::Set("myC2",myC2);
// DrawTrSurf::Set("myC2",myC2);
}
#endif
}
@@ -128,8 +132,8 @@ myBisec(Bisec)
myBis = Geom2dAdaptor_Curve(Bis);
#ifdef DRAW
if ( Affich) {
char* myBisname = "myBis";
DrawTrSurf::Set(myBisname,Bis);
char* myBisname = "myBis";
DrawTrSurf::Set(myBisname,Bis);
}
#endif
@@ -150,8 +154,8 @@ static void Bubble(TColgp_SequenceOfPnt& Seq)
gp_Pnt P1 = Seq.Value(i);
gp_Pnt P2 = Seq.Value(i+1);
if (P2.X()<P1.X()) {
Seq.Exchange(i,i+1);
Invert = Standard_True;
Seq.Exchange(i,i+1);
Invert = Standard_True;
}
}
}
@@ -164,12 +168,12 @@ static void Bubble(TColgp_SequenceOfPnt& Seq)
//=======================================================================
static void EvalParameters(const Geom2dAdaptor_Curve& Bis,
const Geom2dAdaptor_Curve& AC,
TColgp_SequenceOfPnt& Params)
const Geom2dAdaptor_Curve& AC,
TColgp_SequenceOfPnt& Params)
{
Geom2dInt_GInter Intersector;
Standard_Real Tol = Precision::Confusion();
// Standard_Real TolC = 1.e-9;
// Standard_Real TolC = 1.e-9;
Geom2dAdaptor_Curve CBis(Bis);
Geom2dAdaptor_Curve CAC (AC);
@@ -184,9 +188,9 @@ static void EvalParameters(const Geom2dAdaptor_Curve& Bis,
if ( !Intersector.IsDone()) {
StdFail_NotDone::Raise("BRepFill_TrimSurfaceTool::IntersectWith");
}
NbPoints = Intersector.NbPoints();
if (NbPoints > 0) {
for ( Standard_Integer i = 1; i <= NbPoints; i++) {
U1 = Intersector.Point(i).ParamOnSecond();
@@ -194,11 +198,11 @@ static void EvalParameters(const Geom2dAdaptor_Curve& Bis,
P = gp_Pnt(U1,U2,0.);
Params.Append(P);
}
}
NbSegments = Intersector.NbSegments();
if (NbSegments > 0) {
IntRes2d_IntersectionSegment Seg;
for ( Standard_Integer i = 1; i <= NbSegments; i++) {
@@ -206,20 +210,20 @@ static void EvalParameters(const Geom2dAdaptor_Curve& Bis,
U1 = Seg.FirstPoint().ParamOnSecond();
Standard_Real Ulast = Seg.LastPoint().ParamOnSecond();
if ( Abs(U1 - CBis.FirstParameter()) <= Tol &&
Abs(Ulast - CBis.LastParameter()) <= Tol ) {
P = gp_Pnt(U1,Seg.FirstPoint().ParamOnFirst(),0.);
Params.Append(P);
P = gp_Pnt(Ulast,Seg.LastPoint().ParamOnFirst(),0.);
Params.Append(P);
Abs(Ulast - CBis.LastParameter()) <= Tol ) {
P = gp_Pnt(U1,Seg.FirstPoint().ParamOnFirst(),0.);
Params.Append(P);
P = gp_Pnt(Ulast,Seg.LastPoint().ParamOnFirst(),0.);
Params.Append(P);
}
else {
U1 += Seg.LastPoint().ParamOnSecond();
U1 /= 2.;
U2 = Seg.FirstPoint().ParamOnFirst();
U2 += Seg.LastPoint().ParamOnFirst();
U2 /= 2.;
P = gp_Pnt(U1,U2,0.);
Params.Append(P);
U1 += Seg.LastPoint().ParamOnSecond();
U1 /= 2.;
U2 = Seg.FirstPoint().ParamOnFirst();
U2 += Seg.LastPoint().ParamOnFirst();
U2 /= 2.;
P = gp_Pnt(U1,U2,0.);
Params.Append(P);
}
}
}
@@ -227,15 +231,15 @@ static void EvalParameters(const Geom2dAdaptor_Curve& Bis,
// Order the sequence by growing parameter on the bissectrice.
Bubble( Params);
}
static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
const Geom2dAdaptor_Curve& AC,
TColgp_SequenceOfPnt& Params,
const Standard_Real Tol)
const Geom2dAdaptor_Curve& AC,
TColgp_SequenceOfPnt& Params,
const Standard_Real Tol)
{
Geom2dInt_GInter Intersector;
Standard_Real TolC = Tol;
Geom2dAdaptor_Curve CBis(Bis);
Geom2dAdaptor_Curve CAC (AC);
@@ -248,9 +252,9 @@ static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
if ( !Intersector.IsDone()) {
StdFail_NotDone::Raise("BRepFill_TrimSurfaceTool::IntersectWith");
}
NbPoints = Intersector.NbPoints();
if (NbPoints > 0) {
for ( Standard_Integer i = 1; i <= NbPoints; i++) {
U1 = Intersector.Point(i).ParamOnSecond();
@@ -258,11 +262,11 @@ static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
P = gp_Pnt(U1,U2,0.);
Params.Append(P);
}
}
NbSegments = Intersector.NbSegments();
if (NbSegments > 0) {
IntRes2d_IntersectionSegment Seg;
for ( Standard_Integer i = 1; i <= NbSegments; i++) {
@@ -270,20 +274,20 @@ static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
U1 = Seg.FirstPoint().ParamOnSecond();
Standard_Real Ulast = Seg.LastPoint().ParamOnSecond();
if ( Abs(U1 - CBis.FirstParameter()) <= Tol &&
Abs(Ulast - CBis.LastParameter()) <= Tol ) {
P = gp_Pnt(U1,Seg.FirstPoint().ParamOnFirst(),0.);
Params.Append(P);
P = gp_Pnt(Ulast,Seg.LastPoint().ParamOnFirst(),0.);
Params.Append(P);
Abs(Ulast - CBis.LastParameter()) <= Tol ) {
P = gp_Pnt(U1,Seg.FirstPoint().ParamOnFirst(),0.);
Params.Append(P);
P = gp_Pnt(Ulast,Seg.LastPoint().ParamOnFirst(),0.);
Params.Append(P);
}
else {
U1 += Seg.LastPoint().ParamOnSecond();
U1 /= 2.;
U2 = Seg.FirstPoint().ParamOnFirst();
U2 += Seg.LastPoint().ParamOnFirst();
U2 /= 2.;
P = gp_Pnt(U1,U2,0.);
Params.Append(P);
U1 += Seg.LastPoint().ParamOnSecond();
U1 /= 2.;
U2 = Seg.FirstPoint().ParamOnFirst();
U2 += Seg.LastPoint().ParamOnFirst();
U2 /= 2.;
P = gp_Pnt(U1,U2,0.);
Params.Append(P);
}
}
}
@@ -299,8 +303,8 @@ static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
//=======================================================================
void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
const TopoDS_Edge& Edge2,
TColgp_SequenceOfPnt& Params)
const TopoDS_Edge& Edge2,
TColgp_SequenceOfPnt& Params)
{
Params.Clear();
@@ -318,27 +322,28 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
Geom2dAdaptor_Curve AC2(C2,f,l);
#ifdef DRAW
if ( Affich) {
if ( AffichInt) {
f = AC1.FirstParameter();
l = AC1.LastParameter();
char* CURVE1name = "CURVE1";
DrawTrSurf::Set(CURVE1name, new Geom2d_TrimmedCurve(C1,f,l));
char name[32];
sprintf(name,"C1_%d", ++intind);
DrawTrSurf::Set(name, new Geom2d_TrimmedCurve(C1,f,l));
f = AC2.FirstParameter();
l = AC2.LastParameter();
char* CURVE2name = "CURVE2";
DrawTrSurf::Set(CURVE2name, new Geom2d_TrimmedCurve(C2,f,l));
sprintf(name,"C2_%d", intind);
DrawTrSurf::Set(name, new Geom2d_TrimmedCurve(C2,f,l));
f = myBis.FirstParameter();
l = myBis.LastParameter();
char* bisname = "BIS";
DrawTrSurf::Set(bisname, new Geom2d_TrimmedCurve(myBis.Curve(),f,l));
char* Edge1name = "E1";
DBRep::Set(Edge1name, Edge1);
char* Edge2name = "E2";
DBRep::Set(Edge2name, Edge2);
sprintf(name,"BIS%d", intind);
DrawTrSurf::Set(name, new Geom2d_TrimmedCurve(myBis.Curve(),f,l));
sprintf(name,"E1_%d", intind);
DBRep::Set(name, Edge1);
sprintf(name,"E2_%d", intind);
DBRep::Set(name, Edge2);
}
#endif
// Calculate intersection
TColgp_SequenceOfPnt Points2;
gp_Pnt PSeq;
@@ -347,36 +352,94 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
EvalParameters (myBis,AC2,Points2);
Standard_Integer SeanceDeRattrapage=0;
Standard_Real TolInit= 1.e-9;
Standard_Integer nn = 7;
if((AC1.GetType() != GeomAbs_Circle && AC1.GetType() != GeomAbs_Line) ||
(AC2.GetType() != GeomAbs_Circle && AC2.GetType() != GeomAbs_Line)) {
(AC2.GetType() != GeomAbs_Circle && AC2.GetType() != GeomAbs_Line)) {
TolInit = 1.e-8;
nn = 6;
TolInit = 1.e-8;
nn = 6;
}
while ( SeanceDeRattrapage < nn // TolInit <= 0.01
&& ( Points2.Length() != Params.Length() ||
(Points2.Length() == 0 && Params.Length() == 0) ) ) {
#ifdef DEB
cout << "BRepFill_TrimEdgeTool: incoherent intersection. Try with a greater tolerance" << endl;
if(Params.IsEmpty() && Points2.IsEmpty())
{
//Check, may be there are no intersections at all
// for case myBis == Line
if(myBis.GetType() == GeomAbs_Line)
{
Standard_Real dmax = TolInit;
Standard_Integer n = 0;
while(n < nn)
{
dmax *= 10.0;
++n;
}
dmax *= dmax;
//
gp_Lin2d anL = myBis.Line();
Standard_Boolean isFar1 = Standard_True;
Standard_Boolean isFar2 = Standard_True;
gp_Pnt2d aP;
//
Standard_Real d = RealLast();
AC1.D0(AC1.FirstParameter(), aP);
Standard_Real par = ElCLib::Parameter(anL, aP);
if(par >= myBis.FirstParameter() && par <= myBis.LastParameter())
{
d = anL.SquareDistance(aP);
}
AC1.D0(AC1.LastParameter(), aP);
par = ElCLib::Parameter(anL, aP);
if(par >= myBis.FirstParameter() && par <= myBis.LastParameter())
{
d = Min(anL.SquareDistance(aP), d);
}
isFar1 = d > dmax;
//
d = RealLast();
AC2.D0(AC2.FirstParameter(), aP);
par = ElCLib::Parameter(anL, aP);
if(par >= myBis.FirstParameter() && par <= myBis.LastParameter())
{
d = anL.SquareDistance(aP);
}
AC2.D0(AC2.LastParameter(), aP);
par = ElCLib::Parameter(anL, aP);
if(par >= myBis.FirstParameter() && par <= myBis.LastParameter())
{
d = Min(anL.SquareDistance(aP), d);
}
isFar2 = d > dmax;
//
if(isFar1 && isFar2)
{
return;
}
}
}
while ( SeanceDeRattrapage < nn // TolInit <= 0.01
&& ( Points2.Length() != Params.Length() ||
(Points2.Length() == 0 && Params.Length() == 0) ) ) {
#ifdef OCCT_DEBUG
cout << "BRepFill_TrimEdgeTool: incoherent intersection. Try with a greater tolerance" << endl;
#endif
Params.Clear();
Points2.Clear();
TolInit*=10.0;
EvalParametersBis(myBis,AC1,Params,TolInit);
EvalParametersBis(myBis,AC2,Points2,TolInit);
SeanceDeRattrapage++;
Params.Clear();
Points2.Clear();
TolInit*=10.0;
EvalParametersBis(myBis,AC1,Params,TolInit);
EvalParametersBis(myBis,AC2,Points2,TolInit);
SeanceDeRattrapage++;
}
#ifdef DEB
#ifdef OCCT_DEBUG
if(SeanceDeRattrapage != 0) cout << "SeanceDeRattrapage = " << SeanceDeRattrapage << endl;
if(SeanceDeRattrapage == nn) {
cout << "BRepFill_TrimEdgeTool: incoherent intersection" << endl;
@@ -387,7 +450,7 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
if(Params.Length() == 0 && Points2.Length() == 1) {
//cout << "Params.Length() == 0 && Points2.Length() == 1" << endl;
Standard_Real dmin;
Standard_Real dmin, dmax = 0.25*myOffset*myOffset;
Standard_Real tBis = Points2(1).X();
gp_Pnt2d PBis = myBis.Value(tBis);
@@ -395,19 +458,26 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
gp_Pnt2d PC = AC1.Value(t);
dmin = PC.SquareDistance(PBis);
gp_Pnt P(tBis, t, 0.);
Params.Append(P);
if(dmin < dmax)
{
Params.Append(P);
}
t = AC1.LastParameter();
PC = AC1.Value(t);
if(dmin > PC.SquareDistance(PBis)) {
Standard_Real dmin1 = PC.SquareDistance(PBis);
if(dmin > dmin1 && dmin1 < dmax ) {
P.SetY(t);
Params.SetValue(1,P);
if(Params.IsEmpty())
Params.Append(P);
else
Params.SetValue(1,P);
}
}
else if(Params.Length() == 1 && Points2.Length() == 0) {
//cout << "Params.Length() == 1 && Points2.Length() == 0" << endl;
Standard_Real dmin;
Standard_Real dmin, dmax = 0.25*myOffset*myOffset;
Standard_Real tBis = Params(1).X();
gp_Pnt2d PBis = myBis.Value(tBis);
@@ -415,13 +485,20 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
gp_Pnt2d PC = AC2.Value(t);
dmin = PC.SquareDistance(PBis);
gp_Pnt P(tBis, t, 0.);
Points2.Append(P);
if(dmin < dmax)
{
Points2.Append(P);
}
t = AC2.LastParameter();
PC = AC2.Value(t);
if(dmin > PC.SquareDistance(PBis)) {
Standard_Real dmin1 = PC.SquareDistance(PBis);
if(dmin > dmin1 && dmin1 < dmax ) {
P.SetY(t);
Points2.SetValue(1,P);
if(Points2.IsEmpty())
Points2.Append(P);
else
Points2.SetValue(1,P);
}
}
@@ -452,18 +529,18 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
Standard_Real P1xP2x=Abs( P1.X() - P2.X());
if ( P1xP2x > Tol ) {
#ifdef DEB
#ifdef OCCT_DEBUG
cout << "BRepFill_TrimEdgeTool: no same parameter on the bissectrice" << endl;
#endif
if(P1xP2x>TolInit) {
#ifdef DEB
cout << "BRepFill_TrimEdgeTool: Continue somehow" << endl;
#ifdef OCCT_DEBUG
cout << "BRepFill_TrimEdgeTool: Continue somehow" << endl;
#endif
i++;
i++;
}
else {
if ( P1.X() < P2.X()) Params.Remove(i);
else Points2.Remove(i);
if ( P1.X() < P2.X()) Params.Remove(i);
else Points2.Remove(i);
}
}
else i++;
@@ -492,10 +569,10 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
//=======================================================================
void BRepFill_TrimEdgeTool::AddOrConfuse(const Standard_Boolean Start,
const TopoDS_Edge& Edge1,
const TopoDS_Edge& Edge2,
TColgp_SequenceOfPnt& Params)
const
const TopoDS_Edge& Edge1,
const TopoDS_Edge& Edge2,
TColgp_SequenceOfPnt& Params)
const
{
Standard_Boolean ToProj = Standard_True;
gp_Pnt2d PBis;
@@ -521,9 +598,9 @@ const
else P = AC1.Value(Params.Last ().Y());
ToProj = !PBis.IsEqual(P,Tol);
}
if (ToProj) {
#ifdef DEB
#ifdef OCCT_DEBUG
cout << " project extremity bissectrice on parallel."<<endl;
#endif
@@ -537,32 +614,32 @@ const
Geom2dAPI_ProjectPointOnCurve Projector2(PBis,C2,f2,l2);
if (Projector1.NbPoints() == 0) {
#ifdef DEB
#ifdef OCCT_DEBUG
cout << "Failed projection in BRepFill_TrimEdgeTool::AddOrConfuse"<<endl;
#endif
return;
}
if (!Projector1.NearestPoint().IsEqual(PBis,Tol)) {
#ifdef DEB
#ifdef OCCT_DEBUG
cout <<"Incorrect solution in BRepFill_TrimEdgeTool::AddOrConfuse"<<endl;
#endif
return;
}
if (Projector2.NbPoints() == 0) {
#ifdef DEB
#ifdef OCCT_DEBUG
cout << "Failed projection in BRepFill_TrimEdgeTool::AddOrConfuse"<<endl;
#endif
return;
}
if (!Projector2.NearestPoint().IsEqual(PBis,Tol)) {
#ifdef DEB
#ifdef OCCT_DEBUG
cout <<" Mauvaisesolution dans BRepFill_TrimEdgeTool::AddOrConfuse"<<endl;
#endif
return;
}
gp_Pnt PInt (0,
Projector1.LowerDistanceParameter(),
Projector2.LowerDistanceParameter());
Projector1.LowerDistanceParameter(),
Projector2.LowerDistanceParameter());
if (Start) {
PInt.SetX (myBis.FirstParameter());
Params.Prepend(PInt);
@@ -581,10 +658,10 @@ const
Standard_Boolean BRepFill_TrimEdgeTool::IsInside(const gp_Pnt2d& P) const
{
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:12 2002 Begin
// Standard_Real Dist;
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:12 2002 Begin
// Standard_Real Dist;
Standard_Real Dist = RealLast();
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:12 2002 End
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:12 2002 End
if (isPoint1)
Dist = P.Distance(myP1);
else if (isPoint2)
@@ -594,26 +671,26 @@ Standard_Boolean BRepFill_TrimEdgeTool::IsInside(const gp_Pnt2d& P) const
if (Projector.NbPoints() > 0) {
Dist = Projector.LowerDistance();
}
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:43 2002 Begin
// else {
// gp_Pnt2d PF = myC1->Value(myC1->FirstParameter());
// gp_Pnt2d PL = myC1->Value(myC1->LastParameter());
// Dist = Min (P.Distance(PF),P.Distance(PL));
// }
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:43 2002 Begin
// else {
// gp_Pnt2d PF = myC1->Value(myC1->FirstParameter());
// gp_Pnt2d PL = myC1->Value(myC1->LastParameter());
// Dist = Min (P.Distance(PF),P.Distance(PL));
// }
// Check of distances between P and first and last point of the first curve
// should be performed in any case, despite of the results of projection.
// Check of distances between P and first and last point of the first curve
// should be performed in any case, despite of the results of projection.
gp_Pnt2d PF = myC1->Value(myC1->FirstParameter());
gp_Pnt2d PL = myC1->Value(myC1->LastParameter());
Standard_Real aDistMin = Min (P.Distance(PF),P.Distance(PL));
if (Dist > aDistMin)
Dist = aDistMin;
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:44 2002 End
// Modified by Sergey KHROMOV - Fri Sep 27 11:43:44 2002 End
}
// return (Dist < Abs(myOffset);
// return (Dist < Abs(myOffset) + Precision::Confusion());
// return (Dist < Abs(myOffset);
// return (Dist < Abs(myOffset) + Precision::Confusion());
return (Dist < Abs(myOffset) - Precision::Confusion());
}

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

File diff suppressed because it is too large Load Diff

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.
@@ -19,7 +19,9 @@
#include <Precision.hxx>
#include <math_Matrix.hxx>
#include <math_Vector.hxx>
#include <math_Gauss.hxx>
//#include <math_Gauss.hxx>
#include <math_SVD.hxx>
#include <math_Jacobi.hxx>
#include <gp_Lin.hxx>
#include <gp_Circ.hxx>
@@ -45,6 +47,8 @@
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS.hxx>
#include <BRep_Builder.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
#include <GeomLib.hxx>
#include <Geom2d_Curve.hxx>
@@ -175,8 +179,8 @@ 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_Real Tol,
const Standard_Boolean OnlyPlane,
const Standard_Boolean OnlyClosed)
{
myTolerance = Tol;
@@ -214,24 +218,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 +266,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 +288,72 @@ 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
{
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;
@@ -351,41 +363,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,36 +426,100 @@ 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(2,1)+=w*p.Y()*p.X();
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();
aVec(1) -= w*p.X();
aVec(2) -= w*p.Y();
aVec(3) -= w*p.Z();
aMat(1,2)+=w*p.X()*p.Y();
aMat(1,3)+=w*p.X()*p.Z();
//
aMat(2,2)+=w*p.Y()*p.Y();
aMat(2,3)+=w*p.Y()*p.Z();
//
aMat(3,3)+=w*p.Z()*p.Z();
}
// Solve the system of equations to get plane coefficients
math_Gauss aSolver(aMat);
Standard_Boolean isSolved = aSolver.IsDone();
aMat(2,1) = aMat(1,2);
aMat(3,1) = aMat(1,3);
aMat(3,2) = aMat(2,3);
//
math_Jacobi anEignval(aMat);
math_Vector anEVals(1,3);
Standard_Boolean isSolved = anEignval.IsDone();
Standard_Integer isol = 0;
if(isSolved)
{
anEVals = anEignval.Values();
//We need vector with eigenvalue ~ 0.
Standard_Real anEMin = RealLast();
Standard_Real anEMax = -anEMin;
for(i = 1; i <= 3; ++i)
{
Standard_Real anE = Abs(anEVals(i));
if(anEMin > anE)
{
anEMin = anE;
isol = i;
}
if(anEMax < anE)
{
anEMax = anE;
}
}
if(isol == 0)
{
isSolved = Standard_False;
}
else
{
Standard_Real eps = Epsilon(anEMax);
if(anEMin <= eps)
{
anEignval.Vector(isol, aVec);
}
else
{
//try using vector product of other axes
Standard_Integer ind[2] = {0,0};
for(i = 1; i <= 3; ++i)
{
if(i == isol)
{
continue;
}
if(ind[0] == 0)
{
ind[0] = i;
continue;
}
if(ind[1] == 0)
{
ind[1] = i;
continue;
}
}
math_Vector aVec1(1, 3, 0.), aVec2(1, 3, 0.);
anEignval.Vector(ind[0], aVec1);
anEignval.Vector(ind[1], aVec2);
gp_Vec aV1(aVec1(1), aVec1(2), aVec1(3));
gp_Vec aV2(aVec2(1), aVec2(2), aVec2(3));
gp_Vec aN = aV1^ aV2;
aVec(1) = aN.X();
aVec(2) = aN.Y();
aVec(3) = aN.Z();
}
if (aVec.Norm2() < gp::Resolution()) {
isSolved = Standard_False;
}
}
}
//
// let us be more tolerant (occ415)
Standard_Real dfDist = RealLast();
Handle(Geom_Plane) aPlane;
//
if (isSolved) {
aSolver.Solve(aVec);
if (aVec.Norm2()<gp::Resolution()) {
isSolved = Standard_False;
}
}
//
if (isSolved) {
aPlane = new Geom_Plane(aBaryCenter,gp_Dir(aVec(1),aVec(2),aVec(3)));
//Plane normal can have two directions, direction is chosen
//according to direction of eigenvector
gp_Vec anN(aVec(1), aVec(2), aVec(3));
aPlane = new Geom_Plane(aBaryCenter,anN);
dfDist = Controle (aPoints, aPlane);
}
//
@@ -453,23 +529,25 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
gp_Vec aDir(aFirstPnt,aPoints(iPoint));
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(aBaryCenter, aCross);
Standard_Real dfDist2 = Controle (aPoints, aPlane2);
if (dfDist2 < myTolerance) {
myTolReached = dfDist2;
mySurface = aPlane2;
return;
}
if (dfDist2 < dfDist) {
dfDist = dfDist2;
aPlane = aPlane2;
}
}
}
}
}
@@ -483,6 +561,23 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
//myTolReached = dfDist;
//XXt
mySurface = aPlane;
//If S is wire, try to orient surface according to orientation of wire.
if(S.ShapeType() == TopAbs_WIRE && S.Closed())
{
//
TopoDS_Wire aW = TopoDS::Wire(S);
TopoDS_Face aTmpFace = BRepLib_MakeFace(mySurface, Precision::Confusion());
BRep_Builder BB;
BB.Add(aTmpFace, aW);
BRepTopAdaptor_FClass2d FClass(aTmpFace, 0.);
if ( FClass.PerformInfinitePoint() == TopAbs_IN )
{
gp_Dir aN = aPlane->Position().Direction();
aN.Reverse();
mySurface = new Geom_Plane(aPlane->Position().Location(), aN);
}
}
}
//XXf
myTolReached = dfDist;

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.
@@ -39,14 +39,27 @@
#include <BRep_Builder.hxx>
#include <BRepLib.hxx>
#include <TopTools_IndexedDataMapOfShapeShape.hxx>
#include <GeomAbs_CurveType.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Parabola.hxx>
#include <Geom2d_Hyperbola.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <GCE2d_MakeArcOfCircle.hxx>
#include <GCE2d_MakeSegment.hxx>
//
// Modified by Sergey KHROMOV - Thu Dec 5 10:38:14 2002 Begin
static TopoDS_Edge MakeEdge(const Handle(Geom2d_Curve) &theCurve,
const TopoDS_Face &theFace,
const TopoDS_Vertex &theVFirst,
const TopoDS_Vertex &theVLast);
const TopoDS_Face &theFace,
const TopoDS_Vertex &theVFirst,
const TopoDS_Vertex &theVLast);
// Modified by Sergey KHROMOV - Thu Dec 5 10:38:16 2002 End
//
static GeomAbs_CurveType GetCurveType(const Handle(Geom2d_Curve)& theC2d);
static void AdjustCurveEnd(Handle(Geom2d_BoundedCurve)& theC2d, const gp_Pnt2d theP,
const Standard_Boolean isFirst);
//
//=======================================================================
//function : BRepMAT2d_Explorer
//purpose :
@@ -79,7 +92,7 @@ void BRepMAT2d_Explorer::Perform(const TopoDS_Face& aFace)
TopoDS_Face F = TopoDS::Face(aFace);
F.Orientation(TopAbs_FORWARD);
TopExp_Explorer Exp (F,TopAbs_WIRE);
// Modified by Sergey KHROMOV - Tue Nov 26 16:10:37 2002 Begin
// Modified by Sergey KHROMOV - Tue Nov 26 16:10:37 2002 Begin
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(F);
TopoDS_Face aNewF = BRepBuilderAPI_MakeFace(aSurf, Precision::Confusion());
@@ -91,8 +104,8 @@ void BRepMAT2d_Explorer::Perform(const TopoDS_Face& aFace)
BRepLib::BuildCurves3d(aNewF);
myModifShapes.Add(aFace, aNewF);
// CheckConnection();
// Modified by Sergey KHROMOV - Tue Nov 26 16:10:38 2002 End
// CheckConnection();
// Modified by Sergey KHROMOV - Tue Nov 26 16:10:38 2002 End
}
//=======================================================================
@@ -101,43 +114,43 @@ void BRepMAT2d_Explorer::Perform(const TopoDS_Face& aFace)
//=======================================================================
void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
const TopoDS_Face& aFace,
TopoDS_Face& aNewFace)
const TopoDS_Face& aFace,
TopoDS_Face& aNewFace)
{
// Modified by Sergey KHROMOV - Tue Nov 26 14:25:46 2002 Begin
// This method is totally rewroted to include check
// of connection and creation of a new spine.
// Modified by Sergey KHROMOV - Tue Nov 26 14:25:46 2002 Begin
// This method is totally rewroted to include check
// of connection and creation of a new spine.
NewContour();
myIsClosed(currentContour) = (Spine.Closed()) ? Standard_True : Standard_False;
// Modified by skv - Wed Jun 23 12:23:01 2004 Integration Begin
// Taking into account side of bisecting loci construction.
// TopoDS_Wire aWFwd = TopoDS::Wire(Spine.Oriented(TopAbs_FORWARD));
// BRepTools_WireExplorer anExp(aWFwd, aFace);
// Modified by skv - Wed Jun 23 12:23:01 2004 Integration Begin
// Taking into account side of bisecting loci construction.
// TopoDS_Wire aWFwd = TopoDS::Wire(Spine.Oriented(TopAbs_FORWARD));
// BRepTools_WireExplorer anExp(aWFwd, aFace);
BRepTools_WireExplorer anExp(Spine, aFace);
// Modified by skv - Wed Jun 23 12:23:02 2004 Integration End
// Modified by skv - Wed Jun 23 12:23:02 2004 Integration End
TopTools_IndexedDataMapOfShapeShape anOldNewE;
if (!anExp.More())
return;
TopoDS_Edge aFirstEdge = anExp.Current();
TopoDS_Edge aPrevEdge = aFirstEdge;
Standard_Real UFirst,ULast, aD;
Handle(Geom2d_BSplineCurve) BCurve;
Handle(Geom2d_Curve) C2d;
Handle(Geom2d_TrimmedCurve) CT2d;
Handle(Geom2d_TrimmedCurve) aFirstCurve;
gp_Pnt2d aPFirst;
gp_Pnt2d aPLast;
gp_Pnt2d aPCurFirst;
// Modified by skv - Mon Jul 11 19:00:25 2005 Integration Begin
// Set the confusion tolerance in accordance with the further algo
// Standard_Real aTolConf = Precision::Confusion();
// Modified by skv - Mon Jul 11 19:00:25 2005 Integration Begin
// Set the confusion tolerance in accordance with the further algo
// Standard_Real aTolConf = Precision::Confusion();
Standard_Real aTolConf = 1.e-8;
// Modified by skv - Mon Jul 11 19:00:25 2005 Integration End
// Modified by skv - Mon Jul 11 19:00:25 2005 Integration End
Standard_Boolean isModif = Standard_False;
// Treatment of the first edge of a wire.
// Treatment of the first edge of a wire.
anOldNewE.Add(aFirstEdge, aFirstEdge);
C2d = BRep_Tool::CurveOnSurface (aFirstEdge, aFace, UFirst, ULast);
CT2d = new Geom2d_TrimmedCurve(C2d,UFirst,ULast);
@@ -152,7 +165,7 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
aFirstCurve = CT2d;
anExp.Next();
// Treatment of the next edges:
// Treatment of the next edges:
for (; anExp.More(); anExp.Next()) {
TopoDS_Edge anEdge = anExp.Current();
@@ -175,64 +188,111 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
// code should be rewritten.
isModif = Standard_True;
//
//modified by NIZNHY-PKV Tue Aug 7 09:14:03 2007f
//BCurve = Geom2dConvert::CurveToBSplineCurve(CT2d);
BCurve=Geom2dConvert::CurveToBSplineCurve(CT2d, Convert_QuasiAngular);
//modified by NIZNHY-PKV Tue Aug 7 09:14:07 2007t
BCurve->SetPole(1, aPLast);
CT2d = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(),
BCurve->LastParameter());
Standard_Integer aNbC = theCurves.Value(currentContour).Length();
Handle(Geom2d_BoundedCurve) CPrev =
Handle(Geom2d_BoundedCurve)::DownCast(theCurves.ChangeValue(currentContour).ChangeValue(aNbC));
//
GeomAbs_CurveType TCPrev = GetCurveType(CPrev);
GeomAbs_CurveType TCCurr = GetCurveType(CT2d);
//
if(TCCurr <= TCPrev)
{
AdjustCurveEnd(CT2d, aPLast, Standard_True);
// Creation of new edge.
TopoDS_Edge aNewEdge;
TopoDS_Vertex aVf = TopExp::FirstVertex(anEdge);
TopoDS_Vertex aVl = TopExp::LastVertex(anEdge);
// Creation of new edge.
TopoDS_Edge aNewEdge;
TopoDS_Vertex aVf = TopExp::FirstVertex(anEdge);
TopoDS_Vertex aVl = TopExp::LastVertex(anEdge);
if (anEdge.Orientation() == TopAbs_FORWARD)
aNewEdge = MakeEdge(CT2d, aNewFace, aVf, aVl);
else
aNewEdge = MakeEdge(CT2d->Reversed(), aNewFace, aVf, aVl);
if (anEdge.Orientation() == TopAbs_FORWARD)
aNewEdge = MakeEdge(CT2d, aNewFace, aVf, aVl);
else
aNewEdge = MakeEdge(CT2d->Reversed(), aNewFace, aVf, aVl);
aNewEdge.Orientation(anEdge.Orientation());
aNewEdge.Orientation(anEdge.Orientation());
anOldNewE.ChangeFromKey(anEdge) = aNewEdge;
}
else
{
gp_Pnt2d aP = CT2d->Value(CT2d->FirstParameter());
AdjustCurveEnd(CPrev, aP, Standard_False);
theCurves.ChangeValue(currentContour).ChangeValue(aNbC) = CPrev;
//Change previous edge
TopoDS_Edge aNewEdge;
TopoDS_Vertex aVf = TopExp::FirstVertex(aPrevEdge);
TopoDS_Vertex aVl = TopExp::LastVertex(aPrevEdge);
if (aPrevEdge.Orientation() == TopAbs_FORWARD)
aNewEdge = MakeEdge(CPrev, aNewFace, aVf, aVl);
else
aNewEdge = MakeEdge(CPrev->Reversed(), aNewFace, aVf, aVl);
aNewEdge.Orientation(aPrevEdge.Orientation());
anOldNewE.ChangeFromKey(aPrevEdge) = aNewEdge;
}
anOldNewE.ChangeFromKey(anEdge) = aNewEdge;
}
aPLast = CT2d->Value(CT2d->LastParameter());
Add(CT2d);
aPrevEdge = anEdge;
}
// Check of the distance between the first and the last point of wire
// if the wire is closed.
if (myIsClosed(currentContour) && aPLast.Distance(aPFirst) > aTolConf) {
isModif = Standard_True;
if (myIsClosed(currentContour) && aPLast.Distance(aPFirst) > aTolConf) {
isModif = Standard_True;
//modified by NIZNHY-PKV Tue Aug 7 09:20:08 2007f
//Handle(Geom2d_BSplineCurve)
//BCurve = Geom2dConvert::CurveToBSplineCurve(aFirstCurve);
BCurve = Geom2dConvert::CurveToBSplineCurve(aFirstCurve, Convert_QuasiAngular);
//modified by NIZNHY-PKV Tue Aug 7 09:20:11 2007t
BCurve->SetPole(1, aPLast);
aFirstCurve = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(),
BCurve->LastParameter());
//
Standard_Integer aNbC = theCurves.Value(currentContour).Length();
Handle(Geom2d_BoundedCurve) CPrev =
Handle(Geom2d_BoundedCurve)::DownCast(theCurves.ChangeValue(currentContour).ChangeValue(aNbC));
//
GeomAbs_CurveType TCPrev = GetCurveType(CPrev);
GeomAbs_CurveType TCCurr = GetCurveType(aFirstCurve);
//
if(TCCurr <= TCPrev)
{
AdjustCurveEnd(aFirstCurve, aPLast, Standard_True);
theCurves.ChangeValue(currentContour).ChangeValue(1) = aFirstCurve;
// Creation of new first edge.
// Creation of new edge.
TopoDS_Edge aNewEdge;
TopoDS_Vertex aVf = TopExp::FirstVertex(aFirstEdge);
TopoDS_Vertex aVl = TopExp::LastVertex(aFirstEdge);
if (aFirstEdge.Orientation() == TopAbs_FORWARD)
aNewEdge = MakeEdge(aFirstCurve, aNewFace, aVf, aVl);
aNewEdge = MakeEdge(aFirstCurve, aNewFace, aVf, aVl);
else
aNewEdge = MakeEdge(aFirstCurve->Reversed(), aNewFace, aVf, aVl);
aNewEdge = MakeEdge(aFirstCurve->Reversed(), aNewFace, aVf, aVl);
aNewEdge.Orientation(aFirstEdge.Orientation());
anOldNewE.ChangeFromKey(aFirstEdge) = aNewEdge;
}
else
{
gp_Pnt2d aP = aFirstCurve->Value(aFirstCurve->FirstParameter());
AdjustCurveEnd(CPrev, aP, Standard_False);
theCurves.ChangeValue(currentContour).ChangeValue(aNbC) = CPrev;
//Change previous edge
TopoDS_Edge aNewEdge;
TopoDS_Vertex aVf = TopExp::FirstVertex(aPrevEdge);
TopoDS_Vertex aVl = TopExp::LastVertex(aPrevEdge);
if (aPrevEdge.Orientation() == TopAbs_FORWARD)
aNewEdge = MakeEdge(CPrev, aNewFace, aVf, aVl);
else
aNewEdge = MakeEdge(CPrev->Reversed(), aNewFace, aVf, aVl);
aNewEdge.Orientation(aPrevEdge.Orientation());
anOldNewE.ChangeFromKey(aPrevEdge) = aNewEdge;
}
}
TopoDS_Wire aNewWire;
BRep_Builder aBuilder;
@@ -263,7 +323,7 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
aNewWire = Spine;
aBuilder.Add(aNewFace, aNewWire);
// Modified by Sergey KHROMOV - Tue Nov 26 14:25:53 2002 End
// Modified by Sergey KHROMOV - Tue Nov 26 14:25:53 2002 End
}
//=======================================================================
@@ -302,10 +362,10 @@ void BRepMAT2d_Explorer::Clear()
{
theCurves.Clear() ;
currentContour = 0;
// Modified by Sergey KHROMOV - Wed Mar 6 16:07:55 2002 Begin
// Modified by Sergey KHROMOV - Wed Mar 6 16:07:55 2002 Begin
myIsClosed.Clear();
myModifShapes.Clear();
// Modified by Sergey KHROMOV - Wed Mar 6 16:07:55 2002 End
// Modified by Sergey KHROMOV - Wed Mar 6 16:07:55 2002 End
}
@@ -318,9 +378,9 @@ void BRepMAT2d_Explorer::NewContour()
{
TColGeom2d_SequenceOfCurve Contour;
theCurves.Append(Contour);
// Modified by Sergey KHROMOV - Wed Mar 6 16:12:05 2002 Begin
// Modified by Sergey KHROMOV - Wed Mar 6 16:12:05 2002 Begin
myIsClosed.Append(Standard_False);
// Modified by Sergey KHROMOV - Wed Mar 6 16:12:05 2002 End
// Modified by Sergey KHROMOV - Wed Mar 6 16:12:05 2002 End
currentContour ++ ;
}
@@ -353,7 +413,7 @@ Standard_Integer BRepMAT2d_Explorer::NumberOfContours() const
Standard_Integer BRepMAT2d_Explorer::NumberOfCurves
(const Standard_Integer IndexContour)
const
const
{
return theCurves.Value(IndexContour).Length();
}
@@ -421,7 +481,7 @@ TopoDS_Shape BRepMAT2d_Explorer::Shape() const
const TColGeom2d_SequenceOfCurve& BRepMAT2d_Explorer::Contour
(const Standard_Integer IC)
const
const
{
return theCurves.Value(IC);
}
@@ -434,7 +494,7 @@ const
//=======================================================================
Standard_Boolean BRepMAT2d_Explorer::IsModified
(const TopoDS_Shape &aShape) const
(const TopoDS_Shape &aShape) const
{
if (myModifShapes.Contains(aShape)) {
const TopoDS_Shape &aNewShape = myModifShapes.FindFromKey(aShape);
@@ -452,7 +512,7 @@ Standard_Boolean BRepMAT2d_Explorer::IsModified
//=======================================================================
TopoDS_Shape BRepMAT2d_Explorer::ModifiedShape
(const TopoDS_Shape &aShape) const
(const TopoDS_Shape &aShape) const
{
if (myModifShapes.Contains(aShape)) {
const TopoDS_Shape &aNewShape = myModifShapes.FindFromKey(aShape);
@@ -479,9 +539,9 @@ const TColStd_SequenceOfBoolean &BRepMAT2d_Explorer::GetIsClosed() const
//=======================================================================
TopoDS_Edge MakeEdge(const Handle(Geom2d_Curve) &theCurve,
const TopoDS_Face &theFace,
const TopoDS_Vertex &theVFirst,
const TopoDS_Vertex &theVLast)
const TopoDS_Face &theFace,
const TopoDS_Vertex &theVFirst,
const TopoDS_Vertex &theVLast)
{
TopoDS_Edge aNewEdge;
BRep_Builder aBuilder;
@@ -498,3 +558,85 @@ TopoDS_Edge MakeEdge(const Handle(Geom2d_Curve) &theCurve,
return aNewEdge;
}
// Modified by Sergey KHROMOV - Wed Mar 6 17:40:14 2002 End
//
//=======================================================================
//function : GetCurveType
//purpose : Get curve type.
//=======================================================================
GeomAbs_CurveType GetCurveType(const Handle(Geom2d_Curve)& theC2d)
{
GeomAbs_CurveType aTypeCurve = GeomAbs_OtherCurve;
Handle(Standard_Type) TheType = theC2d->DynamicType();
if ( TheType == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
TheType = (*((Handle(Geom2d_TrimmedCurve)*)&theC2d))->BasisCurve()->DynamicType();
}
if ( TheType == STANDARD_TYPE(Geom2d_Circle)) {
aTypeCurve = GeomAbs_Circle;
}
else if ( TheType ==STANDARD_TYPE(Geom2d_Line)) {
aTypeCurve = GeomAbs_Line;
}
else if ( TheType == STANDARD_TYPE(Geom2d_Ellipse)) {
aTypeCurve = GeomAbs_Ellipse;
}
else if ( TheType == STANDARD_TYPE(Geom2d_Parabola)) {
aTypeCurve = GeomAbs_Parabola;
}
else if ( TheType == STANDARD_TYPE(Geom2d_Hyperbola)) {
aTypeCurve = GeomAbs_Hyperbola;
}
else if ( TheType == STANDARD_TYPE(Geom2d_BezierCurve)) {
aTypeCurve = GeomAbs_BezierCurve;
}
else if ( TheType == STANDARD_TYPE(Geom2d_BSplineCurve)) {
aTypeCurve = GeomAbs_BSplineCurve;
}
else {
aTypeCurve = GeomAbs_OtherCurve;
}
return aTypeCurve;
}
//=======================================================================
//function : AdjustCurveEnd
//purpose :
//=======================================================================
void AdjustCurveEnd(Handle(Geom2d_BoundedCurve)& theC2d, const gp_Pnt2d theP,
const Standard_Boolean isFirst)
{
GeomAbs_CurveType aType = GetCurveType(theC2d);
if(aType == GeomAbs_Line)
{
//create new line
if(isFirst)
{
gp_Pnt2d aP = theC2d->Value(theC2d->LastParameter());
theC2d = GCE2d_MakeSegment(theP, aP);
}
else
{
gp_Pnt2d aP = theC2d->Value(theC2d->FirstParameter());
theC2d = GCE2d_MakeSegment(aP, theP);
}
}
else
{
//Convert to BSpline and adjust first pole
Handle(Geom2d_BSplineCurve) BCurve =
Geom2dConvert::CurveToBSplineCurve(theC2d, Convert_QuasiAngular);
if(isFirst)
{
BCurve->SetPole(1, theP);
theC2d = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(),
BCurve->LastParameter());
}
else
{
BCurve->SetPole(BCurve->NbPoles(), theP);
theC2d = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(),
BCurve->LastParameter());
}
}
}

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,8 +45,25 @@
#include <Precision.hxx>
#include <gp.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <Adaptor3d_Surface.hxx>
//
static void Correct2dPoint(const Adaptor3d_Surface& theS, gp_Pnt2d& theP2d);
//
static BRepOffset_Type DefineConnectType(const TopoDS_Edge& E,
const TopoDS_Face& F1,
const TopoDS_Face& F2,
const Standard_Real SinTol,
const Standard_Boolean CorrectPoint);
//
static void CorrectOrientationOfTangent(gp_Vec& TangVec,
const TopoDS_Vertex& aVertex,
const TopoDS_Edge& anEdge)
{
TopoDS_Vertex Vlast = TopExp::LastVertex(anEdge);
if (aVertex.IsSame(Vlast))
TangVec.Reverse();
}
//=======================================================================
//function : BRepOffset_Analyse
//purpose :
@@ -76,99 +93,32 @@ BRepOffset_Analyse::BRepOffset_Analyse(const TopoDS_Shape& S,
//=======================================================================
static void EdgeAnalyse(const TopoDS_Edge& E,
const TopoDS_Face& F1,
const TopoDS_Face& F2,
const Standard_Real SinTol,
BRepOffset_ListOfInterval& LI)
const TopoDS_Face& F1,
const TopoDS_Face& F2,
const Standard_Real SinTol,
BRepOffset_ListOfInterval& LI)
{
TopLoc_Location L;
Standard_Real f,l;
Handle (Geom_Surface) S1 = BRep_Tool::Surface(F1);
Handle (Geom_Surface) S2 = BRep_Tool::Surface(F2);
Handle (Geom2d_Curve) C1 = BRep_Tool::CurveOnSurface(E,F1,f,l);
Handle (Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(E,F2,f,l);
BRepAdaptor_Curve C(E);
f = C.FirstParameter();
l = C.LastParameter();
BRep_Tool::Range(E, F1, f, l);
BRepOffset_Interval I;
I.First(f); I.Last(l);
//
// Tangent if the regularity is at least G1.
if (BRep_Tool::HasContinuity(E,F1,F2)) {
if (BRep_Tool::Continuity(E,F1,F2) > GeomAbs_C0) {
BRepOffset_Interval I;
I.First(f); I.Last(l);
I.Type(BRepOffset_Tangent);
LI.Append(I);
return;
}
}
// First stage : Type determined by one of ends.
// Calculate normals and tangents on the curves and surface.
// normals are oriented outwards.
Standard_Real ParOnC = 0.5*(f+l);
gp_Vec T1 = C.DN(ParOnC,1).Transformed(L.Transformation());
if (T1.SquareMagnitude() > gp::Resolution()) {
T1.Normalize();
}
if (BRepOffset_Tool::OriEdgeInFace(E,F1) == TopAbs_REVERSED) {
T1.Reverse();
}
if (F1.Orientation() == TopAbs_REVERSED) T1.Reverse();
gp_Pnt2d P = C1->Value(ParOnC);
gp_Pnt P3;
gp_Vec D1U,D1V;
S1->D1(P.X(),P.Y(),P3,D1U,D1V);
gp_Vec DN1(D1U^D1V);
if (F1.Orientation() == TopAbs_REVERSED) DN1.Reverse();
P = C2->Value(ParOnC);
S2->D1(P.X(),P.Y(),P3,D1U,D1V);
gp_Vec DN2(D1U^D1V);
if (F2.Orientation() == TopAbs_REVERSED) DN2.Reverse();
DN1.Normalize();
DN2.Normalize();
gp_Vec ProVec = DN1^DN2;
Standard_Real NormProVec = ProVec.Magnitude();
BRepOffset_Interval I;
I.First(f); I.Last(l);
if (Abs(NormProVec) < SinTol) {
// plane
if (DN1.Dot(DN2) > 0) {
//Tangent
I.Type(BRepOffset_Tangent);
}
else {
//Mixed not finished!
#ifdef DEB
cout <<" faces locally mixed"<<endl;
#endif
I.Type(BRepOffset_Convex);
}
}
else {
if (NormProVec > gp::Resolution())
ProVec.Normalize();
Standard_Real Prod = T1.Dot(DN1^DN2);
if (Prod > 0.) {
//
I.Type(BRepOffset_Convex);
}
else {
//reenters
I.Type(BRepOffset_Concave);
}
//
BRepOffset_Type aType = DefineConnectType(E, F1, F2, SinTol, Standard_False);
if(aType != BRepOffset_Tangent)
{
aType = DefineConnectType(E, F1, F2, SinTol, Standard_True);
}
I.Type(aType);
LI.Append(I);
}
@@ -257,7 +207,7 @@ void BRepOffset_Analyse::Perform (const TopoDS_Shape& S,
mapEdgeType(E).Append(Inter);
}
else {
#ifdef DEB
#ifdef OCCT_DEBUG
cout <<"edge shared by more than two faces"<<endl;
#endif
}
@@ -367,6 +317,7 @@ void BRepOffset_Analyse::TangentEdges(const TopoDS_Edge& Edge ,
URef = BRep_Tool::Parameter(Vertex,Edge);
C3dRef = BRepAdaptor_Curve(Edge);
VRef = C3dRef.DN(URef,1);
CorrectOrientationOfTangent(VRef, Vertex, Edge);
if (VRef.SquareMagnitude() < gp::Resolution()) return;
Edges.Clear();
@@ -379,8 +330,9 @@ void BRepOffset_Analyse::TangentEdges(const TopoDS_Edge& Edge ,
U = BRep_Tool::Parameter(Vertex,CurE);
C3d = BRepAdaptor_Curve(CurE);
V = C3d.DN(U,1);
CorrectOrientationOfTangent(V, Vertex, CurE);
if (V.SquareMagnitude() < gp::Resolution()) continue;
if (V.IsParallel(VRef,angle)) {
if (V.IsOpposite(VRef,angle)) {
Edges.Append(CurE);
}
}
@@ -529,3 +481,130 @@ void BRepOffset_Analyse::AddFaces (const TopoDS_Face& Face,
}
}
}
//=======================================================================
//function : Correct2dPoint
//purpose :
//=======================================================================
void Correct2dPoint(const Adaptor3d_Surface& theS, gp_Pnt2d& theP2d)
{
const Standard_Real coeff = 0.01;
Standard_Real eps;
Standard_Real u1, u2, v1, v2;
if(theS.GetType() >= GeomAbs_BezierSurface)
{
u1 = theS.FirstUParameter();
u2 = theS.LastUParameter();
v1 = theS.FirstVParameter();
v2 = theS.LastVParameter();
if(!(Precision::IsInfinite(u1) || Precision::IsInfinite(u2)))
{
eps = Max(coeff*(u2-u1), Precision::PConfusion());
if(Abs(theP2d.X()-u1) < eps)
{
theP2d.SetX(u1 + eps);
}
if(Abs(theP2d.X()-u2) < eps)
{
theP2d.SetX(u2 - eps);
}
}
if(!(Precision::IsInfinite(v1) || Precision::IsInfinite(v2)))
{
eps = Max(coeff*(v2-v1), Precision::PConfusion());
if(Abs(theP2d.Y()-v1) < eps)
{
theP2d.SetY(v1 + eps);
}
if(Abs(theP2d.Y()-v2) < eps)
{
theP2d.SetY(v2 - eps);
}
}
}
}
//=======================================================================
//function : DefineConnectType
//purpose :
//=======================================================================
BRepOffset_Type DefineConnectType(const TopoDS_Edge& E,
const TopoDS_Face& F1,
const TopoDS_Face& F2,
const Standard_Real SinTol,
const Standard_Boolean CorrectPoint)
{
TopLoc_Location L;
Standard_Real f,l;
BRepAdaptor_Surface S1(F1), S2(F2);
Handle (Geom2d_Curve) C1 = BRep_Tool::CurveOnSurface(E,F1,f,l);
Handle (Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(E,F2,f,l);
BRepAdaptor_Curve C(E);
f = C.FirstParameter();
l = C.LastParameter();
//
Standard_Real ParOnC = 0.5*(f+l);
gp_Vec T1 = C.DN(ParOnC,1).Transformed(L.Transformation());
if (T1.SquareMagnitude() > gp::Resolution()) {
T1.Normalize();
}
if (BRepOffset_Tool::OriEdgeInFace(E,F1) == TopAbs_REVERSED) {
T1.Reverse();
}
if (F1.Orientation() == TopAbs_REVERSED) T1.Reverse();
gp_Pnt2d P = C1->Value(ParOnC);
gp_Pnt P3;
gp_Vec D1U,D1V;
if(CorrectPoint)
Correct2dPoint(S1, P);
//
S1.D1(P.X(),P.Y(),P3,D1U,D1V);
gp_Vec DN1(D1U^D1V);
if (F1.Orientation() == TopAbs_REVERSED) DN1.Reverse();
P = C2->Value(ParOnC);
if(CorrectPoint)
Correct2dPoint(S2, P);
S2.D1(P.X(),P.Y(),P3,D1U,D1V);
gp_Vec DN2(D1U^D1V);
if (F2.Orientation() == TopAbs_REVERSED) DN2.Reverse();
DN1.Normalize();
DN2.Normalize();
gp_Vec ProVec = DN1^DN2;
Standard_Real NormProVec = ProVec.Magnitude();
if (Abs(NormProVec) < SinTol) {
// plane
if (DN1.Dot(DN2) > 0) {
//Tangent
return BRepOffset_Tangent;
}
else {
//Mixed not finished!
#ifdef OCCT_DEBUG
cout <<" faces locally mixed"<<endl;
#endif
return BRepOffset_Convex;
}
}
else {
if (NormProVec > gp::Resolution())
ProVec.Normalize();
Standard_Real Prod = T1.Dot(DN1^DN2);
if (Prod > 0.) {
//
return BRepOffset_Convex;
}
else {
//reenters
return BRepOffset_Concave;
}
}
}

File diff suppressed because it is too large Load Diff

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

@@ -2336,10 +2336,6 @@ void BiTgte_Blend::ComputeShape()
BRep_Builder B;
#ifdef DRAW
Standard_Integer NbNT = 1;
#endif
// Maj of the Map of created.
// Update edges that do not change in the resulting shape
// i.e. invariant edges in the unwinding.

View File

@@ -46,9 +46,7 @@ static Standard_IStream& operator >>(Standard_IStream& IS, gp_Trsf& T)
T.SetValues(V1[0],V1[1],V1[2],V[0],
V2[0],V2[1],V2[2],V[1],
V3[0],V3[1],V3[2],V[2],
Precision::Angular(),
Precision::Confusion());
V3[0],V3[1],V3[2],V[2]);
return 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.
@@ -21,6 +21,7 @@
#include <Geom2d_Point.hxx>
#include <Geom2d_CartesianPoint.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <gp.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec2d.hxx>
@@ -31,21 +32,27 @@
#include <Bisector_BisecAna.hxx>
#include <Bisector_BisecPC.hxx>
#include <Bisector_BisecCC.hxx>
#include <GCE2d_MakeSegment.hxx>
/*
#ifdef DEB
//#define DRAW
#ifdef DRAW
#include <DrawTrSurf.hxx>
static char tname[100];
static Standard_CString name = tname ;
#pragma comment(lib, "TKDraw.lib")
static char name[100];
static Standard_Integer nbb = 0;
*/
static Standard_Boolean Affich = Standard_False;
#endif
#endif
static Standard_Boolean IsMaxRC (const Handle(Geom2d_Curve)& C,
Standard_Real U,
Standard_Real& R);
Standard_Real U,
Standard_Real& R);
static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis,
Standard_Real& UFirst,
Standard_Real& ULast);
Standard_Real& UFirst,
Standard_Real& ULast);
//=============================================================================
//function : Empty Constructor
//=============================================================================
@@ -66,48 +73,115 @@ Bisector_Bisec::Bisector_Bisec()
//===========================================================================
void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
const Handle(Geom2d_Curve)& asecondcurve ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector ,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
const Handle(Geom2d_Curve)& asecondcurve ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector ,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
{
Handle(Standard_Type) Type1 = afirstcurve ->DynamicType();
Handle(Standard_Type) Type2 = asecondcurve->DynamicType();
Handle(Bisector_Curve) Bis;
Standard_Real UFirst,ULast;
//gp_XY ref1( -65.9325, -200.28055 );
//gp_XY ref2(50.00154, -201.54198 );
//gp_XY p1 = afirstcurve->Value(afirstcurve->FirstParameter()).XY();
//gp_XY p2 = afirstcurve->Value(afirstcurve->LastParameter()).XY();
//if(p1.IsEqual(ref1, 1.e-5) && p2.IsEqual(ref2,1.e-5))
//{
// cout << "111" << endl;
//}
//p1 = asecondcurve->Value(asecondcurve->FirstParameter()).XY();
//p2 = asecondcurve->Value(asecondcurve->LastParameter()).XY();
//if(p1.IsEqual(ref1, 1.e-5) && p2.IsEqual(ref2,1.e-5))
//{
// cout << "222" << endl;
//}
if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve)
->BasisCurve()->DynamicType();
->BasisCurve()->DynamicType();
}
if (Type2 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Type2 = Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve)
->BasisCurve()->DynamicType();
->BasisCurve()->DynamicType();
}
Handle(Geom2d_Curve) afirstcurve1 = afirstcurve;
Handle(Geom2d_Curve) asecondcurve1 = asecondcurve;
if(Type1 == STANDARD_TYPE(Geom2d_BSplineCurve))
{
Handle(Geom2d_BSplineCurve) aBS;
if(afirstcurve->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve))
{
aBS = Handle(Geom2d_BSplineCurve)::DownCast(Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve)
->BasisCurve());
}
else
{
aBS = Handle(Geom2d_BSplineCurve)::DownCast(afirstcurve);
}
if(aBS->Degree() == 1 && aBS->NbPoles() == 2)
{
if(aBS->Pole(1).Distance(aBS->Pole(2)) < 1.e-4)
{
afirstcurve1 = GCE2d_MakeSegment(aBS->Pole(1), aBS->Pole(2));
Type1 = STANDARD_TYPE(Geom2d_Line);
}
}
}
if(Type2 == STANDARD_TYPE(Geom2d_BSplineCurve))
{
Handle(Geom2d_BSplineCurve) aBS;
if(asecondcurve->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve))
{
aBS = Handle(Geom2d_BSplineCurve)::DownCast(Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve)
->BasisCurve());
}
else
{
aBS = Handle(Geom2d_BSplineCurve)::DownCast(asecondcurve);
}
if(aBS->Degree() == 1 && aBS->NbPoles() == 2)
{
if(aBS->Pole(1).Distance(aBS->Pole(2)) < 1.e-4)
{
asecondcurve1 = GCE2d_MakeSegment(aBS->Pole(1), aBS->Pole(2));
Type2 = STANDARD_TYPE(Geom2d_Line);
}
}
}
if ( (Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) &&
(Type2 == STANDARD_TYPE(Geom2d_Circle) || Type2 == STANDARD_TYPE(Geom2d_Line)) ) {
(Type2 == STANDARD_TYPE(Geom2d_Circle) || Type2 == STANDARD_TYPE(Geom2d_Line)) )
{
//------------------------------------------------------------------
// Analytic Bissectrice.
//------------------------------------------------------------------
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
BisAna->Perform(afirstcurve ,
asecondcurve ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
BisAna->Perform(afirstcurve1 ,
asecondcurve1 ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
}
else {
Standard_Boolean IsLine = Standard_False;
Standard_Boolean IsLine = Standard_False;
if (oncurve) {
gp_Dir2d Fd(afirstvector);
@@ -115,7 +189,7 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
//if (Fd.Dot(Sd) < Precision::Angular() - 1.) {
//if (Fd.Dot(Sd) < 10*Precision::Angular() - 1.) //patch
if (Fd.Dot(Sd) < Sqrt(2.*Precision::Angular()) - 1.)
IsLine = Standard_True;
IsLine = Standard_True;
}
if (IsLine) {
//------------------------------------------------------------------
@@ -125,7 +199,7 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
Handle (Geom2d_CartesianPoint) PG = new Geom2d_CartesianPoint(apoint);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve)
BisL = new Geom2d_TrimmedCurve (L,0,Precision::Infinite());
BisL = new Geom2d_TrimmedCurve (L,0,Precision::Infinite());
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
@@ -137,58 +211,78 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
// Bissectrice algo
//-------------------------------------------------------------------
Handle(Bisector_BisecCC) BisCC = new Bisector_BisecCC();
BisCC -> Perform(asecondcurve,
afirstcurve ,
adirection ,
adirection ,
apoint);
BisCC -> Perform(asecondcurve1,
afirstcurve1 ,
adirection ,
adirection ,
apoint);
if (BisCC -> IsEmpty()) {
// bissectrice is empty. a point is projected at the end of the guide curve.
// Construction of a false bissectrice.
// modified by NIZHNY-EAP Mon Feb 21 12:00:13 2000 ___BEGIN___
gp_Dir2d dir1(afirstvector), dir2(asecondvector);
Standard_Real
Nx = - dir1.X() - dir2.X(),
Ny = - dir1.Y() - dir2.Y();
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
Nx = - afirstvector.Y();
Ny = afirstvector.X();
}
//gp_Dir2d N ( - adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Dir2d N ( adirection*Nx, adirection*Ny);
// modified by NIZHNY-EAP Mon Feb 21 12:00:19 2000 ___END___
Handle (Geom2d_CartesianPoint) PG = new Geom2d_CartesianPoint(apoint);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve)
BisL = new Geom2d_TrimmedCurve (L,0,Precision::Infinite());
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
// bissectrice is empty. a point is projected at the end of the guide curve.
// Construction of a false bissectrice.
// modified by NIZHNY-EAP Mon Feb 21 12:00:13 2000 ___BEGIN___
gp_Pnt2d aP1 = afirstcurve1->Value(afirstcurve1->LastParameter());
gp_Pnt2d aP2 = asecondcurve1->Value(asecondcurve1->FirstParameter());
gp_Pnt2d aPm(.5*(aP1.XY()+aP2.XY()));
Standard_Real Nx, Ny;
if(aPm.Distance(apoint) > 10.*Precision::Confusion())
{
Nx = apoint.X() - aPm.X();
Ny = apoint.Y() - aPm.Y();
if(adirection < 0)
{
Nx = -Nx;
Ny = -Ny;
}
}
else
{
gp_Dir2d dir1(afirstvector), dir2(asecondvector);
Nx = - dir1.X() - dir2.X(),
Ny = - dir1.Y() - dir2.Y();
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
Nx = -afirstvector.Y();
Ny = afirstvector.X();
}
}
gp_Dir2d N ( adirection*Nx, adirection*Ny);
// modified by NIZHNY-EAP Mon Feb 21 12:00:19 2000 ___END___
Handle (Geom2d_CartesianPoint) PG = new Geom2d_CartesianPoint(apoint);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve)
BisL = new Geom2d_TrimmedCurve (L,0,Precision::Infinite());
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
}
else {
UFirst = BisCC->FirstParameter();
ULast = BisCC->LastParameter ();
Bis = BisCC;
ReplaceByLineIfIsToSmall(Bis,UFirst,ULast);
UFirst = BisCC->FirstParameter();
ULast = BisCC->LastParameter ();
Bis = BisCC;
ReplaceByLineIfIsToSmall(Bis,UFirst,ULast);
}
}
}
UFirst = Max(UFirst, Bis->FirstParameter());
ULast = Min(ULast, Bis->LastParameter());
thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast);
/*
sprintf( name, "c1_%d", ++nbb );
DrawTrSurf::Set( name, afirstcurve );
sprintf( name, "c2_%d", nbb );
DrawTrSurf::Set( name, asecondcurve );
sprintf( name, "p%d", nbb );
DrawTrSurf::Set( name, apoint );
sprintf( name, "b%d", nbb );
DrawTrSurf::Set( name, thebisector );
*/
#ifdef DRAW
if(Affich)
{
sprintf( name, "c1_%d", ++nbb );
DrawTrSurf::Set( name, afirstcurve );
sprintf( name, "c2_%d", nbb );
DrawTrSurf::Set( name, asecondcurve );
sprintf( name, "p%d", nbb );
DrawTrSurf::Set( name, apoint );
sprintf( name, "b%d", nbb );
DrawTrSurf::Set( name, thebisector );
}
#endif
}
//===========================================================================
@@ -204,13 +298,13 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
//===========================================================================
void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
const Handle(Geom2d_Point)& asecondpoint ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
const Handle(Geom2d_Point)& asecondpoint ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
{
//gp_Pnt2d SecondPnt = asecondpoint->Pnt2d();
@@ -220,7 +314,7 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve)
->BasisCurve()->DynamicType();
->BasisCurve()->DynamicType();
}
if ( Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) {
@@ -229,13 +323,13 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
//------------------------------------------------------------------
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
BisAna -> Perform (afirstcurve ,
asecondpoint ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
asecondpoint ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
@@ -243,11 +337,11 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
else {
Standard_Boolean IsLine = Standard_False;
Standard_Real RC = Precision::Infinite();
if (oncurve) {
if (Bisector::IsConvex(afirstcurve,adirection) ||
IsMaxRC(afirstcurve,afirstcurve->LastParameter(),RC)) {
IsLine = Standard_True;
IsMaxRC(afirstcurve,afirstcurve->LastParameter(),RC)) {
IsLine = Standard_True;
}
}
if (IsLine) {
@@ -269,66 +363,73 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
//-------------------------------------------------------------------
Handle(Bisector_BisecPC) BisPC = new Bisector_BisecPC();
Handle(Geom2d_Curve) afirstcurvereverse = afirstcurve->Reversed();
BisPC -> Perform(afirstcurvereverse ,
asecondpoint->Pnt2d(),
- adirection );
// Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin
asecondpoint->Pnt2d(),
- adirection );
// Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin
if (BisPC -> IsEmpty()) {
gp_Dir2d dir1(afirstvector), dir2(asecondvector);
Standard_Real
Nx = - dir1.X() - dir2.X(),
Ny = - dir1.Y() - dir2.Y();
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
Nx = - afirstvector.Y();
Ny = afirstvector.X();
}
// gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Dir2d N ( adirection*Nx, adirection*Ny);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve(L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
gp_Dir2d dir1(afirstvector), dir2(asecondvector);
Standard_Real
Nx = - dir1.X() - dir2.X(),
Ny = - dir1.Y() - dir2.Y();
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
Nx = - afirstvector.Y();
Ny = afirstvector.X();
}
// gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Dir2d N ( adirection*Nx, adirection*Ny);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve(L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
} else {
// Modified by Sergey KHROMOV - Wed Mar 6 17:01:08 2002 End
UFirst = BisPC->Parameter(apoint);
ULast = BisPC->LastParameter();
if(UFirst >= ULast)
{
//Standard_Real t = .9;
//UFirst = (1. - t) * BisPC->FirstParameter() + t * ULast;
//Extrapolate by line
//gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) );
gp_Dir2d N( V );
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve (L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
}
else
Bis = BisPC;
// Modified by Sergey KHROMOV - Wed Mar 6 17:01:08 2002 End
UFirst = BisPC->Parameter(apoint);
ULast = BisPC->LastParameter();
if(UFirst >= ULast)
{
//Standard_Real t = .9;
//UFirst = (1. - t) * BisPC->FirstParameter() + t * ULast;
//Extrapolate by line
//gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) );
gp_Dir2d N( V );
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve (L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
}
else
Bis = BisPC;
}
}
}
if(UFirst < Bis->FirstParameter())
UFirst = Bis->FirstParameter();
if(ULast > Bis->LastParameter())
ULast = Bis->LastParameter();
thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast);
/*
#ifdef DRAW
if(Affich)
{
sprintf( name, "c1_%d", ++nbb );
DrawTrSurf::Set( name, afirstcurve );
sprintf( name, "c2_%d", nbb );
DrawTrSurf::Set( name, SecondPnt );
DrawTrSurf::Set( name, asecondpoint->Pnt2d() );
sprintf( name, "p%d", nbb );
DrawTrSurf::Set( name, apoint );
sprintf( name, "b%d", nbb );
DrawTrSurf::Set( name, thebisector );
*/
}
#endif
}
//===========================================================================
@@ -344,13 +445,13 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve ,
//===========================================================================
void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
const Handle(Geom2d_Curve)& asecondcurve ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
const Handle(Geom2d_Curve)& asecondcurve ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
{
//gp_Pnt2d FirstPnt = afirstpoint->Pnt2d();
@@ -358,38 +459,38 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
Handle(Bisector_Curve) Bis;
Handle(Standard_Type) Type1 = asecondcurve ->DynamicType();
Standard_Real UFirst,ULast;
if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve)
->BasisCurve()->DynamicType();
->BasisCurve()->DynamicType();
}
if ( Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) {
//------------------------------------------------------------------
// Analytic Bissectrice.
//------------------------------------------------------------------
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
BisAna -> Perform (afirstpoint ,
asecondcurve ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
asecondcurve ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
}
else {
// Standard_Real UPoint = 0.;
// Standard_Real UPoint = 0.;
Standard_Boolean IsLine = Standard_False;
Standard_Real RC = Precision::Infinite();
if (oncurve) {
if (Bisector::IsConvex(asecondcurve, adirection) ||
IsMaxRC(asecondcurve,asecondcurve->FirstParameter(),RC)) {
IsLine = Standard_True;
IsMaxRC(asecondcurve,asecondcurve->FirstParameter(),RC)) {
IsLine = Standard_True;
}
}
if (IsLine) {
@@ -411,62 +512,69 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
//-------------------------------------------------------------------
Handle(Bisector_BisecPC) BisPC = new Bisector_BisecPC();
BisPC -> Perform(asecondcurve ,
afirstpoint->Pnt2d(),
adirection );
// Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin
afirstpoint->Pnt2d(),
adirection );
// Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin
if (BisPC -> IsEmpty()) {
gp_Dir2d dir1(afirstvector), dir2(asecondvector);
Standard_Real
Nx = - dir1.X() - dir2.X(),
Ny = - dir1.Y() - dir2.Y();
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
Nx = - afirstvector.Y();
Ny = afirstvector.X();
}
// gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Dir2d N ( adirection*Nx, adirection*Ny);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve(L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
gp_Dir2d dir1(afirstvector), dir2(asecondvector);
Standard_Real
Nx = - dir1.X() - dir2.X(),
Ny = - dir1.Y() - dir2.Y();
if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
Nx = - afirstvector.Y();
Ny = afirstvector.X();
}
// gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Dir2d N ( adirection*Nx, adirection*Ny);
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve(L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
} else {
// Modified by Sergey KHROMOV - Thu Feb 21 16:49:58 2002 End
UFirst = BisPC->Parameter(apoint);
ULast = BisPC->LastParameter();
if(UFirst >= ULast)
{
//Extrapolate by line
//gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) );
gp_Dir2d N( V );
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve (L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
}
else
Bis = BisPC;
// Modified by Sergey KHROMOV - Thu Feb 21 16:49:58 2002 End
UFirst = BisPC->Parameter(apoint);
ULast = BisPC->LastParameter();
if(UFirst >= ULast)
{
//Extrapolate by line
//gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) );
gp_Dir2d N( V );
Handle (Geom2d_Line) L = new Geom2d_Line (apoint,N);
Handle (Geom2d_TrimmedCurve) BisL = new Geom2d_TrimmedCurve (L,0,RC);
Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna ();
BisAna->Init(BisL);
UFirst = BisAna->ParameterOfStartPoint();
ULast = BisAna->ParameterOfEndPoint();
Bis = BisAna;
}
else
Bis = BisPC;
}
}
}
UFirst = Max(UFirst, Bis->FirstParameter());
ULast = Min(ULast, Bis->LastParameter());
thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast);
/*
#ifdef DRAW
if(Affich)
{
sprintf( name, "c1_%d", ++nbb );
DrawTrSurf::Set( name, FirstPnt );
DrawTrSurf::Set( name, afirstpoint->Pnt2d() );
sprintf( name, "c2_%d", nbb );
DrawTrSurf::Set( name, asecondcurve );
sprintf( name, "p%d", nbb );
DrawTrSurf::Set( name, apoint );
sprintf( name, "b%d", nbb );
DrawTrSurf::Set( name, thebisector );
*/
}
#endif
}
//===========================================================================
@@ -481,29 +589,31 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
//===========================================================================
void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
const Handle(Geom2d_Point)& asecondpoint ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
const Handle(Geom2d_Point)& asecondpoint ,
const gp_Pnt2d& apoint ,
const gp_Vec2d& afirstvector ,
const gp_Vec2d& asecondvector,
const Standard_Real adirection ,
const Standard_Real tolerance ,
const Standard_Boolean oncurve )
{
Handle(Bisector_BisecAna) Bis = new Bisector_BisecAna();
Bis -> Perform (afirstpoint ,
asecondpoint ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
asecondpoint ,
apoint ,
afirstvector ,
asecondvector ,
adirection ,
tolerance ,
oncurve );
thebisector = new Geom2d_TrimmedCurve(Bis,
Bis->ParameterOfStartPoint(),
Bis->ParameterOfEndPoint());
Bis->ParameterOfStartPoint(),
Bis->ParameterOfEndPoint());
/*
#ifdef DRAW
if(Affich)
{
sprintf( name, "c1_%d", ++nbb );
DrawTrSurf::Set( name, afirstpoint->Pnt2d() );
sprintf( name, "c2_%d", nbb );
@@ -512,7 +622,8 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint ,
DrawTrSurf::Set( name, apoint );
sprintf( name, "b%d", nbb );
DrawTrSurf::Set( name, thebisector );
*/
}
#endif
}
//=============================================================================
@@ -539,8 +650,8 @@ const Handle(Geom2d_TrimmedCurve)& Bisector_Bisec::ChangeValue()
// replaced by a half-straight.
//=============================================================================
static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis,
Standard_Real& UFirst,
Standard_Real& ULast )
Standard_Real& UFirst,
Standard_Real& ULast )
{
if (Abs(ULast - UFirst) > 2.*Precision::PConfusion()*10.) return; //patch
@@ -568,8 +679,8 @@ static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis,
//purpose :
//=============================================================================
static Standard_Boolean IsMaxRC (const Handle(Geom2d_Curve)& C,
Standard_Real U,
Standard_Real& R)
Standard_Real U,
Standard_Real& R)
{
Standard_Real KF,KL;
Standard_Real US = C->FirstParameter();
@@ -583,7 +694,7 @@ static Standard_Boolean IsMaxRC (const Handle(Geom2d_Curve)& C,
Norm2 = D1.SquareMagnitude();;
if (Norm2 < gp::Resolution()) { KF = 0.0;}
else { KF = Abs(D1^D2)/(Norm2*sqrt(Norm2));}
C->D2(UL,P,D1,D2);
Norm2 = D1.SquareMagnitude();;
if (Norm2 < gp::Resolution()) { KL = 0.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.
@@ -46,24 +46,24 @@
static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
const Handle(Geom2d_Curve)& C,
Standard_Real& theParam);
const Handle(Geom2d_Curve)& C,
Standard_Real& theParam);
static Standard_Real Curvature (const Handle(Geom2d_Curve)& C,
Standard_Real U,
Standard_Real Tol) ;
Standard_Real U,
Standard_Real Tol) ;
static Standard_Boolean TestExtension (const Handle(Geom2d_Curve)& C1,
const Handle(Geom2d_Curve)& C2,
const Standard_Integer Start_End);
const Handle(Geom2d_Curve)& C2,
const Standard_Integer Start_End);
static Standard_Boolean DiscretPar(const Standard_Real DU,
const Standard_Real EpsMin,
const Standard_Real EpsMax,
const Standard_Integer NbMin,
const Standard_Integer NbMax,
Standard_Real& Eps,
Standard_Integer& Nb);
const Standard_Real EpsMin,
const Standard_Real EpsMax,
const Standard_Integer NbMin,
const Standard_Integer NbMax,
Standard_Real& Eps,
Standard_Integer& Nb);
//=============================================================================
//function :
@@ -80,11 +80,11 @@ Bisector_BisecCC::Bisector_BisecCC()
//purpose :
//=============================================================================
Bisector_BisecCC::Bisector_BisecCC(const Handle(Geom2d_Curve)& Cu1,
const Handle(Geom2d_Curve)& Cu2,
const Standard_Real Side1,
const Standard_Real Side2,
const gp_Pnt2d& Origin,
const Standard_Real DistMax)
const Handle(Geom2d_Curve)& Cu2,
const Standard_Real Side1,
const Standard_Real Side2,
const gp_Pnt2d& Origin,
const Standard_Real DistMax)
{
Perform (Cu1,Cu2,Side1,Side2,Origin,DistMax);
}
@@ -94,11 +94,11 @@ Bisector_BisecCC::Bisector_BisecCC(const Handle(Geom2d_Curve)& Cu1,
//purpose :
//=============================================================================
void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
const Handle(Geom2d_Curve)& Cu2,
const Standard_Real Side1,
const Standard_Real Side2,
const gp_Pnt2d& Origin,
const Standard_Real DistMax)
const Handle(Geom2d_Curve)& Cu2,
const Standard_Real Side1,
const Standard_Real Side2,
const gp_Pnt2d& Origin,
const Standard_Real DistMax)
{
isEmpty = Standard_False;
distMax = DistMax;
@@ -122,7 +122,6 @@ void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
// Calculate first point of the polygon.
//---------------------------------------------
Standard_Boolean isProjDone = ProjOnCurve (Origin,curve1, U);
P = ValueByInt (U,UC1,UC2,Dist);
if(!isProjDone)
{
@@ -130,6 +129,20 @@ void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
return;
}
P = ValueByInt (U,UC1,UC2,Dist);
if(Dist < Precision::Confusion())
{
gp_Pnt2d aP1 = curve1->Value(UC1);
gp_Pnt2d aP2 = curve2->Value(UC2);
Standard_Real dp = (aP1.Distance(P)+aP2.Distance(P));
Standard_Real dorig = (aP1.Distance(Origin)+aP2.Distance(Origin));
if(dp < dorig)
{
isEmpty = Standard_True;
return;
}
}
if (Dist < Precision::Infinite()) {
//----------------------------------------------------
// the parameter of the origin point gives a point
@@ -164,7 +177,7 @@ void Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
}
}
if ( !myPolygon.Length() == 0) {
if ( myPolygon.Length() != 0 ) {
SupLastParameter();
//----------------------------------------------
// Construction of the polygon of the bissectrice.
@@ -363,11 +376,11 @@ Handle(Geom2d_Geometry) Bisector_BisecCC::Copy() const
Handle(Bisector_BisecCC) Bisector_BisecCC::ChangeGuide() const
{
Handle(Bisector_BisecCC) C = new Bisector_BisecCC();
C -> Curve (1, curve2) ; C -> Curve (2, curve1);
C -> Sign (1, sign2 ) ; C -> Sign (2, sign1 );
C -> IsConvex (1, isConvex2); C -> IsConvex (2, isConvex1);
//-------------------------------------------------------------------------
// Construction of the new polygon from the initial one.
// inversion of PointOnBis and Calculation of new parameters on the bissectrice.
@@ -380,8 +393,8 @@ Handle(Bisector_BisecCC) Bisector_BisecCC::ChangeGuide() const
for (Standard_Integer i = myPolygon.Length(); i >=1; i--) {
Bisector_PointOnBis P = myPolygon.Value(i);
Bisector_PointOnBis NewP (P.ParamOnC2(), P.ParamOnC1(),
P.ParamOnC2(), P.Distance (),
P.Point());
P.ParamOnC2(), P.Distance (),
P.Point());
Poly.Append (NewP);
}
}
@@ -389,15 +402,15 @@ Handle(Bisector_BisecCC) Bisector_BisecCC::ChangeGuide() const
for (Standard_Integer i = 1; i <= myPolygon.Length(); i ++) {
Bisector_PointOnBis P = myPolygon.Value(i);
Bisector_PointOnBis NewP (P.ParamOnC2(), P.ParamOnC1(),
P.ParamOnC2(), P.Distance (),
P.Point());
P.ParamOnC2(), P.Distance (),
P.Point());
Poly.Append (NewP);
}
}
C -> Polygon (Poly);
C -> FirstParameter (Poly.First().ParamOnBis());
C -> LastParameter (Poly.Last() .ParamOnBis());
return C;
}
@@ -429,7 +442,7 @@ Standard_Boolean Bisector_BisecCC::IsCN (const Standard_Integer N) const
//=============================================================================
Standard_Real Bisector_BisecCC::FirstParameter() const
{
return startIntervals.First();
return startIntervals.First();
}
//=============================================================================
@@ -438,7 +451,7 @@ Standard_Real Bisector_BisecCC::FirstParameter() const
//=============================================================================
Standard_Real Bisector_BisecCC::LastParameter() const
{
return endIntervals.Last();
return endIntervals.Last();
}
//=============================================================================
@@ -475,7 +488,7 @@ Standard_Real Bisector_BisecCC::IntervalFirst(const Standard_Integer Index) cons
{
return startIntervals.Value(Index);
}
//=============================================================================
//function : IntervalLast
//purpose :
@@ -510,7 +523,7 @@ Standard_Boolean Bisector_BisecCC::IsClosed() const
{
if (curve1->IsClosed()) {
if (startIntervals.First() == curve1->FirstParameter() &&
endIntervals .Last () == curve1->LastParameter () )
endIntervals .Last () == curve1->LastParameter () )
return Standard_True;
}
return Standard_False;
@@ -531,8 +544,8 @@ Standard_Boolean Bisector_BisecCC::IsPeriodic() const
//purpose :
//=============================================================================
static Standard_Real Curvature (const Handle(Geom2d_Curve)& C,
Standard_Real U,
Standard_Real Tol)
Standard_Real U,
Standard_Real Tol)
{
Standard_Real K1;
gp_Vec2d D1,D2;
@@ -569,9 +582,9 @@ static Standard_Real Curvature (const Handle(Geom2d_Curve)& C,
//
//=============================================================================
gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
Standard_Real& U1,
Standard_Real& U2,
Standard_Real& Dist) const
Standard_Real& U1,
Standard_Real& U2,
Standard_Real& Dist) const
{
gp_Vec2d T;
@@ -619,11 +632,11 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
//---------------------------------------------------------------
gp_Pnt2d P1;
gp_Vec2d T1;
Standard_Real EpsH = 1.E-8;
Standard_Real EpsH100 = 1.E-6;
Standard_Real EpsH = 1.E-9;
Standard_Real EpsH100 = 1.E-7;
curve1->D1 (U1,P1,T1);
gp_Vec2d N1(T1.Y(), - T1.X());
if ((VMax - VMin) < Precision::PConfusion()) {
U2 = VInit;
}
@@ -637,14 +650,14 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
else {
math_BissecNewton SolNew (H,VMin - EpsH100,VMax + EpsH100,EpsH,10);
if (SolNew.IsDone()) {
U2 = SolNew.Root();
U2 = SolNew.Root();
}
else {
math_FunctionRoot SolRoot (H,VInit,EpsH,VMin - EpsH100,VMax + EpsH100);
if (SolRoot.IsDone()) {
U2 = SolRoot.Root();
}
else { Valid = Standard_False;}
math_FunctionRoot SolRoot (H,VInit,EpsH,VMin - EpsH100,VMax + EpsH100);
if (SolRoot.IsDone()) {
U2 = SolRoot.Root();
}
else { Valid = Standard_False;}
}
}
}
@@ -667,8 +680,8 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
Valid = Standard_False;
}
else {
PBis = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1);
Dist = P1.SquareDistance(PBis);
PBis = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1);
Dist = P1.SquareDistance(PBis);
}
}
@@ -691,20 +704,20 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
Geom2dAdaptor_Curve ANorLi(NorLi);
//-------------------------------------------------------------------------
Geom2dInt_GInter Intersect(ABisPC,ANorLi,
Precision::Confusion(),Precision::Confusion());
Precision::Confusion(),Precision::Confusion());
//-------------------------------------------------------------------------
if (Intersect.IsDone() && !Intersect.IsEmpty()) {
for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
if (Intersect.Point(i).ParamOnSecond()*sign1 < Precision::PConfusion()) {
P = Intersect.Point(i).Value();
if (P.SquareDistance(P1) < DMin) {
DMin = P.SquareDistance(P1);
PBis = P;
U2 = BisPC->LinkBisCurve(Intersect.Point(i).ParamOnFirst());
Dist = DMin;
}
}
if (Intersect.Point(i).ParamOnSecond()*sign1 < Precision::PConfusion()) {
P = Intersect.Point(i).Value();
if (P.SquareDistance(P1) < DMin) {
DMin = P.SquareDistance(P1);
PBis = P;
U2 = BisPC->LinkBisCurve(Intersect.Point(i).ParamOnFirst());
Dist = DMin;
}
}
}
}
}
@@ -725,9 +738,9 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real U,
// normal at this point.
//=============================================================================
gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
Standard_Real& U1,
Standard_Real& U2,
Standard_Real& Dist) const
Standard_Real& U1,
Standard_Real& U2,
Standard_Real& Dist) const
{
//------------------------------------------------------------------
// Return point, tangent, normal on C1 at parameter U.
@@ -738,7 +751,7 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
gp_Vec2d Tan1,Tan2;
curve1->D1(U1,P1,Tan1);
gp_Vec2d N1( Tan1.Y(), - Tan1.X());
//--------------------------------------------------------------------------
// test confusion of P1 with extremity of curve2.
//--------------------------------------------------------------------------
@@ -777,7 +790,7 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
Standard_Integer NbSamples =20;
Standard_Real UFirstOnC2 = curve2->FirstParameter();
Standard_Real ULastOnC2 = curve2->LastParameter();
if (!myPolygon.IsEmpty()){
if (sign1 == sign2) { ULastOnC2 = myPolygon.Last().ParamOnC2();}
else { UFirstOnC2 = myPolygon.Last().ParamOnC2();}
@@ -792,10 +805,10 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
Bisector_FunctionH H (curve2,P1,sign1*sign2*Tan1);
math_FunctionRoots SolRoot (H,
UFirstOnC2,
ULastOnC2 ,
NbSamples,
EpsX,EpsH,EpsH);
UFirstOnC2,
ULastOnC2 ,
NbSamples,
EpsX,EpsH,EpsH);
if (SolRoot.IsDone()) {
for (Standard_Integer j = 1; j <= SolRoot.NbSolutions(); j++) {
USol = SolRoot.Value(j);
@@ -806,60 +819,60 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
// Test if the solution is at the proper side of the curves.
if (N1P2P1*sign1 > 0 ) {
P = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1);
DistPP1 = P1.SquareDistance(P);
if (DistPP1 < DMin) {
DMin = DistPP1;
PSol = P;
U2 = USol;
YaSol = Standard_True;
}
P = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1);
DistPP1 = P1.SquareDistance(P);
if (DistPP1 < DMin) {
DMin = DistPP1;
PSol = P;
U2 = USol;
YaSol = Standard_True;
}
}
}
}
/*
/*
if (!YaSol) {
//--------------------------------------------------------------------
// Construction de la bisectrice point courbe et de la droite passant
// par P1 et portee par la normale.
//--------------------------------------------------------------------
Handle(Bisector_BisecPC) BisPC
= new Bisector_BisecPC(curve2,P1,sign2,2*distMax);
//-------------------------------
// Test si la bissectrice existe.
//-------------------------------
if (BisPC->IsEmpty()) {
Dist = Precision::Infinite();
PSol = P1;
return PSol;
}
Handle(Geom2d_Line) NorLi = new Geom2d_Line (P1,N1);
Geom2dAdaptor_Curve NorLiAd;
if (sign1 < 0.) {NorLiAd.Load(NorLi,0. ,distMax);}
else {NorLiAd.Load(NorLi,- distMax,0. );}
//-------------------------------------------------------------------------
Geom2dInt_GInter Intersect(BisPC,NorLiAd,
Precision::Confusion(),Precision::Confusion());
//-------------------------------------------------------------------------
if (Intersect.IsDone() && !Intersect.IsEmpty()) {
for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
if (Intersect.Point(i).ParamOnSecond()*sign1< Precision::PConfusion()) {
P = Intersect.Point(i).Value();
DistPP1 = P.SquareDistance(P1);
if (DistPP1 < DMin) {
DMin = DistPP1;
PSol = P;
U2 = Intersect.Point(i).ParamOnFirst();
YaSol = Standard_True;
}
}
}
}
//--------------------------------------------------------------------
// Construction de la bisectrice point courbe et de la droite passant
// par P1 et portee par la normale.
//--------------------------------------------------------------------
Handle(Bisector_BisecPC) BisPC
= new Bisector_BisecPC(curve2,P1,sign2,2*distMax);
//-------------------------------
// Test si la bissectrice existe.
//-------------------------------
if (BisPC->IsEmpty()) {
Dist = Precision::Infinite();
PSol = P1;
return PSol;
}
*/
Handle(Geom2d_Line) NorLi = new Geom2d_Line (P1,N1);
Geom2dAdaptor_Curve NorLiAd;
if (sign1 < 0.) {NorLiAd.Load(NorLi,0. ,distMax);}
else {NorLiAd.Load(NorLi,- distMax,0. );}
//-------------------------------------------------------------------------
Geom2dInt_GInter Intersect(BisPC,NorLiAd,
Precision::Confusion(),Precision::Confusion());
//-------------------------------------------------------------------------
if (Intersect.IsDone() && !Intersect.IsEmpty()) {
for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
if (Intersect.Point(i).ParamOnSecond()*sign1< Precision::PConfusion()) {
P = Intersect.Point(i).Value();
DistPP1 = P.SquareDistance(P1);
if (DistPP1 < DMin) {
DMin = DistPP1;
PSol = P;
U2 = Intersect.Point(i).ParamOnFirst();
YaSol = Standard_True;
}
}
}
}
}
*/
if (YaSol) {
Dist = DMin;
@@ -869,7 +882,7 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
P2 = curve2->Value(U2);
gp_Vec2d PP1(P1.X() - PSol.X(),P1.Y() - PSol.Y());
gp_Vec2d PP2(P2.X() - PSol.X(),P2.Y() - PSol.Y());
//-----------------------------------------------
// Dist = product of norms = distance at the square.
//-----------------------------------------------
@@ -878,18 +891,18 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
}
else {
if ( !isConvex1 ) {
Standard_Real K1 = Curvature(curve1,U1,Precision::Confusion());
if (K1 != 0.) {
if (Dist > 1/(K1*K1)) YaSol = Standard_False;
}
Standard_Real K1 = Curvature(curve1,U1,Precision::Confusion());
if (K1 != 0.) {
if (Dist > 1/(K1*K1)) YaSol = Standard_False;
}
}
if (YaSol) {
if ( !isConvex2 ) {
Standard_Real K2 = Curvature(curve2,U2,Precision::Confusion());
if (K2 != 0.) {
if (Dist > 1/(K2*K2)) YaSol = Standard_False;
}
}
if ( !isConvex2 ) {
Standard_Real K2 = Curvature(curve2,U2,Precision::Confusion());
if (K2 != 0.) {
if (Dist > 1/(K2*K2)) YaSol = Standard_False;
}
}
}
}
}
@@ -905,7 +918,7 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real U,
//purpose :
//=============================================================================
void Bisector_BisecCC::D0(const Standard_Real U,
gp_Pnt2d& P) const
gp_Pnt2d& P) const
{
Standard_Real U1,U2,Dist;
@@ -917,8 +930,8 @@ void Bisector_BisecCC::D0(const Standard_Real U,
//purpose :
//=============================================================================
void Bisector_BisecCC::D1(const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& V ) const
gp_Pnt2d& P,
gp_Vec2d& V ) const
{
V.SetCoord(0.,0.);
gp_Vec2d V2,V3;
@@ -930,9 +943,9 @@ void Bisector_BisecCC::D1(const Standard_Real U,
//purpose :
//=============================================================================
void Bisector_BisecCC::D2(const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2) const
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2) const
{
V1.SetCoord(0.,0.);
V2.SetCoord(0.,0.);
@@ -945,10 +958,10 @@ void Bisector_BisecCC::D2(const Standard_Real U,
//purpose :
//=============================================================================
void Bisector_BisecCC::D3(const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2,
gp_Vec2d& V3) const
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2,
gp_Vec2d& V3) const
{
V1.SetCoord(0.,0.);
V2.SetCoord(0.,0.);
@@ -961,7 +974,7 @@ void Bisector_BisecCC::D3(const Standard_Real U,
//purpose :
//=============================================================================
gp_Vec2d Bisector_BisecCC::DN(const Standard_Real U,
const Standard_Integer N) const
const Standard_Integer N) const
{
gp_Pnt2d P;
gp_Vec2d V1(0.,0.);
@@ -969,12 +982,12 @@ gp_Vec2d Bisector_BisecCC::DN(const Standard_Real U,
gp_Vec2d V3(0.,0.);
Values (U,N,P,V1,V2,V3);
switch (N) {
case 1 : return V1;
case 2 : return V2;
case 3 : return V3;
default: {
Standard_NotImplemented::Raise();
}
case 1 : return V1;
case 2 : return V2;
case 3 : return V3;
default: {
Standard_NotImplemented::Raise();
}
}
return V1;
}
@@ -1000,11 +1013,11 @@ gp_Vec2d Bisector_BisecCC::DN(const Standard_Real U,
//
//=============================================================================
void Bisector_BisecCC::Values (const Standard_Real U,
const Standard_Integer N,
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2,
gp_Vec2d& V3) const
const Standard_Integer N,
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2,
gp_Vec2d& V3) const
{
V1 = gp_Vec2d(0.,0.);
V2 = gp_Vec2d(0.,0.);
@@ -1014,7 +1027,7 @@ void Bisector_BisecCC::Values (const Standard_Real U,
// curve.
//-------------------------------------------------------------------------
Standard_Real U0,V0,Dist;
//-----------------------------------------------
// is the polygon reduced to a point or empty?
//-----------------------------------------------
@@ -1066,16 +1079,16 @@ void Bisector_BisecCC::Values (const Standard_Real U,
TvvPuPv = Tvv.Dot(PuPv) ; TvTvv = Tv.Dot(Tvv) ;
Standard_Real dHdu = 2*(TuPuPv*(TuuPuPv - TuTu)*TvTv +
TvPuPv*TuTv*TuTu -TuTuu*TvPuPv*TvPuPv);
TvPuPv*TuTv*TuTu -TuTuu*TvPuPv*TvPuPv);
Standard_Real dHdv = 2*(TuPuPv*TuTv*TvTv + TvTvv*TuPuPv*TuPuPv -
TvPuPv*(TvvPuPv + TvTv)*TuTu);
TvPuPv*(TvvPuPv + TvTv)*TuTu);
//-----------------------------
// Calculate dF/du and dF/dv.
//-----------------------------
Standard_Real NorPuPv,NuPuPv,NorTv;
Standard_Real A,B,dAdu,dAdv,dBdu,dBdv,BB;
NorPuPv = Nor.Dot(PuPv);
NuPuPv = Nu .Dot(PuPv);
NorTv = Nor.Dot(Tv) ;
@@ -1087,7 +1100,7 @@ void Bisector_BisecCC::Values (const Standard_Real U,
dBdu = - NuPuPv ;
dAdv = TvPuPv;
dBdv = - NorTv;
//---------------------------------------
// F(u,v) = Pu - (A(u,v)/B(u,v))*Nor(u)
//----------------------------------------
@@ -1098,7 +1111,7 @@ void Bisector_BisecCC::Values (const Standard_Real U,
else {
gp_Vec2d dFdu = Tu - (dAdu/B - dBdu*A/BB)*Nor - (A/B)*Nu;
gp_Vec2d dFdv = ( - dAdv/B + dBdv*A/BB)*Nor ;
if (Abs(dHdv) > gp::Resolution()) {
V1 = dFdu + dFdv*( - dHdu / dHdv );
}
@@ -1115,10 +1128,10 @@ void Bisector_BisecCC::Values (const Standard_Real U,
// by tangence of the curve.
//============================================================================
gp_Pnt2d Bisector_BisecCC::Extension (const Standard_Real U,
Standard_Real& U1,
Standard_Real& U2,
Standard_Real& Dist,
gp_Vec2d& T ) const
Standard_Real& U1,
Standard_Real& U2,
Standard_Real& Dist,
gp_Vec2d& T ) const
{
Bisector_PointOnBis PRef;
gp_Pnt2d P,P1,P2,PBis;
@@ -1189,7 +1202,7 @@ gp_Pnt2d Bisector_BisecCC::Extension (const Standard_Real U,
}
if (T1.Dot(Tang) < 0.) Tang = - Tang;
}
T = Tang.Normalized();
PBis.SetCoord(P.X() + dU*T.X(),P.Y() + dU*T.Y());
Dist = P1.Distance(PBis);
@@ -1201,12 +1214,12 @@ gp_Pnt2d Bisector_BisecCC::Extension (const Standard_Real U,
// purpose :
//=============================================================================
static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
const Handle(Geom2d_Curve)& CB,
const Standard_Real SignA,
const Standard_Real SignB,
const Standard_Real UOnA,
Standard_Real& UOnB,
Standard_Real& Dist)
const Handle(Geom2d_Curve)& CB,
const Standard_Real SignA,
const Standard_Real SignB,
const Standard_Real UOnA,
Standard_Real& UOnB,
Standard_Real& Dist)
{
//------------------------------------------------------------------
// Return point,tangent, normal on CA with parameter UOnA.
@@ -1218,7 +1231,7 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
CA->D1(UOnA,P1,Tan1);
gp_Vec2d N1(Tan1.Y(), - Tan1.X());
//--------------------------------------------------------------------------
// test of confusion of P1 with extremity of curve2.
//--------------------------------------------------------------------------
@@ -1250,7 +1263,7 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
Standard_Real DMin = Precision::Infinite();
Standard_Real UPC;
Standard_Boolean YaSol = Standard_False;
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Construction of the bisectrice point curve and of the straight line passing
// through P1 and carried by the normal.
//--------------------------------------------------------------------
@@ -1271,21 +1284,21 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
Geom2dAdaptor_Curve ANorLi(NorLi);
//-------------------------------------------------------------------------
Geom2dInt_GInter Intersect(ABisPC,ANorLi,
Precision::Confusion(),Precision::Confusion());
Precision::Confusion(),Precision::Confusion());
//-------------------------------------------------------------------------
if (Intersect.IsDone() && !Intersect.IsEmpty()) {
for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
if (Intersect.Point(i).ParamOnSecond()*SignA < Precision::PConfusion()) {
P = Intersect.Point(i).Value();
if (P.SquareDistance(P1) < DMin) {
DMin = P.SquareDistance(P1);
PSol = P;
UPC = Intersect.Point(i).ParamOnFirst();
UOnB = BisPC->LinkBisCurve(UPC);
Dist = DMin;
YaSol = Standard_True;
}
P = Intersect.Point(i).Value();
if (P.SquareDistance(P1) < DMin) {
DMin = P.SquareDistance(P1);
PSol = P;
UPC = Intersect.Point(i).ParamOnFirst();
UOnB = BisPC->LinkBisCurve(UPC);
Dist = DMin;
YaSol = Standard_True;
}
}
}
}
@@ -1294,27 +1307,38 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
// Point found => Test distance curvature + Angular test
//---------------------------------------------------------------
P2 = CB->Value(UOnB);
if(P1.SquareDistance(PSol) < 1.e-32)
{
YaSol = Standard_False;
return YaSol;
}
if(P2.SquareDistance(PSol) < 1.e-32)
{
YaSol = Standard_False;
return YaSol;
}
gp_Dir2d PP1Unit(P1.X() - PSol.X(),P1.Y() - PSol.Y());
gp_Dir2d PP2Unit(P2.X() - PSol.X(),P2.Y() - PSol.Y());
if (PP1Unit*PP2Unit > 1. - Precision::Angular()) {
YaSol = Standard_False;
}
else {
Dist = sqrt(Dist);
if ( !IsConvexA ) {
Standard_Real K1 = Curvature(CA,UOnA,Precision::Confusion());
if (K1 != 0.) {
if (Dist > Abs(1/K1)) YaSol = Standard_False;
}
Standard_Real K1 = Curvature(CA,UOnA,Precision::Confusion());
if (K1 != 0.) {
if (Dist > Abs(1/K1)) YaSol = Standard_False;
}
}
if (YaSol) {
if ( !IsConvexB ) {
Standard_Real K2 = Curvature(CB,UOnB,Precision::Confusion());
if (K2 != 0.) {
if (Dist > Abs(1/K2)) YaSol = Standard_False;
}
}
if ( !IsConvexB ) {
Standard_Real K2 = Curvature(CB,UOnB,Precision::Confusion());
if (K2 != 0.) {
if (Dist > Abs(1/K2)) YaSol = Standard_False;
}
}
}
}
}
@@ -1426,20 +1450,20 @@ Standard_Real Bisector_BisecCC::Parameter(const gp_Pnt2d& P) const
//=============================================================================
//void Bisector_BisecCC::Dump(const Standard_Integer Deep,
void Bisector_BisecCC::Dump(const Standard_Integer ,
const Standard_Integer Offset) const
const Standard_Integer Offset) const
{
Indent (Offset);
cout <<"Bisector_BisecCC :"<<endl;
Indent (Offset);
// cout <<"Curve1 :"<<curve1<<endl;
// cout <<"Curve2 :"<<curve2<<endl;
// cout <<"Curve1 :"<<curve1<<endl;
// cout <<"Curve2 :"<<curve2<<endl;
cout <<"Sign1 :"<<sign1<<endl;
cout <<"Sign2 :"<<sign2<<endl;
cout <<"Number Of Intervals :"<<startIntervals.Length()<<endl;
for (Standard_Integer i = 1; i <= startIntervals.Length(); i++) {
cout <<"Interval number :"<<i<<"Start :"<<startIntervals.Value(i)
<<" end :"<< endIntervals.Value(i)<<endl ;
<<" end :"<< endIntervals.Value(i)<<endl ;
}
cout <<"Index Current Interval :"<<currentInterval<<endl;
}
@@ -1449,7 +1473,7 @@ void Bisector_BisecCC::Dump(const Standard_Integer ,
// purpose :
//=============================================================================
void Bisector_BisecCC::Curve(const Standard_Integer I,
const Handle(Geom2d_Curve)& C)
const Handle(Geom2d_Curve)& C)
{
if (I == 1) curve1 = C;
else if (I == 2) curve2 = C;
@@ -1461,7 +1485,7 @@ void Bisector_BisecCC::Curve(const Standard_Integer I,
// purpose :
//=============================================================================
void Bisector_BisecCC::Sign(const Standard_Integer I,
const Standard_Real S)
const Standard_Real S)
{
if (I == 1) sign1 = S;
else if (I == 2) sign2 = S;
@@ -1491,7 +1515,7 @@ void Bisector_BisecCC::DistMax(const Standard_Real D)
// purpose :
//=============================================================================
void Bisector_BisecCC::IsConvex(const Standard_Integer I,
const Standard_Boolean IsConvex)
const Standard_Boolean IsConvex)
{
if (I == 1) isConvex1 = IsConvex;
else if (I == 2) isConvex2 = IsConvex;
@@ -1586,7 +1610,7 @@ void Bisector_BisecCC::LastParameter (const Standard_Real U)
// purpose :
//=============================================================================
Standard_Real Bisector_BisecCC::SearchBound (const Standard_Real U1,
const Standard_Real U2) const
const Standard_Real U2) const
{
Standard_Real UMid,Dist1,Dist2,DistMid,U11,U22;
Standard_Real UC1,UC2;
@@ -1596,22 +1620,22 @@ Standard_Real Bisector_BisecCC::SearchBound (const Standard_Real U1,
U11 = U1; U22 = U2;
PBisPrec = ValueByInt(U11,UC1,UC2,Dist1);
PBis = ValueByInt(U22,UC1,UC2,Dist2);
while ((U22 - U11) > TolPar ||
((Dist1 < Precision::Infinite() &&
Dist2 < Precision::Infinite() &&
!PBis.IsEqual(PBisPrec,TolPnt)))) {
PBisPrec = PBis;
UMid = 0.5*( U22 + U11);
PBis = ValueByInt(UMid,UC1,UC2,DistMid);
if ((Dist1 < Precision::Infinite()) == (DistMid < Precision::Infinite())) {
U11 = UMid;
Dist1 = DistMid;
}
else {
U22 = UMid;
Dist2 = DistMid;
}
((Dist1 < Precision::Infinite() &&
Dist2 < Precision::Infinite() &&
!PBis.IsEqual(PBisPrec,TolPnt)))) {
PBisPrec = PBis;
UMid = 0.5*( U22 + U11);
PBis = ValueByInt(UMid,UC1,UC2,DistMid);
if ((Dist1 < Precision::Infinite()) == (DistMid < Precision::Infinite())) {
U11 = UMid;
Dist1 = DistMid;
}
else {
U22 = UMid;
Dist2 = DistMid;
}
}
PBis = ValueByInt(U11,UC1,UC2,Dist1);
if (Dist1 < Precision::Infinite()) {
@@ -1628,8 +1652,8 @@ Standard_Real Bisector_BisecCC::SearchBound (const Standard_Real U1,
// purpose :
//=============================================================================
static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
const Handle(Geom2d_Curve)& C,
Standard_Real& theParam)
const Handle(Geom2d_Curve)& C,
Standard_Real& theParam)
{
//Standard_Real UOnCurve =0.;
theParam = 0.0;
@@ -1644,16 +1668,16 @@ static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
theParam = C->FirstParameter();
return Standard_True;
}
if (P.IsEqual(PL ,Precision::Confusion()))
{
theParam = C->LastParameter();
return Standard_True;
}
gp_Vec2d PPF(PF.X() - P.X(), PF.Y() - P.Y());
TF.Normalize();
if ( Abs (PPF.Dot(TF)) < Precision::Confusion())
{
theParam = C->FirstParameter();
@@ -1667,8 +1691,8 @@ static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
return Standard_True;
}
Geom2dAPI_ProjectPointOnCurve Proj(P,C,
C->FirstParameter(),
C->LastParameter());
C->FirstParameter(),
C->LastParameter());
if (Proj.NbPoints() > 0) {
theParam = Proj.LowerDistanceParameter();
}
@@ -1684,8 +1708,8 @@ static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
// purpose :
//=============================================================================
static Standard_Boolean TestExtension (const Handle(Geom2d_Curve)& C1,
const Handle(Geom2d_Curve)& C2,
const Standard_Integer Start_End)
const Handle(Geom2d_Curve)& C2,
const Standard_Integer Start_End)
{
gp_Pnt2d P1,P2;
gp_Vec2d T1,T2;
@@ -1708,7 +1732,7 @@ static Standard_Boolean TestExtension (const Handle(Geom2d_Curve)& C1,
if (P1.IsEqual(P2,Precision::Confusion())) {
T2.Normalize();
if (T1.Dot(T2) > 1.0 - Precision::Confusion()) {
Test = Standard_True;
Test = Standard_True;
}
}
}
@@ -1753,12 +1777,12 @@ void Bisector_BisecCC::ComputePointEnd ()
// purpose :
//=============================================================================
static Standard_Boolean DiscretPar(const Standard_Real DU,
const Standard_Real EpsMin,
const Standard_Real EpsMax,
const Standard_Integer NbMin,
const Standard_Integer NbMax,
Standard_Real& Eps,
Standard_Integer& Nb)
const Standard_Real EpsMin,
const Standard_Real EpsMax,
const Standard_Integer NbMin,
const Standard_Integer NbMax,
Standard_Real& Eps,
Standard_Integer& Nb)
{
if (DU <= NbMin*EpsMin) {
Eps = DU/(NbMin + 1) ;

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,14 +33,14 @@
#include <Precision.hxx>
#include <math_BissecNewton.hxx>
#include <ElCLib.hxx>
#ifdef DRAW
#include <Draw_Appli.hxx>
#include <DrawTrSurf_Curve2d.hxx>
#include <Draw_Marker2D.hxx>
#endif
#ifdef DEB
//#define DRAW
#ifdef DRAW
#include <DrawTrSurf.hxx>
static char name[100];
static Standard_Boolean Affich = Standard_False;
static Standard_Integer nbint = 0;
#endif
#endif
//===================================================================================
@@ -174,14 +174,14 @@ void Bisector_Inter::Perform(const Bisector_Bisec& C1,
PMax,UMax,D2.LastTolerance());
if ((IB2 == 1 && Bis2->IsExtendAtStart()) ||
(IB2 == Bis1->NbIntervals() && Bis2->IsExtendAtEnd()) ){
//--------------------------------------------------------
// Part corresponding to an extension is a segment.
//--------------------------------------------------------
SBis2 [IB2] = ConstructSegment (PMin,PMax,UMin,UMax);
(IB2 == Bis1->NbIntervals() && Bis2->IsExtendAtEnd()) ){
//--------------------------------------------------------
// Part corresponding to an extension is a segment.
//--------------------------------------------------------
SBis2 [IB2] = ConstructSegment (PMin,PMax,UMin,UMax);
}
else {
SBis2 [IB2] = Bis2;
SBis2 [IB2] = Bis2;
}
NB2++;
}
@@ -271,11 +271,11 @@ void Bisector_Inter::SinglePerform(const Handle(Geom2d_Curve)& CBis1,
if (Type1 == STANDARD_TYPE(Geom2d_Line) && Type2 != STANDARD_TYPE(Geom2d_Line)) {
TestBound(Handle(Geom2d_Line)::DownCast(Bis1),
D1,Bis2,D2,TolConf,Standard_False);
D1,Bis2,D2,TolConf,Standard_False);
}
else if (Type2 == STANDARD_TYPE(Geom2d_Line)&& Type1 != STANDARD_TYPE(Geom2d_Line)) {
TestBound(Handle(Geom2d_Line)::DownCast(Bis2),
D2,Bis1,D1,TolConf,Standard_True);
D2,Bis1,D1,TolConf,Standard_True);
}
Geom2dInt_GInter Intersect;
Geom2dAdaptor_Curve ABis1(Bis1);
@@ -287,21 +287,17 @@ void Bisector_Inter::SinglePerform(const Handle(Geom2d_Curve)& CBis1,
#ifdef DRAW
if (Affich) {
Handle(DrawTrSurf_Curve2d) dr;
Draw_Color Couleur = Draw_bleu;
dr = new DrawTrSurf_Curve2d(Bis1,Couleur,100);
dout << dr;
dr = new DrawTrSurf_Curve2d(Bis2,Couleur,100);
dout << dr;
if (IsDone() && !IsEmpty()) {
sprintf( name, "i1_%d", ++nbint);
DrawTrSurf::Set(name, Bis1);
sprintf( name, "i2_%d", nbint);
DrawTrSurf::Set(name, Bis2);
if (IsDone() && !IsEmpty()) {
for (Standard_Integer k = 1; k <= NbPoints(); k++) {
gp_Pnt2d P = Point(k).Value();
Handle(Draw_Marker2D) drp = new Draw_Marker2D(P,Draw_Plus,Draw_vert);
dout << drp;
gp_Pnt2d P = Point(k).Value();
sprintf( name, "ip_%d_%d", nbint, k);
DrawTrSurf::Set(name, P);
}
}
dout.Flush();
}
#endif
}
@@ -334,7 +330,7 @@ void Bisector_Inter::NeighbourPerform(const Handle(Bisector_BisecCC)& Bis1,
// Change guiedline on Bis2.
BisTemp = Bis2->ChangeGuide();
Guide = Bis2->Curve(2);
#ifdef DEB
#ifdef OCCT_DEBUG
gp_Pnt2d P2S = Bis2->ValueAndDist(D2.FirstParameter(),U1,UMax,Dist);
gp_Pnt2d P2E = Bis2->ValueAndDist(D2.LastParameter() ,U1,UMin,Dist);
#else

View File

@@ -34,6 +34,7 @@
#include <BRepTools_WireExplorer.hxx>
#include <BRepTools_ShapeSet.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRep_TEdge.hxx>
#include <Precision.hxx>
#include <Poly_Triangulation.hxx>
#include <gp_Ax2.hxx>
@@ -968,6 +969,112 @@ static Standard_Integer countshapes(Draw_Interpretor& di,
return 0;
}
//=======================================================================
//
//=======================================================================
void setProp(TopoDS_Shape Sh, const char** a, Standard_Integer n)
{
Standard_Integer i;
for(i = 2; i < n; i++) {
if (strstr ( a[i], "free" )) {
if(a[i][0] == '-') {
Sh.Free(Standard_False);
}
else {
Sh.Free(Standard_True);
}
}
if (strstr ( a[i], "modified" )) {
if(a[i][0] == '-') {
Sh.Modified(Standard_False);
}
else {
Sh.Modified(Standard_True);
}
}
if (strstr ( a[i], "checked" )) {
if(a[i][0] == '-') {
Sh.Checked(Standard_False);
}
else {
Sh.Checked(Standard_True);
}
}
if (strstr ( a[i], "orientable" )) {
if(a[i][0] == '-') {
Sh.Orientable(Standard_False);
}
else {
Sh.Orientable(Standard_True);
}
}
if (strstr ( a[i], "closed" )) {
if(a[i][0] == '-') {
Sh.Closed(Standard_False);
}
else {
Sh.Closed(Standard_True);
}
}
if (strstr ( a[i], "infinite" )) {
if(a[i][0] == '-') {
Sh.Infinite(Standard_False);
}
else {
Sh.Infinite(Standard_True);
}
}
if (strstr ( a[i], "convex" )) {
if(a[i][0] == '-') {
Sh.Convex(Standard_False);
}
else {
Sh.Convex(Standard_True);
}
}
if (strstr ( a[i], "locked" )) {
if(a[i][0] == '-') {
Sh.Locked(Standard_False);
}
else {
Sh.Locked(Standard_True);
}
}
}
}
//=======================================================================
//
//=======================================================================
static Standard_Integer setFlags(Draw_Interpretor& ,
Standard_Integer n, const char** a)
{
if (n < 3) return 1;
TopExp_Explorer ex;
TopoDS_Shape Sh = DBRep::Get(a[1]);
if (Sh.IsNull()) return 1;
setProp(Sh, a, n);
for (ex.Init (Sh,TopAbs_VERTEX); ex.More(); ex.Next()) {
TopoDS_Shape S = ex.Current();
setProp(S, a, n);
}
for (ex.Init (Sh,TopAbs_EDGE); ex.More(); ex.Next()) {
TopoDS_Shape S = ex.Current();
setProp(S, a, n);
}
for (ex.Init (Sh,TopAbs_FACE); ex.More(); ex.Next()) {
TopoDS_Shape S = ex.Current();
setProp(S, a, n);
}
return 0;
}
//=======================================================================
//memory management
//=======================================================================
@@ -1200,6 +1307,9 @@ void DBRep::BasicCommands(Draw_Interpretor& theCommands)
__FILE__,nbshapes,g);
theCommands.Add("numshapes","numshapes s; size of shape",__FILE__,numshapes,g);
theCommands.Add("countshapes","countshapes s; count of shape",__FILE__,countshapes,g);
theCommands.Add("setflags",
"setflags shape_name flag1[flag2...]\n sets flags for shape(free, modidfied, checked, orientable, closed, infinite, convex, locked), for exmple <setflags a free> or <setflags a -free> if necessary unflag ",
__FILE__,setFlags,g);
// theCommands.Add("dumpmmgt",
// "dump le contenu du gestionnaire de memoire",__FILE__,dumpmmgt,g);

View File

@@ -133,6 +133,8 @@ is
generic class GExtCC2d, CCache2d, ECC2d;
generic class GLocateExtCC2d, LCCache2d, ELCC2d, LocECC2d;
imported UBTFilterCCPoints;
-- Curve-Surface:
class ExtCS;

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.
@@ -38,6 +38,7 @@
#include <Extrema_ExtPElS.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <Extrema_ExtPS.hxx>
#include <ElSLib.hxx>
Extrema_ExtCS::Extrema_ExtCS()
{
@@ -45,27 +46,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 +75,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 +93,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 +113,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() || myExtElCS.NbExt() > 0) break;
case GeomAbs_Torus:
case GeomAbs_Cone:
@@ -130,104 +131,106 @@ 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;
}
else if(myStype == GeomAbs_Plane)
{
myExtElCS.Perform(C.Circle(), myS->Plane());
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 +238,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 +292,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 +312,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 +329,7 @@ void Extrema_ExtCS::Perform(const Adaptor3d_Curve& C,
}
break;
}
myDone = myExtElCS.IsDone();
if (myDone) {
myIsPar = myExtElCS.IsParallel();
@@ -337,16 +340,40 @@ 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));
}
if(mySqDist.Length() == 0 && NbExt > 0)
{
//Analytical extremas seem to be out of curve/surface boundaries.
//For plane it is possible to add extremity points of curve
if(myStype == GeomAbs_Plane)
{
gp_Pln aPln = myS->Plane();
gp_Pnt PC, PP;
if(!Precision::IsInfinite(myucinf))
{
PC = C.Value(myucinf);
ElSLib::PlaneParameters(aPln.Position(), PC, U, V);
PP = ElSLib::PlaneValue(U, V, aPln.Position());
AddSolution(C, myucinf, U, V, PC, PP, PC.SquareDistance(PP));
}
if(!Precision::IsInfinite(myucsup))
{
PC = C.Value(myucsup);
ElSLib::PlaneParameters(aPln.Position(), PC, U, V);
PP = ElSLib::PlaneValue(U, V, aPln.Position());
AddSolution(C, myucsup, U, V, PC, PP, PC.SquareDistance(PP));
}
}
}
}
}
}
@@ -379,8 +406,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 +415,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 +436,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 +448,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

@@ -56,10 +56,39 @@ void Extrema_ExtElCS::Perform(const gp_Lin& C,
mySqDist->SetValue(1, S.SquareDistance(C));
myIsPar = Standard_True;
}
else {
else
{
myNbExt = 0;
}
IntAna_IntConicQuad anInter(C, S,
Precision::Angular(),
Precision::Confusion());
if(anInter.IsDone())
{
myNbExt = anInter.NbPoints();
}
if(myNbExt == 0)
return;
myPoint1 = new Extrema_HArray1OfPOnCurv(1, myNbExt);
mySqDist = new TColStd_HArray1OfReal(1, myNbExt);
myPoint2 = new Extrema_HArray1OfPOnSurf(1, myNbExt);
Standard_Real aUSurf = 0.0, aVSurf = 0.0;
Extrema_POnCurv aPOnC;
Extrema_POnSurf aPOnS;
const gp_Pnt& aPC = anInter.Point(1);
aPOnC.SetValues(anInter.ParamOnConic(1), aPC);
myPoint1->SetValue(1, aPOnC);
ElSLib::PlaneParameters(S.Position(), aPC, aUSurf, aVSurf);
const gp_Pnt aPS(ElSLib::PlaneValue(aUSurf, aVSurf, S.Position()));
aPOnS.SetParameters(aUSurf, aVSurf, aPS);
myPoint2->SetValue(1, aPOnS);
mySqDist->SetValue(1, 0.0);
}
}
@@ -261,13 +290,90 @@ Extrema_ExtElCS::Extrema_ExtElCS(const gp_Circ& C,
//void Extrema_ExtElCS::Perform(const gp_Circ& C,
// const gp_Pln& S)
void Extrema_ExtElCS::Perform(const gp_Circ& ,
const gp_Pln& )
void Extrema_ExtElCS::Perform(const gp_Circ& C,
const gp_Pln& S)
{
Standard_NotImplemented::Raise();
myDone = Standard_True;
myIsPar = Standard_False;
gp_Ax2 Pos = C.Position();
gp_Dir NCirc = Pos.Direction();
gp_Dir NPln = S.Axis().Direction();
if (NCirc.IsParallel(NPln, Precision::Angular())) {
mySqDist = new TColStd_HArray1OfReal(1, 1);
mySqDist->SetValue(1, S.SquareDistance(C.Location()));
myIsPar = Standard_True;
}
else {
gp_Dir ExtLine = NCirc ^ NPln;
ExtLine = ExtLine ^ NCirc;
//
gp_Dir XDir = Pos.XDirection();
Standard_Real T[2];
T[0] = XDir.AngleWithRef(ExtLine, NCirc);
if(T[0] < 0.)
{
//Put in period
T[0] += M_PI;
}
T[1] = T[0] + M_PI;
//
myNbExt = 2;
//Check intersection
IntAna_IntConicQuad anInter(C, S,
Precision::Angular(),
Precision::Confusion());
if(anInter.IsDone())
{
if(anInter.NbPoints() > 1)
{
myNbExt += anInter.NbPoints();
}
}
myPoint1 = new Extrema_HArray1OfPOnCurv(1, myNbExt);
mySqDist = new TColStd_HArray1OfReal(1, myNbExt);
myPoint2 = new Extrema_HArray1OfPOnSurf(1, myNbExt);
Standard_Integer i;
gp_Pnt PC, PP;
Standard_Real U, V;
Extrema_POnCurv POnC;
Extrema_POnSurf POnS;
for(i = 0; i < 2; ++i)
{
PC = ElCLib::CircleValue(T[i], C.Position(), C.Radius());
POnC.SetValues(T[i], PC);
myPoint1->SetValue(i+1, POnC);
ElSLib::PlaneParameters(S.Position(), PC, U, V);
PP = ElSLib::PlaneValue(U, V, S.Position());
POnS.SetParameters(U, V, PP);
myPoint2->SetValue(i+1, POnS);
mySqDist->SetValue(i+1, PC.SquareDistance(PP));
}
//
if(myNbExt > 2)
{
//Add intersection points
for(i = 1; i <= anInter.NbPoints(); ++i)
{
Standard_Real t = anInter.ParamOnConic(i);
PC = ElCLib::CircleValue(t, C.Position(), C.Radius());
POnC.SetValues(t, PC);
myPoint1->SetValue(i+2, POnC);
ElSLib::PlaneParameters(S.Position(), PC, U, V);
PP = ElSLib::PlaneValue(U, V, S.Position());
POnS.SetParameters(U, V, PP);
myPoint2->SetValue(i+2, POnS);
mySqDist->SetValue(i+2, PC.SquareDistance(PP));
}
}
}
//
}

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

@@ -28,7 +28,8 @@ uses POnCurv from Extrema,
Pnt from gp,
HArray1OfPnt from TColgp,
SequenceOfReal from TColStd,
ListOfTransient from TColStd
ListOfTransient from TColStd,
UBTFilterCCPoints from Extrema
raises InfiniteSolutions from StdFail,
@@ -138,12 +139,12 @@ is
Results(me: in out; AlgExt: ExtElC from Extrema;
Ut11, Ut12, Ut21, Ut22: Real)
is static protected;
is static;
Results(me: in out;AlgExt: ECC;
Ut11, Ut12, Ut21, Ut22: Real)
is static protected;
is static;
@@ -169,7 +170,8 @@ fields
mydist12: Real;
mydist21: Real;
mydist22: Real;
myFilter: UBTFilterCCPoints from Extrema;
end GExtCC;

View File

@@ -43,6 +43,95 @@
#include <Extrema_ExtPElC.hxx>
#include <Standard_NullObject.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <Bnd_Box.hxx>
#include <BndLib_Add3dCurve.hxx>
#include <TColgp_HArray1OfPnt.hxx>
typedef NCollection_UBTreeFiller<Handle(Extrema_CCache), Bnd_Box> UBTreeFiller;
typedef NCollection_UBTree<Handle(Extrema_CCache), Bnd_Box> UBTree;
class ComputeIntervExtrema : public UBTree::Selector
{
public:
/**
* Constructor
*/
ComputeIntervExtrema(const Handle(Extrema_CCache)& theCache, Extrema_ECCOfExtCC& theECC, Extrema_GExtCC *theExt, const Standard_Boolean theIsFirst, const Standard_Real U11, const Standard_Real U12, const Standard_Real U21, const Standard_Real U22) : myECC(theECC), myExt(theExt), myIsFirst(theIsFirst), myU11(U11), myU12(U12), myU21(U21), myU22(U22)
{
if(theIsFirst)
myECC.SetCurveCache (1, theCache);
else
myECC.SetCurveCache (2, theCache);
//Initialize BndBox
myBox.SetVoid();
Curve1& aC = *(Curve1*)(theCache->CurvePtr());
const Standard_Real aFPar = theCache->FirstParameter(),
aLPar = theCache->LastParameter();
BndLib_Add3dCurve::Add(aC, aFPar, aLPar, Precision::Confusion(), myBox);
myBox.Enlarge(Precision::Infinite());
};
/**
* Bounding box rejection - definition of virtual method.
*/
Standard_EXPORT virtual Standard_Boolean Reject(const Bnd_Box& theBox) const;
/**
* Redefined from the base class
*/
Standard_EXPORT virtual Standard_Boolean Accept(const Handle(Extrema_CCache)& theCache);
protected:
ComputeIntervExtrema& operator=(ComputeIntervExtrema&);
private:
Extrema_ECCOfExtCC& myECC;
Bnd_Box myBox;
Extrema_GExtCC *myExt;
const Standard_Boolean myIsFirst;
Standard_Real myU11;
Standard_Real myU12;
Standard_Real myU21;
Standard_Real myU22;
}; //end fo clMinimumDistanceSelector
Standard_Boolean ComputeIntervExtrema::Reject(const Bnd_Box& theBox) const
{
return (theBox.IsOut(myBox));
}
Standard_Boolean ComputeIntervExtrema::Accept(const Handle(Extrema_CCache)& theCache)
{
if(myIsFirst)
myECC.SetCurveCache (2, theCache);
else
myECC.SetCurveCache (1, theCache);
myECC.Perform();
myExt->Results(myECC, myU11, myU12, myU21, myU22);
if(!myECC.IsDone() || myECC.NbExt() == 0)
return Standard_True;
Standard_Real aMinDist = RealLast();
for(Standard_Integer i = 1; i <= myECC.NbExt(); i++)
{
aMinDist = Min(aMinDist, myECC.SquareDistance(i));
}
myBox.SetGap(sqrt(aMinDist));
return Standard_True;
}
//=======================================================================
//function : Extrema_GExtCC
//purpose :
@@ -54,6 +143,7 @@ Extrema_GExtCC::Extrema_GExtCC (const Standard_Real TolC1,
{
myC[0] = 0; myC[1] = 0;
myTol[0] = TolC1; myTol[1] = TolC2;
myFilter.Reset(myTol);
}
//=======================================================================
@@ -75,6 +165,7 @@ Extrema_GExtCC::Extrema_GExtCC(const Curve1& C1,
SetCurve (2, C2, V1, V2);
SetTolerance (1, TolC1);
SetTolerance (2, TolC2);
myFilter.Reset(myTol);
Perform();
}
@@ -94,6 +185,7 @@ Extrema_GExtCC::Extrema_GExtCC(const Curve1& C1,
SetCurve (2, C2, C2.FirstParameter(), C2.LastParameter());
SetTolerance (1, TolC1);
SetTolerance (2, TolC2);
myFilter.Reset(myTol);
Perform();
}
@@ -175,6 +267,13 @@ void Extrema_GExtCC::Perform()
U21 = myInf[1];
U22 = mySup[1];
{
const Standard_Real aF = 1.0e6;// static_cast<Standard_Real>(INT_MAX - 1);
//Standard_Real aCS[2] = { Max((U12 - U11) / aF, 1.0e-5), Max((U22 - U21) / aF, 1.0e-5) };
Standard_Real aCS[2] = { (U12 - U11) / aF, (U22 - U21) / aF };
myFilter.Reset(aCS);
}
if (!Precision::IsInfinite(U11)) P1f = Tool1::Value(*((Curve1*)myC[0]), U11);
if (!Precision::IsInfinite(U12)) P1l = Tool1::Value(*((Curve1*)myC[0]), U12);
if (!Precision::IsInfinite(U21)) P2f = Tool2::Value(*((Curve2*)myC[1]), U21);
@@ -395,18 +494,37 @@ void Extrema_GExtCC::Perform()
}
}
//2. process each cache from one list with each cache from the other
TColStd_ListIteratorOfListOfTransient anIt1 (myCacheLists[0]);
for (; anIt1.More(); anIt1.Next()) {
Handle(Extrema_CCache) aCache1 = Handle(Extrema_CCache)::DownCast (anIt1.Value());
myECC.SetCurveCache (1, aCache1);
TColStd_ListIteratorOfListOfTransient anIt2 (myCacheLists[1]);
for (; anIt2.More(); anIt2.Next()) {
Handle(Extrema_CCache) aCache2 = Handle(Extrema_CCache)::DownCast (anIt2.Value());
myECC.SetCurveCache (2, aCache2);
myECC.Perform();
Results(myECC, U11, U12, U21, U22);
}
Bnd_Box aBox;
const Standard_Integer aFInd = (myCacheLists[0].Extent() > myCacheLists[1].Extent()) ? 1 : 0;
const Standard_Integer aSInd = (myCacheLists[0].Extent() > myCacheLists[1].Extent()) ? 0 : 1;
Handle(NCollection_IncAllocator) anAlloc = new NCollection_IncAllocator(5000);
UBTree aDeflTree (anAlloc);
UBTreeFiller aDeflTreeFiller(aDeflTree);
TColStd_ListIteratorOfListOfTransient anIt2 (myCacheLists[aSInd]);
for (; anIt2.More(); anIt2.Next())
{
aBox.SetVoid();
const Handle(Extrema_CCache)& aCache2 = Handle(Extrema_CCache)::DownCast (anIt2.Value());
BndLib_Add3dCurve::Add(*(Curve1*)myC[aSInd], aCache2->FirstParameter(), aCache2->LastParameter(), Precision::Confusion(), aBox);
aDeflTreeFiller.Add(aCache2, aBox);
}
//Shake TreeFiller
aDeflTreeFiller.Fill();
aDeflTreeFiller.Reset();
TColStd_ListIteratorOfListOfTransient anIt1 (myCacheLists[aFInd]);
for (; anIt1.More(); anIt1.Next())
{
const Handle(Extrema_CCache)& aCache1 = Handle(Extrema_CCache)::DownCast (anIt1.Value());
ComputeIntervExtrema aSel(aCache1, myECC, this, aFInd == 0, U11, U12, U21, U22);
// No reset
//myFilter.Reset(myTol);
aDeflTree.Select(aSel);
}
}
}
@@ -832,50 +950,85 @@ void Extrema_GExtCC::Results(const Extrema_ECC& AlgExt,
const Standard_Real Ut21,
const Standard_Real Ut22)
{
Standard_Integer i, j,NbExt;
Standard_Real Val, U, U2,Uj,U2j;
Extrema_POnCurv P1, P2,P1j,P2j;
Standard_Boolean IsExtrema;
Standard_Integer NbExt;
Standard_Real Val, U, U2;
Extrema_POnCurv P1, P2, P1j, P2j;
myDone = AlgExt.IsDone();
if (myDone) {
NbExt = AlgExt.NbExt();
for (i = 1; i <= NbExt; i++) {
Extrema_CCPointsInspector anInspector(myTol);
const Standard_Boolean isToUseCFilter = (NbExt >= 15);
for (Standard_Integer i = 1; i <= NbExt; i++)
{
AlgExt.Points(i, P1, P2);
U = P1.Parameter();
U2 = P2.Parameter();
IsExtrema=Standard_True;
for (j=1;j<=mynbext;j++)
{ P1j=mypoints.Value(2*j-1);
P2j=mypoints.Value(2*j);
Uj=P1j.Parameter();
U2j=P2j.Parameter();
if ((Abs(Uj-U)<=myTol[0]) && (Abs(U2j-U2)<=myTol[1]))
IsExtrema=Standard_False;}
if (IsExtrema)
{
// Verification de la validite des parametres
if (Tool1::IsPeriodic(*((Curve1*)myC[0]))) {
U = ElCLib::InPeriod(U, Ut11, Ut11+Tool1::Period(*((Curve1*)myC[0])));
}
if (Tool2::IsPeriodic(*((Curve2*)myC[1]))) {
U2 = ElCLib::InPeriod(U2, Ut21, Ut21+Tool2::Period(*((Curve2*)myC[1])));
}
if ((U >= Ut11 - RealEpsilon()) &&
(U <= Ut12 + RealEpsilon()) &&
(U2 >= Ut21 - RealEpsilon()) &&
(U2 <= Ut22 + RealEpsilon()))
Standard_Boolean IsExtrema = Standard_True;
if (!isToUseCFilter)
{
for (Standard_Integer j = 1; j <= mynbext; j++)
{
P1j = mypoints.Value(2 * j - 1);
P2j = mypoints.Value(2 * j);
Standard_Real Uj = P1j.Parameter();
Standard_Real U2j = P2j.Parameter();
if ((Abs(Uj - U) <= myTol[0]) && (Abs(U2j - U2) <= myTol[1]))
{
IsExtrema = Standard_False;
break;
}
}
}
else
{
gp_XY aPnt2d(U, U2);
gp_XY aXYmin(U - myTol[0], U2 - myTol[1]);
gp_XY aXYmax(U + myTol[0], U2 + myTol[1]);
anInspector.ClearFind();
anInspector.SetCurrent(aPnt2d);
myFilter.Inspect(aXYmin, aXYmax, anInspector);
if (!anInspector.isFind())
{
IsExtrema = Standard_True;
myFilter.Add(aPnt2d, aPnt2d);
}
else
{
IsExtrema = Standard_False;
}
}
if (!IsExtrema)
{
continue;
}
// Verification de la validite des parametres
if (Tool1::IsPeriodic(*((Curve1*)myC[0]))) {
U = ElCLib::InPeriod(U, Ut11, Ut11+Tool1::Period(*((Curve1*)myC[0])));
}
if (Tool2::IsPeriodic(*((Curve2*)myC[1]))) {
U2 = ElCLib::InPeriod(U2, Ut21, Ut21+Tool2::Period(*((Curve2*)myC[1])));
}
if( (U >= Ut11 - RealEpsilon()) &&
(U <= Ut12 + RealEpsilon()) &&
(U2 >= Ut21 - RealEpsilon()) &&
(U2 <= Ut22 + RealEpsilon()))
{ mynbext++;
Val = AlgExt.SquareDistance(i);
mySqDist.Append(Val);
P1.SetValues(U, P1.Value());
P2.SetValues(U2, P2.Value());
mypoints.Append(P1);
mypoints.Append(P2);
}
Val = AlgExt.SquareDistance(i);
mySqDist.Append(Val);
P1.SetValues(U, P1.Value());
P2.SetValues(U2, P2.Value());
mypoints.Append(P1);
mypoints.Append(P2);
}
}
}
}
}

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

@@ -40,6 +40,13 @@ is
---C++: inline
is static;
SetParameters(me: in out;
theU, theV: Real from Standard;
thePnt: Pnt from gp);
---Purpose: Sets the params of current POnSurf instance.
-- (e.g. to the point to be projected).
---C++: inline
fields
myU: Real;
myV: Real;

Some files were not shown because too many files have changed in this diff Show More