autotools

This commit is contained in:
Joachim Schoeberl 2009-01-12 23:40:13 +00:00
commit 310cb00b13
335 changed files with 208368 additions and 0 deletions

1
AUTHORS Normal file
View File

@ -0,0 +1 @@
Joachim Schoeberl <joachim.schoeberl@rwth-aachen.de>

340
COPYING Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, 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 or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
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 give any other recipients of the Program a copy of this License
along with the Program.
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 Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
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 Program, 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 Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) 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; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, 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 executable. However, as a
special exception, the source code 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.
If distribution of executable or 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 counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program 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.
5. 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 Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program 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 to
this License.
7. 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 Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program 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 Program.
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.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program 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.
9. The Free Software Foundation may publish revised and/or new versions
of the 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 Program
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 Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, 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
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), 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 Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. 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 program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

0
ChangeLog Normal file
View File

167
INSTALL Normal file
View File

@ -0,0 +1,167 @@
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes a while. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Type `make install' to install the programs and any data files and
documentation.
4. You can remove the program binaries and object files from the
source code directory by typing `make clean'.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made.
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.

2
Makefile.am Normal file
View File

@ -0,0 +1,2 @@
SUBDIRS = libsrc ng

8
Makefile.cvs Normal file
View File

@ -0,0 +1,8 @@
default: all
all:
aclocal
autoheader
automake
autoconf

640
Makefile.in Normal file
View File

@ -0,0 +1,640 @@
# Makefile.in generated by automake 1.10.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(top_srcdir)/configure AUTHORS COPYING COPYING.LIB ChangeLog \
INSTALL NEWS TODO config.guess config.sub depcomp install-sh \
ltmain.sh missing mkinstalldirs
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
install-html-recursive install-info-recursive \
install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = libsrc ng
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
.SUFFIXES:
am--refresh:
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \
cd $(srcdir) && $(AUTOMAKE) --gnu \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
cd $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
else :; fi
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
$(srcdir)/config.h.in: $(am__configure_deps)
cd $(top_srcdir) && $(AUTOHEADER)
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
$(RECURSIVE_CLEAN_TARGETS):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
$(am__remove_distdir)
test -d $(distdir) || mkdir $(distdir)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
distdir=`$(am__cd) $(distdir) && pwd`; \
top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$top_distdir" \
distdir="$$distdir/$$subdir" \
am__remove_distdir=: \
am__skip_length_check=: \
distdir) \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
dist-lzma: distdir
tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
$(am__remove_distdir)
dist-tarZ: distdir
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
dist-shar: distdir
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir)
dist dist-all: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lzma*) \
unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& cd $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
$(am__remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
distuninstallcheck:
@cd $(distuninstallcheck_dir) \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile config.h
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-hdr \
distclean-libtool distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am:
install-dvi: install-dvi-recursive
install-exec-am:
install-html: install-html-recursive
install-info: install-info-recursive
install-man:
install-pdf: install-pdf-recursive
install-ps: install-ps-recursive
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am:
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
install-strip
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am am--refresh check check-am clean clean-generic \
clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
dist-gzip dist-lzma dist-shar dist-tarZ dist-zip distcheck \
distclean distclean-generic distclean-hdr distclean-libtool \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs installdirs-am \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-recursive uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

0
NEWS Normal file
View File

0
README Normal file
View File

0
TODO Normal file
View File

1363
config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

59
config.h.in Normal file
View File

@ -0,0 +1,59 @@
/* config.h.in. Generated from configure.in by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION

1470
config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

17764
configure vendored Executable file

File diff suppressed because it is too large Load Diff

13
configure.in Normal file
View File

@ -0,0 +1,13 @@
AC_INIT(configure.in)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(netgen, 5.0)
AC_LANG_CPLUSPLUS
AC_PROG_CXX
AM_PROG_LIBTOOL
AC_OUTPUT(Makefile libsrc/Makefile libsrc/csg/Makefile libsrc/general/Makefile \
libsrc/geom2d/Makefile libsrc/gprim/Makefile libsrc/include/Makefile libsrc/interface/Makefile \
libsrc/linalg/Makefile libsrc/meshing/Makefile libsrc/occ/Makefile libsrc/opti/Makefile \
libsrc/parallel/Makefile libsrc/stlgeom/Makefile libsrc/visualization/Makefile ng/Makefile)

441
depcomp Executable file
View File

@ -0,0 +1,441 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
# Copyright 1999, 2000 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program 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 General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# `libtool' can also be set to `yes' or `no'.
depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. This file always lives in the current directory.
# Also, the AIX compiler puts `$object:' at the start of each line;
# $object doesn't have directory information.
stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
tmpdepfile="$stripped.u"
outname="$stripped.o"
if test "$libtool" = yes; then
"$@" -Wc,-M
else
"$@" -M
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
if test -f "$tmpdepfile"; then
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
icc)
# Must come before tru64.
# Intel's C compiler understands `-MD -MF file'. However
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
sed -e "s,^[^:]*: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
tru64)
# The Tru64 AIX compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
tmpdepfile1="$object.d"
tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'`
if test "$libtool" = yes; then
"$@" -Wc,-MD
else
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
if test -f "$tmpdepfile1"; then
tmpdepfile="$tmpdepfile1"
else
tmpdepfile="$tmpdepfile2"
fi
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a space and a tab in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the proprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
test -z "$dashmflag" && dashmflag=-M
( IFS=" "
case " $* " in
*" --mode=compile "*) # this is libtool, let us make it quiet
for arg
do # cycle over the arguments
case "$arg" in
"--mode=compile")
# insert --quiet before "--mode=compile"
set fnord "$@" --quiet
shift # fnord
;;
esac
set fnord "$@" "$arg"
shift # fnord
shift # "$arg"
done
;;
esac
"$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
# X makedepend
(
shift
cleared=no
for arg in "$@"; do
case $cleared in no)
set ""; shift
cleared=yes
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift;;
-*)
;;
*)
set fnord "$@" "$arg"; shift;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tail +3 "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the proprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
( IFS=" "
case " $* " in
*" --mode=compile "*)
for arg
do # cycle over the arguments
case $arg in
"--mode=compile")
# insert --quiet before "--mode=compile"
set fnord "$@" --quiet
shift # fnord
;;
esac
set fnord "$@" "$arg"
shift # fnord
shift # "$arg"
done
;;
esac
"$@" -E |
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the proprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
( IFS=" "
case " $* " in
*" --mode=compile "*)
for arg
do # cycle over the arguments
case $arg in
"--mode=compile")
# insert --quiet before "--mode=compile"
set fnord "$@" --quiet
shift # fnord
;;
esac
set fnord "$@" "$arg"
shift # fnord
shift # "$arg"
done
;;
esac
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0

276
install-sh Executable file
View File

@ -0,0 +1,276 @@
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd=$cpprog
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd=$stripprog
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "$0: no input file specified" >&2
exit 1
else
:
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d "$dst" ]; then
instcmd=:
chmodcmd=""
else
instcmd=$mkdirprog
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f "$src" ] || [ -d "$src" ]
then
:
else
echo "$0: $src does not exist" >&2
exit 1
fi
if [ x"$dst" = x ]
then
echo "$0: no destination specified" >&2
exit 1
else
:
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d "$dst" ]
then
dst=$dst/`basename "$src"`
else
:
fi
fi
## this sed command emulates the dirname command
dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-$defaultIFS}"
oIFS=$IFS
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS=$oIFS
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp=$pathcomp$1
shift
if [ ! -d "$pathcomp" ] ;
then
$mkdirprog "$pathcomp"
else
:
fi
pathcomp=$pathcomp/
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd "$dst" &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename "$dst"`
else
dstfile=`basename "$dst" $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename "$dst"`
else
:
fi
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/#inst.$$#
rmtmp=$dstdir/#rm.$$#
# Trap to clean up temp files at exit.
trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
# Move or copy the file name to the temp name
$doit $instcmd "$src" "$dsttmp" &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
# Now remove or move aside any old file at destination location. We try this
# two ways since rm can't unlink itself on some systems and the destination
# file might be busy for other reasons. In this case, the final cleanup
# might fail but the new file should still install successfully.
{
if [ -f "$dstdir/$dstfile" ]
then
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
$doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
{
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
(exit 1); exit
}
else
:
fi
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
fi &&
# The final little trick to "correctly" pass the exit status to the exit trap.
{
(exit 0); exit
}

4
libsrc/Makefile.am Normal file
View File

@ -0,0 +1,4 @@
INCLUDES =
METASOURCES = AUTO
SUBDIRS = csg general geom2d gprim include interface linalg meshing occ opti \
parallel stlgeom visualization

492
libsrc/Makefile.in Normal file
View File

@ -0,0 +1,492 @@
# Makefile.in generated by automake 1.10.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = libsrc
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
install-html-recursive install-info-recursive \
install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
INCLUDES =
METASOURCES = AUTO
SUBDIRS = csg general geom2d gprim include interface linalg meshing occ opti \
parallel stlgeom visualization
all: all-recursive
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libsrc/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu libsrc/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
$(RECURSIVE_CLEAN_TARGETS):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
distdir=`$(am__cd) $(distdir) && pwd`; \
top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$top_distdir" \
distdir="$$distdir/$$subdir" \
am__remove_distdir=: \
am__skip_length_check=: \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am:
install-dvi: install-dvi-recursive
install-exec-am:
install-html: install-html-recursive
install-info: install-info-recursive
install-man:
install-pdf: install-pdf-recursive
install-ps: install-ps-recursive
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am:
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
install-strip
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am check check-am clean clean-generic clean-libtool \
ctags ctags-recursive distclean distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

7
libsrc/csg/Makefile.am Normal file
View File

@ -0,0 +1,7 @@
INCLUDES = -I$(top_srcdir)/libsrc/include
METASOURCES = AUTO
noinst_LIBRARIES = libcsg.a
libcsg_a_SOURCES = algprim.cpp brick.cpp bspline2d.cpp csgeom.cpp csgparser.cpp \
curve2d.cpp edgeflw.cpp explicitcurve2d.cpp extrusion.cpp gencyl.cpp genmesh.cpp \
identify.cpp manifold.cpp meshsurf.cpp polyhedra.cpp revolution.cpp singularref.cpp \
solid.cpp specpoin.cpp spline3d.cpp surface.cpp triapprox.cpp

471
libsrc/csg/Makefile.in Normal file
View File

@ -0,0 +1,471 @@
# Makefile.in generated by automake 1.10.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = libsrc/csg
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
LIBRARIES = $(noinst_LIBRARIES)
ARFLAGS = cru
libcsg_a_AR = $(AR) $(ARFLAGS)
libcsg_a_LIBADD =
am_libcsg_a_OBJECTS = algprim.$(OBJEXT) brick.$(OBJEXT) \
bspline2d.$(OBJEXT) csgeom.$(OBJEXT) csgparser.$(OBJEXT) \
curve2d.$(OBJEXT) edgeflw.$(OBJEXT) explicitcurve2d.$(OBJEXT) \
extrusion.$(OBJEXT) gencyl.$(OBJEXT) genmesh.$(OBJEXT) \
identify.$(OBJEXT) manifold.$(OBJEXT) meshsurf.$(OBJEXT) \
polyhedra.$(OBJEXT) revolution.$(OBJEXT) singularref.$(OBJEXT) \
solid.$(OBJEXT) specpoin.$(OBJEXT) spline3d.$(OBJEXT) \
surface.$(OBJEXT) triapprox.$(OBJEXT)
libcsg_a_OBJECTS = $(am_libcsg_a_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(libcsg_a_SOURCES)
DIST_SOURCES = $(libcsg_a_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
INCLUDES = -I$(top_srcdir)/libsrc/include
METASOURCES = AUTO
noinst_LIBRARIES = libcsg.a
libcsg_a_SOURCES = algprim.cpp brick.cpp bspline2d.cpp csgeom.cpp csgparser.cpp \
curve2d.cpp edgeflw.cpp explicitcurve2d.cpp extrusion.cpp gencyl.cpp genmesh.cpp \
identify.cpp manifold.cpp meshsurf.cpp polyhedra.cpp revolution.cpp singularref.cpp \
solid.cpp specpoin.cpp spline3d.cpp surface.cpp triapprox.cpp
all: all-am
.SUFFIXES:
.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libsrc/csg/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu libsrc/csg/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
libcsg.a: $(libcsg_a_OBJECTS) $(libcsg_a_DEPENDENCIES)
-rm -f libcsg.a
$(libcsg_a_AR) libcsg.a $(libcsg_a_OBJECTS) $(libcsg_a_LIBADD)
$(RANLIB) libcsg.a
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/algprim.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/brick.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bspline2d.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/csgeom.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/csgparser.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/curve2d.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edgeflw.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/explicitcurve2d.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extrusion.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gencyl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genmesh.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/identify.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/manifold.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/meshsurf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polyhedra.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/revolution.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/singularref.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/solid.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/specpoin.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spline3d.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/surface.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/triapprox.Po@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cpp.lo:
@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LIBRARIES)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-exec-am:
install-html: install-html-am
install-info: install-info-am
install-man:
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstLIBRARIES ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

1685
libsrc/csg/algprim.cpp Normal file

File diff suppressed because it is too large Load Diff

439
libsrc/csg/algprim.hpp Normal file
View File

@ -0,0 +1,439 @@
#ifndef FILE_ALGPRIM
#define FILE_ALGPRIM
/**************************************************************************/
/* File: algprim.hh */
/* Author: Joachim Schoeberl */
/* Date: 1. Dez. 95 */
/**************************************************************************/
/*
Quadric Surfaces (Plane, Sphere, Cylinder)
*/
/**
A quadric surface.
surface defined by
cxx x^2 + cyy y^2 + czz z^2 + cxy x y + cxz x z + cyz y z +
cx x + cy y + cz z + c1 = 0.
**/
class QuadraticSurface : public OneSurfacePrimitive
{
protected:
double cxx, cyy, czz, cxy, cxz, cyz, cx, cy, cz, c1;
public:
virtual double CalcFunctionValue (const Point<3> & point) const;
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const;
/*
virtual int RootInBox (const Box<3> & box)
const { return 0; }
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box)
const { return DOES_INTERSECT; }
*/
virtual double HesseNorm () const { return cxx + cyy + czz; }
virtual Point<3> GetSurfacePoint () const;
virtual void Print (ostream & ist) const;
virtual void Read (istream & ist);
void PrintCoeff (ostream & ost) const;
};
/// A Plane (i.e., the plane and everything behind it).
class Plane : public QuadraticSurface
{
/// a point in the plane
Point<3> p;
/// outward normal vector
Vec<3> n;
double eps_base;
public:
///
Plane (const Point<3> & ap, Vec<3> an);
virtual void GetPrimitiveData (const char *& classname,
ARRAY<double> & coeffs) const;
virtual void SetPrimitiveData (ARRAY<double> & coeffs);
static Primitive * CreateDefault ();
virtual Primitive * Copy () const;
virtual void Transform (Transformation<3> & trans);
virtual int IsIdentic (const Surface & s2, int & inv, double eps) const;
///
virtual void DefineTangentialPlane (const Point<3> & ap1,
const Point<3> & ap2);
///
virtual void ToPlane (const Point<3> & p3d,
Point<2> & pplane, double h,
int & zone) const;
///
virtual void FromPlane (const Point<2> & pplane,
Point<3> & p3d,
double h) const;
///
virtual void Project (Point<3> & p) const;
///
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
///
inline virtual double CalcFunctionValue (const Point<3> & p3d) const
{return cx * p3d(0) + cy * p3d(1) + cz * p3d(2) + c1;}
///
virtual void CalcGradient (const Point<3> & point,
Vec<3> & grad) const;
///
virtual void CalcHesse (const Point<3> & point,
Mat<3> & hesse) const;
///
virtual double HesseNorm () const;
///
virtual Point<3> GetSurfacePoint () const;
///
virtual void GetTriangleApproximation
(TriangleApproximation & tas,
const Box<3> & boundingbox, double facets) const;
};
// typedef Plane Plane;
///
class Sphere : public QuadraticSurface
{
///
Point<3> c;
///
double r;
public:
///
Sphere (const Point<3> & ac, double ar);
virtual void GetPrimitiveData (const char *& classname,
ARRAY<double> & coeffs) const;
virtual void SetPrimitiveData (ARRAY<double> & coeffs);
static Primitive * CreateDefault ();
virtual Primitive * Copy () const;
virtual void Transform (Transformation<3> & trans);
virtual int IsIdentic (const Surface & s2, int & inv, double eps) const;
///
virtual void DefineTangentialPlane (const Point<3> & ap1,
const Point<3> & ap2);
///
virtual void ToPlane (const Point<3> & p3d,
Point<2> & pplane, double h,
int & zone) const;
///
virtual void FromPlane (const Point<2> & pplane,
Point<3> & p, double h) const;
///
virtual void Project (Point<3> & p) const;
///
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
///
virtual double HesseNorm () const;
///
virtual Point<3> GetSurfacePoint () const;
///
const Point<3> & Center () const { return c; }
///
double Radius () const { return r; }
///
virtual void GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & bbox,
double facets) const;
};
///
class Cylinder : public QuadraticSurface
{
///
Point<3> a, b;
///
double r;
///
Vec<3> vab;
public:
Cylinder (const Point<3> & aa, const Point<3> & ab, double ar);
Cylinder (ARRAY<double> & coeffs);
virtual void GetPrimitiveData (const char *& classname, ARRAY<double> & coeffs) const;
virtual void SetPrimitiveData (ARRAY<double> & coeffs);
static Primitive * CreateDefault ();
virtual Primitive * Copy () const;
virtual void Transform (Transformation<3> & trans);
///
virtual int IsIdentic (const Surface & s2, int & inv, double eps) const;
///
virtual void DefineTangentialPlane (const Point<3> & ap1,
const Point<3> & ap2);
///
virtual void ToPlane (const Point<3> & p,
Point<2> & pplane,
double h,
int & zone) const;
///
virtual void FromPlane (const Point<2> & pplane,
Point<3> & p,
double h) const;
///
virtual void Project (Point<3> & p) const;
///
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
///
virtual double HesseNorm () const;
///
virtual Point<3> GetSurfacePoint () const;
///
virtual void GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & bbox,
double facets) const;
};
///
class EllipticCylinder : public QuadraticSurface
{
private:
///
Point<3> a;
///
Vec<3> vl, vs;
///
Vec<3> vab, t0vec, t1vec;
///
double vabl, t0, t1;
public:
///
EllipticCylinder (const Point<3> & aa,
const Vec<3> & avl, const Vec<3> & avs);
/*
static Primitive * CreateDefault ();
virtual void GetPrimitiveData (const char *& classname, ARRAY<double> & coeffs) const;
virtual void SetPrimitiveData (ARRAY<double> & coeffs);
*/
///
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
///
virtual double HesseNorm () const;
///
virtual Point<3> GetSurfacePoint () const;
virtual void GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & bbox,
double facets) const;
virtual double MaxCurvature () const;
virtual double MaxCurvatureLoc (const Point<3> & /* c */ ,
double /* rad */) const;
private:
void CalcData();
};
///
class Ellipsoid : public QuadraticSurface
{
private:
///
Point<3> a;
///
Vec<3> v1, v2, v3;
///
double rmin;
public:
///
Ellipsoid (const Point<3> & aa,
const Vec<3> & av1,
const Vec<3> & av2,
const Vec<3> & av3);
///
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
///
virtual double HesseNorm () const;
///
virtual double MaxCurvature () const;
///
virtual Point<3> GetSurfacePoint () const;
virtual void GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & bbox,
double facets) const;
private:
void CalcData();
};
///
class Cone : public QuadraticSurface
{
///
Point<3> a, b;
///
double ra, rb, minr;
///
Vec<3> vab, t0vec, t1vec;
///
double vabl, t0, t1;
public:
///
Cone (const Point<3> & aa, const Point<3> & ab, double ara, double arb);
///
static Primitive * CreateDefault ();
virtual void GetPrimitiveData (const char *& classname, ARRAY<double> & coeffs) const;
virtual void SetPrimitiveData (ARRAY<double> & coeffs);
///
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
///
virtual double HesseNorm () const;
virtual double LocH (const Point<3> & p, double x,
double c, double hmax) const;
///
virtual Point<3> GetSurfacePoint () const;
virtual void GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & bbox,
double facets) const;
private:
void CalcData();
};
/// Torus
/// Lorenzo Codecasa (codecasa@elet.polimi.it)
/// April 27th, 2005
///
/// begin...
class Torus : public OneSurfacePrimitive
{
/// center of the torus
Point<3> c;
/// vector normal to the symmetry plane of the torus
Vec<3> n;
/// Large radius of the torus
double R;
/// Small radius of the torus
double r;
public:
/// OK
Torus (const Point<3> & ac, const Vec<3> & an, double aR, double ar);
/// OK
const Point<3> & Center () const { return c; }
/// OK
const Vec<3> & NormalToPlane () const { return n; }
/// OK
double LargeRadius () const { return R; }
/// OK
double SmallRadius () const { return r; }
/// OK
virtual double CalcFunctionValue (const Point<3> & point) const;
/// OK
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
/// OK
virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const;
/// OK
virtual double HesseNorm () const;
/// OK
virtual Point<3> GetSurfacePoint () const;
/// OK
virtual void GetPrimitiveData (const char *& classname,
ARRAY<double> & coeffs) const;
/// OK
virtual void SetPrimitiveData (ARRAY<double> & coeffs);
/// OK
static Primitive * CreateDefault ();
/// OK
virtual Primitive * Copy () const;
/// OK
virtual void Transform (Transformation<3> & trans);
/// OK
virtual int IsIdentic (const Surface & s2, int & inv, double eps) const;
/// OK
/// virtual void DefineTangentialPlane (const Point<3> & ap1,
// const Point<3> & ap2);
/// OK
/// virtual void ToPlane (const Point<3> & p3d,
/// Point<2> & pplane,
/// double h, int & zone) const;
/// OK
/// virtual void FromPlane (const Point<2> & pplane,
// Point<3> & p, double h) const;
/// OK
/// virtual void Project (Point<3> & p) const;
/// OK
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
/// OK
virtual void GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & bbox,
double facets) const;
/// OK
virtual void Print (ostream & ist) const;
/// OK
virtual void Read (istream & ist);
};
/// ...end
#endif

526
libsrc/csg/brick.cpp Normal file
View File

@ -0,0 +1,526 @@
#include <mystdlib.h>
#include <linalg.hpp>
#include <csg.hpp>
namespace netgen
{
Parallelogram3d :: Parallelogram3d (Point<3> ap1, Point<3> ap2, Point<3> ap3)
{
p1 = ap1;
p2 = ap2;
p3 = ap3;
CalcData();
}
Parallelogram3d ::~Parallelogram3d ()
{
;
}
void Parallelogram3d :: SetPoints (Point<3> ap1,
Point<3> ap2,
Point<3> ap3)
{
p1 = ap1;
p2 = ap2;
p3 = ap3;
CalcData();
}
void Parallelogram3d :: CalcData()
{
v12 = p2 - p1;
v13 = p3 - p1;
p4 = p2 + v13;
n = Cross (v12, v13);
n.Normalize();
}
int Parallelogram3d ::
IsIdentic (const Surface & s2, int & inv, double eps) const
{
int id =
(fabs (s2.CalcFunctionValue (p1)) <= eps) &&
(fabs (s2.CalcFunctionValue (p2)) <= eps) &&
(fabs (s2.CalcFunctionValue (p3)) <= eps);
if (id)
{
Vec<3> n2;
n2 = s2.GetNormalVector(p1);
inv = (n * n2) < 0;
}
return id;
}
double Parallelogram3d :: CalcFunctionValue (const Point<3> & point) const
{
return n * (point - p1);
}
void Parallelogram3d :: CalcGradient (const Point<3> & /* point */,
Vec<3> & grad) const
{
grad = n;
}
void Parallelogram3d :: CalcHesse (const Point<3> & /* point */, Mat<3> & hesse) const
{
hesse = 0;
}
double Parallelogram3d :: HesseNorm () const
{
return 0;
}
Point<3> Parallelogram3d :: GetSurfacePoint () const
{
return p1;
}
void Parallelogram3d :: Print (ostream & str) const
{
str << "Parallelogram3d " << p1 << " - " << p2 << " - " << p3 << endl;
}
void Parallelogram3d ::
GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & /* bbox */,
double /* facets */) const
{
tas.AddPoint (p1);
tas.AddPoint (p2);
tas.AddPoint (p3);
tas.AddPoint (p4);
tas.AddTriangle (TATriangle (0, 0, 1, 2));
tas.AddTriangle (TATriangle (0, 2, 1, 3));
}
Brick :: Brick (Point<3> ap1, Point<3> ap2,
Point<3> ap3, Point<3> ap4)
{
faces.SetSize (6);
surfaceids.SetSize (6);
surfaceactive.SetSize(6);
p1 = ap1; p2 = ap2;
p3 = ap3; p4 = ap4;
for (int i = 0; i < 6; i++)
{
faces[i] = new Plane (Point<3>(0,0,0), Vec<3> (0,0,1));
surfaceactive[i] = 1;
}
CalcData();
}
Brick :: ~Brick ()
{
for (int i = 0; i < 6; i++)
delete faces[i];
}
Primitive * Brick :: CreateDefault ()
{
return new Brick (Point<3> (0,0,0),
Point<3> (1,0,0),
Point<3> (0,1,0),
Point<3> (0,0,1));
}
Primitive * Brick :: Copy () const
{
return new Brick (p1, p2, p3, p4);
}
void Brick :: Transform (Transformation<3> & trans)
{
trans.Transform (p1);
trans.Transform (p2);
trans.Transform (p3);
trans.Transform (p4);
CalcData();
}
INSOLID_TYPE Brick :: BoxInSolid (const BoxSphere<3> & box) const
{
/*
int i;
double maxval;
for (i = 1; i <= 6; i++)
{
double val = faces.Get(i)->CalcFunctionValue (box.Center());
if (i == 1 || val > maxval)
maxval = val;
}
if (maxval > box.Diam()) return IS_OUTSIDE;
if (maxval < -box.Diam()) return IS_INSIDE;
return DOES_INTERSECT;
*/
bool inside = 1;
bool outside = 0;
Point<3> p[8];
for (int j = 0; j < 8; j++)
p[j] = box.GetPointNr(j);
for (int i = 0; i < 6; i++)
{
bool outsidei = 1;
for (int j = 0; j < 8; j++)
{
// Point<3> p = box.GetPointNr (j);
double val = faces[i]->Plane::CalcFunctionValue (p[j]);
if (val > 0) inside = 0;
if (val < 0) outsidei = 0;
}
if (outsidei) outside = 1;
}
if (outside) return IS_OUTSIDE;
if (inside) return IS_INSIDE;
return DOES_INTERSECT;
}
INSOLID_TYPE Brick :: PointInSolid (const Point<3> & p,
double eps) const
{
double maxval = faces[0] -> Plane::CalcFunctionValue (p);
for (int i = 1; i < 6; i++)
{
double val = faces[i] -> Plane::CalcFunctionValue (p);
if (val > maxval) maxval = val;
}
if (maxval > eps) return IS_OUTSIDE;
if (maxval < -eps) return IS_INSIDE;
return DOES_INTERSECT;
}
INSOLID_TYPE Brick :: VecInSolid (const Point<3> & p,
const Vec<3> & v,
double eps) const
{
INSOLID_TYPE result = IS_INSIDE;
for (int i = 0; i < faces.Size(); i++)
{
INSOLID_TYPE hres = faces[i]->VecInSolid(p, v, eps);
if (hres == IS_OUTSIDE || result == IS_OUTSIDE) result = IS_OUTSIDE;
else if (hres == DOES_INTERSECT || result == DOES_INTERSECT) result = DOES_INTERSECT;
else result = IS_INSIDE;
}
return result;
/*
INSOLID_TYPE is = IS_INSIDE;
Vec<3> grad;
double scal;
for (int i = 0; i < faces.Size(); i++)
{
if (faces[i] -> PointOnSurface (p, eps))
{
GetSurface(i).CalcGradient (p, grad);
scal = v * grad;
if (scal >= eps)
is = IS_OUTSIDE;
if (scal >= -eps && is == IS_INSIDE)
is = DOES_INTERSECT;
}
}
return is;
*/
/*
Point<3> p2 = p + 1e-2 * v;
return PointInSolid (p2, eps);
*/
}
INSOLID_TYPE Brick :: VecInSolid2 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const
{
INSOLID_TYPE result = IS_INSIDE;
for (int i = 0; i < faces.Size(); i++)
{
INSOLID_TYPE hres = faces[i]->VecInSolid2(p, v1, v2, eps);
if (hres == IS_OUTSIDE || result == IS_OUTSIDE) result = IS_OUTSIDE;
else if (hres == DOES_INTERSECT || result == DOES_INTERSECT) result = DOES_INTERSECT;
else result = IS_INSIDE;
}
return result;
}
INSOLID_TYPE Brick :: VecInSolid3 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const
{
INSOLID_TYPE result = IS_INSIDE;
for (int i = 0; i < faces.Size(); i++)
{
INSOLID_TYPE hres = faces[i]->VecInSolid3(p, v1, v2, eps);
if (hres == IS_OUTSIDE || result == IS_OUTSIDE) result = IS_OUTSIDE;
else if (hres == DOES_INTERSECT || result == DOES_INTERSECT) result = DOES_INTERSECT;
else result = IS_INSIDE;
}
return result;
}
INSOLID_TYPE Brick :: VecInSolid4 (const Point<3> & p,
const Vec<3> & v,
const Vec<3> & v2,
const Vec<3> & m,
double eps) const
{
INSOLID_TYPE result = IS_INSIDE;
for (int i = 0; i < faces.Size(); i++)
{
INSOLID_TYPE hres = faces[i]->VecInSolid4(p, v, v2, m, eps);
if (hres == IS_OUTSIDE || result == IS_OUTSIDE) result = IS_OUTSIDE;
else if (hres == DOES_INTERSECT || result == DOES_INTERSECT) result = DOES_INTERSECT;
else result = IS_INSIDE;
}
return result;
}
void Brick ::
GetPrimitiveData (const char *& classname, ARRAY<double> & coeffs) const
{
classname = "brick";
coeffs.SetSize(12);
coeffs.Elem(1) = p1(0);
coeffs.Elem(2) = p1(1);
coeffs.Elem(3) = p1(2);
coeffs.Elem(4) = p2(0);
coeffs.Elem(5) = p2(1);
coeffs.Elem(6) = p2(2);
coeffs.Elem(7) = p3(0);
coeffs.Elem(8) = p3(1);
coeffs.Elem(9) = p3(2);
coeffs.Elem(10) = p4(0);
coeffs.Elem(11) = p4(1);
coeffs.Elem(12) = p4(2);
}
void Brick :: SetPrimitiveData (ARRAY<double> & coeffs)
{
p1(0) = coeffs.Elem(1);
p1(1) = coeffs.Elem(2);
p1(2) = coeffs.Elem(3);
p2(0) = coeffs.Elem(4);
p2(1) = coeffs.Elem(5);
p2(2) = coeffs.Elem(6);
p3(0) = coeffs.Elem(7);
p3(1) = coeffs.Elem(8);
p3(2) = coeffs.Elem(9);
p4(0) = coeffs.Elem(10);
p4(1) = coeffs.Elem(11);
p4(2) = coeffs.Elem(12);
CalcData();
}
void Brick :: CalcData()
{
v12 = p2 - p1;
v13 = p3 - p1;
v14 = p4 - p1;
Point<3> pi[8];
int i1, i2, i3;
int i, j;
i = 0;
for (i3 = 0; i3 <= 1; i3++)
for (i2 = 0; i2 <= 1; i2++)
for (i1 = 0; i1 <= 1; i1++)
{
pi[i] = p1 + i1 * v12 + i2 * v13 + i3 * v14;
i++;
}
static int lface[6][4] =
{ { 1, 3, 2, 4 },
{ 5, 6, 7, 8 },
{ 1, 2, 5, 6 },
{ 3, 7, 4, 8 },
{ 1, 5, 3, 7 },
{ 2, 4, 6, 8 } };
ARRAY<double> data(6);
for (i = 0; i < 6; i++)
{
const Point<3> lp1 = pi[lface[i][0]-1];
const Point<3> lp2 = pi[lface[i][1]-1];
const Point<3> lp3 = pi[lface[i][2]-1];
Vec<3> n = Cross ((lp2-lp1), (lp3-lp1));
n.Normalize();
for (j = 0; j < 3; j++)
{
data[j] = lp1(j);
data[j+3] = n(j);
}
faces[i] -> SetPrimitiveData (data);
/*
{
faces.Elem(i+1) -> SetPoints
(pi[lface[i][0]-1],
pi[lface[i][1]-1],
pi[lface[i][2]-1]);
}
*/
}
}
void Brick :: Reduce (const BoxSphere<3> & box)
{
double val;
// Point<3> p;
Point<3> p[8];
for(int j=0;j<8;j++)
p[j]=box.GetPointNr(j);
for (int i = 0; i < 6; i++)
{
bool hasout = 0;
bool hasin = 0;
for (int j = 0; j < 8; j++)
{
// p = box.GetPointNr (j);
val = faces[i]->Plane::CalcFunctionValue (p[j]);
if (val > 0) hasout = 1;
else if (val < 0) hasin = 1;
if (hasout && hasin) break;
}
surfaceactive[i] = hasout && hasin;
}
}
void Brick :: UnReduce ()
{
for (int i = 0; i < 6; i++)
surfaceactive[i] = 1;
}
OrthoBrick :: OrthoBrick (const Point<3> & ap1, const Point<3> & ap2)
: Brick (ap1,
Point<3> (ap2(0), ap1(1), ap1(2)),
Point<3> (ap1(0), ap2(1), ap1(2)),
Point<3> (ap1(0), ap1(1), ap2(2)))
{
pmin = ap1;
pmax = ap2;
}
INSOLID_TYPE OrthoBrick :: BoxInSolid (const BoxSphere<3> & box) const
{
if (pmin(0) > box.PMax()(0) ||
pmin(1) > box.PMax()(1) ||
pmin(2) > box.PMax()(2) ||
pmax(0) < box.PMin()(0) ||
pmax(1) < box.PMin()(1) ||
pmax(2) < box.PMin()(2))
return IS_OUTSIDE;
if (pmin(0) < box.PMin()(0) &&
pmin(1) < box.PMin()(1) &&
pmin(2) < box.PMin()(2) &&
pmax(0) > box.PMax()(0) &&
pmax(1) > box.PMax()(1) &&
pmax(2) > box.PMax()(2))
return IS_INSIDE;
return DOES_INTERSECT;
}
void OrthoBrick :: Reduce (const BoxSphere<3> & box)
{
surfaceactive.Elem(1) =
(box.PMin()(2) < pmin(2)) && (pmin(2) < box.PMax()(2));
surfaceactive.Elem(2) =
(box.PMin()(2) < pmax(2)) && (pmax(2) < box.PMax()(2));
surfaceactive.Elem(3) =
(box.PMin()(1) < pmin(1)) && (pmin(1) < box.PMax()(1));
surfaceactive.Elem(4) =
(box.PMin()(1) < pmax(1)) && (pmax(1) < box.PMax()(1));
surfaceactive.Elem(5) =
(box.PMin()(0) < pmin(0)) && (pmin(0) < box.PMax()(0));
surfaceactive.Elem(6) =
(box.PMin()(0) < pmax(0)) && (pmax(0) < box.PMax()(0));
}
}

120
libsrc/csg/brick.hpp Normal file
View File

@ -0,0 +1,120 @@
#ifndef FILE_BRICK
#define FILE_BRICK
/**************************************************************************/
/* File: brick.hpp */
/* Author: Joachim Schoeberl */
/* Date: 11. Mar. 98 */
/**************************************************************************/
/*
brick geometry, has several surfaces
*/
class Parallelogram3d : public Surface
{
Point<3> p1, p2, p3, p4;
Vec<3> v12, v13;
Vec<3> n;
public:
Parallelogram3d (Point<3> ap1, Point<3> ap2, Point<3> ap3);
virtual ~Parallelogram3d ();
void SetPoints (Point<3> ap1, Point<3> ap2, Point<3> ap3);
virtual int IsIdentic (const Surface & s2, int & inv, double eps) const;
virtual double CalcFunctionValue (const Point<3> & point) const;
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const;
virtual double HesseNorm () const;
virtual Point<3> GetSurfacePoint () const;
virtual void Print (ostream & str) const;
virtual void GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & boundingbox,
double facets) const;
protected:
void CalcData();
};
class Brick : public Primitive
{
Point<3> p1, p2, p3, p4;
Vec<3> v12, v13, v14;
// ARRAY<OneSurfacePrimitive*> faces;
ARRAY<Plane*> faces;
public:
Brick (Point<3> ap1, Point<3> ap2, Point<3> ap3, Point<3> ap4);
virtual ~Brick ();
static Primitive * CreateDefault ();
virtual Primitive * Copy () const;
virtual void Transform (Transformation<3> & trans);
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
virtual INSOLID_TYPE PointInSolid (const Point<3> & p,
double eps) const;
virtual INSOLID_TYPE VecInSolid (const Point<3> & p,
const Vec<3> & v,
double eps) const;
virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const;
virtual INSOLID_TYPE VecInSolid3 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const;
virtual INSOLID_TYPE VecInSolid4 (const Point<3> & p,
const Vec<3> & v,
const Vec<3> & v2,
const Vec<3> & m,
double eps) const;
virtual int GetNSurfaces() const
{ return 6; }
virtual Surface & GetSurface (int i)
{ return *faces[i]; }
virtual const Surface & GetSurface (int i) const
{ return *faces[i]; }
virtual void GetPrimitiveData (const char *& classname, ARRAY<double> & coeffs) const;
virtual void SetPrimitiveData (ARRAY<double> & coeffs);
virtual void Reduce (const BoxSphere<3> & box);
virtual void UnReduce ();
protected:
void CalcData();
};
class OrthoBrick : public Brick
{
protected:
Point<3> pmin, pmax;
public:
OrthoBrick (const Point<3> & ap1, const Point<3> & ap2);
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
virtual void Reduce (const BoxSphere<3> & box);
};
#endif

242
libsrc/csg/bspline2d.cpp Normal file
View File

@ -0,0 +1,242 @@
#include <mystdlib.h>
#include <csg.hpp>
namespace netgen
{
BSplineCurve2d :: BSplineCurve2d ()
{
redlevel = 0;
}
void BSplineCurve2d :: AddPoint (const Point<2> & apoint)
{
points.Append (apoint);
intervallused.Append (0);
}
bool BSplineCurve2d :: Inside (const Point<2> & p, double & dist) const
{
Point<2> hp = p;
double t = ProjectParam (p);
hp = Eval(t);
Vec<2> v = EvalPrime (t);
Vec<2> n (v(0), -v(1));
cout << "p = " << p << ", hp = " << hp << endl;
dist = Dist (p, hp);
double scal = (hp-p) * n;
cout << "scal = " << scal << endl;
return scal >= 0;
}
double BSplineCurve2d :: ProjectParam (const Point<2> & p) const
{
double t, dt, mindist, mint = 0.0;
int n1;
mindist = 1e10;
dt = 0.2;
for (n1 = 1; n1 <= points.Size(); n1++)
if (intervallused.Get(n1) == 0)
for (t = n1; t <= n1+1; t += dt)
if (Dist (Eval(t), p) < mindist)
{
mint = t;
mindist = Dist (Eval(t), p);
}
if (mindist > 1e9)
{
for (t = 0; t <= points.Size(); t += dt)
if (Dist (Eval(t), p) < mindist)
{
mint = t;
mindist = Dist (Eval(t), p);
}
}
while (Dist (Eval (mint-dt), p) < mindist)
{
mindist = Dist (Eval (mint-dt), p);
mint -= dt;
}
while (Dist (Eval (mint+dt), p) < mindist)
{
mindist = Dist (Eval (mint+dt), p);
mint += dt;
}
return NumericalProjectParam (p, mint-dt, mint+dt);
}
// t \in (n1, n2)
Point<2> BSplineCurve2d :: Eval (double t) const
{
int n, n1, n2, n3, n4;
double loct, b1, b2, b3, b4;
Point<2> hp;
static int cnt = 0;
cnt++;
if (cnt % 100000 == 0) (*mycout) << "cnt = " << cnt << endl;
n = int(t);
loct = t - n;
b1 = 0.25 * (1 - loct) * (1 - loct);
b4 = 0.25 * loct * loct;
b2 = 0.5 - b4;
b3 = 0.5 - b1;
n1 = (n + 10 * points.Size() -1) % points.Size() + 1;
n2 = n1+1;
if (n2 > points.Size()) n2 = 1;
n3 = n2+1;
if (n3 > points.Size()) n3 = 1;
n4 = n3+1;
if (n4 > points.Size()) n4 = 1;
// (*mycout) << "t = " << t << " n = " << n << " loct = " << loct
// << " n1 = " << n1 << endl;
hp(0) = b1 * points.Get(n1)(0) + b2 * points.Get(n2)(0) +
b3 * points.Get(n3)(0) + b4 * points.Get(n4)(0);
hp(1) = b1 * points.Get(n1)(1) + b2 * points.Get(n2)(1) +
b3 * points.Get(n3)(1) + b4 * points.Get(n4)(1);
return hp;
}
Vec<2> BSplineCurve2d :: EvalPrime (double t) const
{
int n, n1, n2, n3, n4;
double loct, db1, db2, db3, db4;
Vec<2> hv;
n = int(t);
loct = t - n;
db1 = 0.5 * (loct - 1);
db4 = 0.5 * loct;
db2 = -db4;
db3 = -db1;
n1 = (n + 10 * points.Size() -1) % points.Size() + 1;
n2 = n1+1;
if (n2 > points.Size()) n2 = 1;
n3 = n2+1;
if (n3 > points.Size()) n3 = 1;
n4 = n3+1;
if (n4 > points.Size()) n4 = 1;
hv(0) = db1 * points.Get(n1)(0) + db2 * points.Get(n2)(0) +
db3 * points.Get(n3)(0) + db4 * points.Get(n4)(0);
hv(1) = db1 * points.Get(n1)(1) + db2 * points.Get(n2)(1) +
db3 * points.Get(n3)(1) + db4 * points.Get(n4)(1);
return hv;
}
Vec<2> BSplineCurve2d :: EvalPrimePrime (double t) const
{
int n, n1, n2, n3, n4;
double ddb1, ddb2, ddb3, ddb4;
Vec<2> hv;
n = int(t);
// double loct = t - n;
ddb1 = 0.5;
ddb4 = 0.5;
ddb2 = -0.5;
ddb3 = -0.5;
n1 = (n + 10 * points.Size() -1) % points.Size() + 1;
n2 = n1+1;
if (n2 > points.Size()) n2 = 1;
n3 = n2+1;
if (n3 > points.Size()) n3 = 1;
n4 = n3+1;
if (n4 > points.Size()) n4 = 1;
hv(0) = ddb1 * points.Get(n1)(0) + ddb2 * points.Get(n2)(0) +
ddb3 * points.Get(n3)(0) + ddb4 * points.Get(n4)(0);
hv(1) = ddb1 * points.Get(n1)(1) + ddb2 * points.Get(n2)(1) +
ddb3 * points.Get(n3)(1) + ddb4 * points.Get(n4)(1);
return hv;
}
int BSplineCurve2d :: SectionUsed (double t) const
{
int n1 = int(t);
n1 = (n1 + 10 * points.Size() - 1) % points.Size() + 1;
return (intervallused.Get(n1) == 0);
}
void BSplineCurve2d :: Reduce (const Point<2> & p, double rad)
{
int n1, n;
int j;
double minx, miny, maxx, maxy;
// (*testout) << "Reduce: " << p << "," << rad << endl;
redlevel++;
for (n1 = 1; n1 <= points.Size(); n1++)
{
if (intervallused.Get(n1) != 0) continue;
minx = maxx = points.Get(n1)(0);
miny = maxy = points.Get(n1)(1);
n = n1;
for (j = 1; j <= 3; j++)
{
n++;
if (n > points.Size()) n = 1;
if (points.Get(n)(0) < minx) minx = points.Get(n)(0);
if (points.Get(n)(1) < miny) miny = points.Get(n)(1);
if (points.Get(n)(0) > maxx) maxx = points.Get(n)(0);
if (points.Get(n)(1) > maxy) maxy = points.Get(n)(1);
}
if (minx > p(0) + rad || maxx < p(0) - rad ||
miny > p(1) + rad || maxy < p(1) - rad)
{
intervallused.Elem(n1) = redlevel;
// (*testout) << 0;
}
else
{
// (*testout) << 1;
intervallused.Elem(n1) = 0;
}
}
// (*testout) << endl;
}
void BSplineCurve2d :: UnReduce ()
{
int i;
for (i = 1; i <= intervallused.Size(); i++)
if (intervallused.Get(i) == redlevel)
intervallused.Set (i, 0);
redlevel--;
}
void BSplineCurve2d :: Print (ostream & ost) const
{
ost << "SplineCurve: " << points.Size() << " points." << endl;
for (int i = 1; i <= points.Size(); i++)
ost << "P" << i << " = " << points.Get(i) << endl;
}
}

51
libsrc/csg/csg.hpp Normal file
View File

@ -0,0 +1,51 @@
#ifndef FILE_CSG
#define FILE_CSG
/* *************************************************************************/
/* File: geoml.hpp */
/* Author: Joachim Schoeberl */
/* Date: 21. Jun. 98 */
/* *************************************************************************/
#include <myadt.hpp>
#include <gprim.hpp>
#include <meshing.hpp>
#include <geometry2d.hpp>
namespace netgen
{
#include "surface.hpp"
#include "solid.hpp"
#include "identify.hpp"
#include "singularref.hpp"
#include "csgeom.hpp"
#include "csgparser.hpp"
#ifndef SMALLLIB
#define _INCLUDE_MORE
#endif
//#ifdef LINUX
#define _INCLUDE_MORE
//#endif
#ifdef _INCLUDE_MORE
#include "triapprox.hpp"
#include "algprim.hpp"
#include "brick.hpp"
#include "spline3d.hpp"
#include "manifold.hpp"
#include "curve2d.hpp"
#include "explicitcurve2d.hpp"
#include "gencyl.hpp"
#include "polyhedra.hpp"
#include "extrusion.hpp"
#include "revolution.hpp"
#include "specpoin.hpp"
#include "edgeflw.hpp"
#include "meshsurf.hpp"
#endif
}
#endif

1422
libsrc/csg/csgeom.cpp Normal file

File diff suppressed because it is too large Load Diff

309
libsrc/csg/csgeom.hpp Normal file
View File

@ -0,0 +1,309 @@
#ifndef FILE_CSGEOM
#define FILE_CSGEOM
/**************************************************************************/
/* File: csgeom.hh */
/* Author: Joachim Schoeberl */
/* Date: 27. Nov. 97 */
/**************************************************************************/
/**
Constructive Solid Geometry
*/
class TriangleApproximation;
class TATriangle;
/**
A top level object is an entity to be meshed.
I can be either a solid, or one surface patch of a solid.
*/
class TopLevelObject
{
Solid * solid;
Surface * surface;
double red, blue, green;
bool visible, transp;
double maxh;
string material;
int layer;
int bc; // for surface patches, only
string bcname;
public:
TopLevelObject (Solid * asolid,
Surface * asurface = NULL);
const Solid * GetSolid() const { return solid; }
Solid * GetSolid() { return solid; }
const Surface * GetSurface () const { return surface; }
Surface * GetSurface () { return surface; }
void GetData (ostream & ost);
void SetData (istream & ist);
void SetMaxH (double amaxh) { maxh = amaxh; }
double GetMaxH () const { return maxh; }
void SetRGB (double ared, double agreen, double ablue)
{
red = ared;
green = agreen;
blue = ablue;
}
double GetRed () const { return red; }
double GetGreen () const { return green; }
double GetBlue () const { return blue; }
void SetTransparent (bool atransp)
{ transp = atransp; }
bool GetTransparent () const { return transp; }
void SetVisible (bool avisible)
{ visible = avisible; }
bool GetVisible () const { return visible; }
const string GetMaterial () const { return material; }
void SetMaterial (const string & mat) { material = mat; }
int GetLayer () const { return layer; }
void SetLayer (int alayer) { layer = alayer; }
void SetBCProp (int abc) { bc = abc; }
int GetBCProp () const { return bc; }
void SetBCName (string abc) { bcname = abc; }
const string GetBCName () const { return bcname; }
};
/**
CSGeometry has the whole geometric information
*/
class CSGeometry
{
private:
/// all surfaces
SYMBOLTABLE<Surface*> surfaces;
public:
/// primitive of surface
ARRAY<const Primitive*> surf2prim;
private:
ARRAY<Surface*> delete_them;
/// all named solids
SYMBOLTABLE<Solid*> solids;
/// all 2d splinecurves
SYMBOLTABLE< SplineGeometry<2>* > splinecurves2d;
/// all 3d splinecurves
SYMBOLTABLE< SplineGeometry<3>* > splinecurves3d;
/// all top level objects: solids and surfaces
ARRAY<TopLevelObject*> toplevelobjects;
/// additional points specified by user
ARRAY<Point<3> > userpoints;
ARRAY<double> userpoints_ref_factor;
mutable ARRAY<Point<3> > identpoints;
/// triangular approximation of top level objects
ARRAY<TriangleApproximation*> triapprox;
/// increment, if geometry is changed
static int changeval;
/// bounding box of geometry
Box<3> boundingbox;
/// bounding box, if not set by input file
static Box<3> default_boundingbox;
/// identic surfaces are stored by pair of indizes, val = inverse
INDEX_2_HASHTABLE<int> identicsurfaces;
ARRAY<int> isidenticto;
/// identification of boundaries (periodic, thin domains, ...)
double ideps;
/// filename of inputfile
string filename;
public:
CSGeometry ();
CSGeometry (const string & afilename);
~CSGeometry ();
void Clean ();
void Save (ostream & ost);
void Load (istream & ist);
void SaveSurfaces (ostream & out);
void LoadSurfaces (istream & in);
int GetChangeVal() { return changeval; }
void Change() { changeval++; }
void AddSurface (Surface * surf);
void AddSurface (char * name, Surface * surf);
void AddSurfaces (Primitive * prim);
int GetNSurf () const { return surfaces.Size(); }
const Surface * GetSurface (const char * name) const;
const Surface * GetSurface (int i) const
{ return surfaces[i]; }
void SetSolid (const char * name, Solid * sol);
const Solid * GetSolid (const char * name) const;
const Solid * GetSolid (const string & name) const;
int GetNSolids () const { return solids.Size(); }
const Solid * GetSolid (int i) const { return solids[i]; }
const SYMBOLTABLE<Solid*> & GetSolids () const { return solids; }
void SetSplineCurve (const char * name, SplineGeometry<2> * spl);
void SetSplineCurve (const char * name, SplineGeometry<3> * spl);
const SplineGeometry<2> * GetSplineCurve2d (const string & name) const;
const SplineGeometry<3> * GetSplineCurve3d (const string & name) const;
void SetFlags (const char * solidname, const Flags & flags);
int GetNTopLevelObjects () const
{ return toplevelobjects.Size(); }
int SetTopLevelObject (Solid * sol, Surface * surf = NULL);
void GetTopLevelObject (int nr, Solid *& sol, Surface *& surf)
{
sol = toplevelobjects[nr]->GetSolid();
surf = toplevelobjects[nr]->GetSurface();
}
void GetTopLevelObject (int nr, const Solid *& sol, const Surface *& surf) const
{
sol = toplevelobjects[nr]->GetSolid();
surf = toplevelobjects[nr]->GetSurface();
}
TopLevelObject * GetTopLevelObject (const Solid * sol, const Surface * surf = NULL);
TopLevelObject * GetTopLevelObject (int nr)
{ return toplevelobjects[nr]; }
const TopLevelObject * GetTopLevelObject (int nr) const
{ return toplevelobjects[nr]; }
void RemoveTopLevelObject (Solid * sol, Surface * surf = NULL);
void AddUserPoint (const Point<3> & p, double ref_factor = 0)
{ userpoints.Append (p); userpoints_ref_factor.Append (ref_factor); }
int GetNUserPoints () const
{ return userpoints.Size(); }
const Point<3> & GetUserPoint (int nr) const
{ return userpoints[nr]; }
double GetUserPointRefFactor (int nr) const
{ return userpoints_ref_factor[nr]; }
void AddIdentPoint (const Point<3> & p) const
{ identpoints.Append(p);}
int GetNIdentPoints (void) const
{ return identpoints.Size();}
const Point<3> & GetIdentPoint(int nr) const
{ return identpoints[nr]; }
void DeleteIdentPoints(void) const
{ identpoints.DeleteAll();}
// quick implementations:
ARRAY<SingularFace*> singfaces;
ARRAY<SingularEdge*> singedges;
ARRAY<SingularPoint*> singpoints;
ARRAY<Identification*> identifications;
int GetNIdentifications (void) const { return identifications.Size(); }
void AddIdentification (Identification * ident);
///
void CalcTriangleApproximation(const Box<3> & boundingbox,
double detail, double facets);
///
void FindIdenticSurfaces (double eps);
///
void GetSurfaceIndices (const Solid * sol,
const BoxSphere<3> & box,
ARRAY<int> & locsurf) const;
///
void GetIndependentSurfaceIndices (const Solid * sol,
const BoxSphere<3> & box,
ARRAY<int> & locsurf) const;
///
void GetIndependentSurfaceIndices (const Solid * sol,
const Point<3> & p, Vec<3> & v,
ARRAY<int> & locsurf) const;
///
void GetIndependentSurfaceIndices (ARRAY<int> & locsurf) const;
///
int GetSurfaceClassRepresentant (int si) const
{ return isidenticto[si]; }
///
const TriangleApproximation * GetTriApprox (int msnr)
{
if (msnr < triapprox.Size())
return triapprox[msnr];
return 0;
}
void IterateAllSolids (SolidIterator & it, bool only_once = false);
void RefineTriangleApprox (Solid * locsol,
int surfind,
const BoxSphere<3> & box,
double detail,
const TATriangle & tria,
TriangleApproximation & tams,
IndexSet & iset);
const Box<3> & BoundingBox () const { return boundingbox; }
void SetBoundingBox (const Box<3> & abox)
{
boundingbox = abox;
}
static void SetDefaultBoundingBox (const Box<3> & abox)
{
default_boundingbox = abox;
}
double MaxSize () const;
void SetIdEps(double eps){ideps = eps;}
double GetIdEps(void) const {return ideps;}
class BCModification {
public:
int si;
int tlonr;
int bcnr;
string * bcname;
};
ARRAY<BCModification> bcmodifications;
};
#endif

1332
libsrc/csg/csgparser.cpp Normal file

File diff suppressed because it is too large Load Diff

107
libsrc/csg/csgparser.hpp Normal file
View File

@ -0,0 +1,107 @@
#ifndef _CSGPARSER_HPP
#define _CSGPARSER_HPP
//namespace netgen
//{
enum TOKEN_TYPE
{
TOK_MINUS = '-', TOK_LP = '(', OK_RP = ')', TOK_LSP = '[', TOK_RSP = ']',
TOK_EQU = '=', TOK_COMMA = ',', TOK_SEMICOLON = ';',
TOK_NUM = 100, TOK_STRING, TOK_NAMED_SOLID, TOK_PRIMITIVE,
TOK_OR, TOK_AND, TOK_NOT,
TOK_SINGULAR, TOK_EDGE, TOK_POINT, TOK_FACE, TOK_IDENTIFY, TOK_CLOSESURFACES,
TOK_CLOSEEDGES, TOK_PERIODIC,
TOK_SOLID, TOK_RECO, TOK_TLO, TOK_CURVE2D, TOK_CURVE3D, TOK_BOUNDINGBOX,
TOK_BOUNDARYCONDITION, TOK_BOUNDARYCONDITIONNAME,
TOK_DEFINE, TOK_CONSTANT,
TOK_END };
struct kwstruct
{
TOKEN_TYPE kw;
const char * name;
};
enum PRIMITIVE_TYPE
{
TOK_SPHERE = 1, TOK_CYLINDER, TOK_PLANE, TOK_ELLIPTICCYLINDER,
TOK_ELLIPSOID, TOK_CONE,
TOK_ORTHOBRICK, TOK_POLYHEDRON,
TOK_TORUS,
TOK_TUBE, TOK_GENCYL, TOK_EXTRUSION, TOK_REVOLUTION,
TOK_TRANSLATE, TOK_MULTITRANSLATE, TOK_ROTATE, TOK_MULTIROTATE
};
struct primstruct
{
PRIMITIVE_TYPE kw;
const char * name;
};
class CSGScanner
{
TOKEN_TYPE token;
PRIMITIVE_TYPE prim_token;
double num_value;
string string_value;
int linenum;
istream * scanin;
public:
CSGScanner (istream & ascanin);
TOKEN_TYPE GetToken() const
{ return token; }
double GetNumValue() const
{ return num_value; }
const string & GetStringValue() const
{ return string_value; }
char GetCharValue() const
{ return string_value[0]; }
PRIMITIVE_TYPE GetPrimitiveToken() const
{ return prim_token; }
void ReadNext();
/*
CSGScanner & Parse (char ch);
CSGScanner & Parse (int & i);
CSGScanner & Parse (double & d);
CSGScanner & Parse (Point<3> & p);
CSGScanner & Parse (Vec<3> & p);
*/
void Error (const string & err);
};
CSGScanner & operator>> (CSGScanner & scan, char ch);
CSGScanner & operator>> (CSGScanner & scan, double & d);
CSGScanner & operator>> (CSGScanner & scan, int & i);
CSGScanner & operator>> (CSGScanner & scan, Point<3> & p);
CSGScanner & operator>> (CSGScanner & scan, Vec<3> & v);
//}
#endif // _CSGPARSER_HPP

78
libsrc/csg/curve2d.cpp Normal file
View File

@ -0,0 +1,78 @@
#include <mystdlib.h>
#include <myadt.hpp>
#include <csg.hpp>
namespace netgen
{
CircleCurve2d :: CircleCurve2d (const Point<2> & acenter, double arad)
{
center = acenter;
rad = arad;
}
void CircleCurve2d :: Project (Point<2> & p) const
{
Vec<2> v = p - center;
v *= rad/v.Length();
p = center + v;
}
void CircleCurve2d :: NormalVector (const Point<2> & p, Vec<2> & n) const
{
n = p - center;
n /= n.Length();
}
QuadraticCurve2d :: QuadraticCurve2d ()
{
cxx = cyy = cxy = cx = cy = c = 0;
}
void QuadraticCurve2d :: Read (istream & ist)
{
ist >> cxx >> cyy >> cxy >> cx >> cy >> c;
}
void QuadraticCurve2d :: Project (Point<2> & p) const
{
double f, x, y, gradx, grady, grad2;
int its = 0;
x = p(0);
y = p(1);
do
{
f = cxx * x * x + cyy * y * y + cxy * x * y + cx * x + cy * y + c;
gradx = 2 * cxx * x + cxy * y + cx;
grady = 2 * cyy * y + cxy * x + cy;
grad2 = gradx * gradx + grady * grady;
x -= f * gradx / grad2;
y -= f * grady / grad2;
// (*mycout) << "x = " << x << " y = " << y << " f = " << f << endl;
its++;
}
while (fabs (f) > 1e-8 && its < 20);
if (its >= 20)
cerr << "QuadraticCurve2d::Project: many iterations, f = " << f << endl;
p(0) = x;
p(1) = y;
}
void QuadraticCurve2d :: NormalVector (const Point<2> & p, Vec<2> & n) const
{
n(0) = 2 * cxx * p(0) + cxy * p(1) + cx;
n(1) = 2 * cyy * p(1) + cxy * p(0) + cy;
n.Normalize();
}
}

59
libsrc/csg/curve2d.hpp Normal file
View File

@ -0,0 +1,59 @@
#ifndef FILE_CURVE2D
#define FILE_CURVE2D
/**************************************************************************/
/* File: curve2d.hh */
/* Author: Joachim Schoeberl */
/* Date: 24. Jul. 96 */
/**************************************************************************/
/*
2D Curve repesentation
*/
///
class Curve2d : public Manifold
{
public:
///
virtual void Project (Point<2> & p) const = 0;
///
virtual void NormalVector (const Point<2> & p, Vec<2> & n) const = 0;
};
///
class CircleCurve2d : public Curve2d
{
///
Point<2> center;
///
double rad;
public:
///
CircleCurve2d (const Point<2> & acenter, double arad);
///
virtual void Project (Point<2> & p) const;
///
virtual void NormalVector (const Point<2> & p, Vec<2> & n) const;
};
///
class QuadraticCurve2d : public Curve2d
{
///
double cxx, cyy, cxy, cx, cy, c;
public:
///
QuadraticCurve2d ();
///
void Read (istream & ist);
///
virtual void Project (Point<2> & p) const;
///
virtual void NormalVector (const Point<2> & p, Vec<2> & n) const;
};
#endif

1820
libsrc/csg/edgeflw.cpp Normal file

File diff suppressed because it is too large Load Diff

104
libsrc/csg/edgeflw.hpp Normal file
View File

@ -0,0 +1,104 @@
#ifndef FILE_EDGEFLW
#define FILE_EDGEFLW
/**************************************************************************/
/* File: edgeflw.hh */
/* Author: Joachim Schoeberl */
/* Date: 01. Okt. 95 */
/**************************************************************************/
/*
Edge - following function and
Projection to edge of implicitly given edge
*/
/**
Calculates edges.
The edges of a solid geometry are computed. Special
points have to be given.
*/
extern void CalcEdges (const CSGeometry & geometry,
const ARRAY<SpecialPoint> & specpoints,
double h, Mesh & mesh);
class EdgeCalculation
{
const CSGeometry & geometry;
ARRAY<SpecialPoint> & specpoints;
Point3dTree * searchtree;
Point3dTree * meshpoint_tree;
int cntedge;
double ideps;
public:
EdgeCalculation (const CSGeometry & ageometry,
ARRAY<SpecialPoint> & aspecpoints);
~EdgeCalculation();
void SetIdEps(const double epsin) {ideps = epsin;}
void Calc(double h, Mesh & mesh);
private:
void CalcEdges1 (double h, Mesh & mesh);
void FollowEdge (int pi1, int & ep, int & pos,
// const ARRAY<SpecialPoint> & hsp,
const ARRAY<int> & hsp,
double h, const Mesh & mesh,
ARRAY<Point<3> > & edgepoints,
ARRAY<double> & curvelength);
void AnalyzeEdge (int s1, int s2, int s1_rep, int s2_rep, int pos, int layer,
const ARRAY<Point<3> > & edgepoints,
ARRAY<Segment> & refedges,
ARRAY<bool> & refedgesinv);
void StoreEdge (const ARRAY<Segment> & refedges,
const ARRAY<bool> & refedgesinv,
const ARRAY<Point<3> > & edgepoints,
const ARRAY<double> & curvelength,
int layer,
Mesh & mesh);
void StoreShortEdge (const ARRAY<Segment> & refedges,
const ARRAY<bool> & refedgesinv,
const ARRAY<Point<3> > & edgepoints,
const ARRAY<double> & curvelength,
int layer,
Mesh & mesh);
void CopyEdge (const ARRAY<Segment> & refedges,
const ARRAY<bool> & refedgesinv,
int copyfromedge,
const Point<3> & fromstart, const Point<3> & fromend,
const Point<3> & tostart, const Point<3> & toend,
int copyedgeidentification,
int layer,
Mesh & mesh);
void SplitEqualOneSegEdges (Mesh & mesh);
void FindClosedSurfaces (double h, Mesh & mesh);
public:
bool point_on_edge_problem;
};
#endif

View File

@ -0,0 +1,160 @@
#include <mystdlib.h>
#include <csg.hpp>
namespace netgen
{
ExplicitCurve2d :: ExplicitCurve2d ()
{
;
}
void ExplicitCurve2d :: Project (Point<2> & p) const
{
double t;
t = ProjectParam (p);
p = Eval (t);
}
double ExplicitCurve2d :: NumericalProjectParam (const Point<2> & p, double lb, double ub) const
{
double t(-1);
Vec<2> tan;
Vec<2> curv;
Point<2> cp;
double f, fl, fu;
int cnt;
tan = EvalPrime (lb);
cp = Eval (lb);
fl = tan * (cp - p);
if (fl > 0) // changed by wmf, originally fl >= 0
{
// cerr << "tan = " << tan << " cp - p = " << (cp - p) << endl;
// cerr << "ExplicitCurve2d::NumericalProject: lb wrong" << endl;
return 0;
}
tan = EvalPrime (ub);
cp = Eval (ub);
fu = tan * (cp - p);
if (fu < 0) // changed by wmf, originally fu <= 0
{
// cerr << "tan = " << tan << " cp - p = " << (cp - p) << endl;
// cerr << "ExplicitCurve2d::NumericalProject: ub wrong" << endl;
return 0;
}
cnt = 0;
while (ub - lb > 1e-12 && fu - fl > 1e-12)
{
cnt++;
if (cnt > 50)
{
(*testout) << "Num Proj, cnt = " << cnt << endl;
}
t = (lb * fu - ub * fl) / (fu - fl);
if (t > 0.9 * ub + 0.1 * lb) t = 0.9 * ub + 0.1 * lb;
if (t < 0.1 * ub + 0.9 * lb) t = 0.1 * ub + 0.9 * lb;
tan = EvalPrime (t);
cp = Eval (t);
f = tan * (cp - p);
if (f >= 0)
{
ub = t;
fu = f;
}
else
{
lb = t;
fl = f;
}
}
return t;
}
Vec<2> ExplicitCurve2d :: Normal (double t) const
{
Vec<2> tan = EvalPrime (t);
tan.Normalize();
return Vec<2> (tan(1), -tan(0));
}
void ExplicitCurve2d :: NormalVector (const Point<2> & p, Vec<2> & n) const
{
double t = ProjectParam (p);
n = Normal (t);
}
Point<2> ExplicitCurve2d :: CurvCircle (double t) const
{
Point<2> cp;
Vec<2> tan, n, curv;
double den;
cp = Eval (t);
tan = EvalPrime (t);
n = Normal (t);
curv = EvalPrimePrime (t);
den = n * curv;
if (fabs (den) < 1e-12)
return cp + 1e12 * n;
return cp + (tan.Length2() / den) * n;
}
double ExplicitCurve2d :: MaxCurvature () const
{
double t, tmin, tmax, dt;
double curv;
Vec<2> tan;
double maxcurv;
maxcurv = 0;
tmin = MinParam ();
tmax = MaxParam ();
dt = (tmax - tmin) / 1000;
for (t = tmin; t <= tmax+dt; t += dt)
if (SectionUsed (t))
{
tan = EvalPrime (t);
curv = fabs ( (Normal(t) * EvalPrimePrime(t)) / tan.Length2());
if (curv > maxcurv) maxcurv = curv;
}
return maxcurv;
}
double ExplicitCurve2d :: MaxCurvatureLoc (const Point<2> & p, double rad) const
{
double t, tmin, tmax, dt;
double curv;
Vec<2> tan;
double maxcurv;
maxcurv = 0;
tmin = MinParam ();
tmax = MaxParam ();
dt = (tmax - tmin) / 1000;
for (t = tmin; t <= tmax+dt; t += dt)
if (Dist (Eval(t), p) < rad)
{
tan = EvalPrime (t);
curv = fabs ( (Normal(t) * EvalPrimePrime(t)) / tan.Length2());
if (curv > maxcurv) maxcurv = curv;
}
return maxcurv;
}
}

View File

@ -0,0 +1,109 @@
#ifndef FILE_EXPLICITCURVE2D
#define FILE_EXPLICITCURVE2D
/**************************************************************************/
/* File: explicitcurve2d.hh */
/* Author: Joachim Schoeberl */
/* Date: 14. Oct. 96 */
/**************************************************************************/
/*
Explicit 2D Curve repesentation
*/
///
class ExplicitCurve2d : public Curve2d
{
public:
///
ExplicitCurve2d ();
///
virtual void Project (Point<2> & p) const;
///
virtual double ProjectParam (const Point<2> & p) const = 0;
///
virtual double NumericalProjectParam (const Point<2> & p, double lb, double ub) const;
///
virtual double MinParam () const = 0;
///
virtual double MaxParam () const = 0;
///
virtual Point<2> Eval (double t) const = 0;
///
virtual Vec<2> EvalPrime (double t) const = 0;
///
virtual Vec<2> Normal (double t) const;
///
virtual void NormalVector (const Point<2> & p, Vec<2> & n) const;
///
virtual Vec<2> EvalPrimePrime (double t) const = 0;
///
virtual double MaxCurvature () const;
///
virtual double MaxCurvatureLoc (const Point<2> & p, double rad) const;
///
virtual Point<2> CurvCircle (double t) const;
///
virtual void Print (ostream & /* str */) const { };
///
virtual int SectionUsed (double /* t */) const { return 1; }
///
virtual void Reduce (const Point<2> & /* p */, double /* rad */) { };
///
virtual void UnReduce () { };
};
///
class BSplineCurve2d : public ExplicitCurve2d
{
///
ARRAY<Point<2> > points;
///
ARRAY<int> intervallused;
///
int redlevel;
public:
///
BSplineCurve2d ();
///
void AddPoint (const Point<2> & apoint);
bool Inside (const Point<2> & p, double & dist) const;
///
virtual double ProjectParam (const Point<2> & p) const;
///
virtual double MinParam () const { return 0; }
///
virtual double MaxParam () const { return points.Size(); }
///
virtual Point<2> Eval (double t) const;
///
virtual Vec<2> EvalPrime (double t) const;
///
virtual Vec<2> EvalPrimePrime (double t) const;
///
virtual void Print (ostream & str) const;
///
virtual int SectionUsed (double t) const;
///
virtual void Reduce (const Point<2> & p, double rad);
///
virtual void UnReduce ();
};
#endif

940
libsrc/csg/extrusion.cpp Normal file
View File

@ -0,0 +1,940 @@
#include <mystdlib.h>
#include <linalg.hpp>
#include <csg.hpp>
namespace netgen
{
void ExtrusionFace :: Init(void)
{
p0.SetSize(path->GetNSplines());
x_dir.SetSize(path->GetNSplines());
y_dir.SetSize(path->GetNSplines());
z_dir.SetSize(path->GetNSplines());
loc_z_dir.SetSize(path->GetNSplines());
spline3_path.SetSize(path->GetNSplines());
line_path.SetSize(path->GetNSplines());
for(int i=0; i<path->GetNSplines(); i++)
{
spline3_path[i] = dynamic_cast < const SplineSeg3<3>* >(&path->GetSpline(i));
line_path[i] = dynamic_cast < const LineSeg<3>* >(&path->GetSpline(i));
if(line_path[i])
{
y_dir[i] = line_path[i]->EndPI() - line_path[i]->StartPI();
y_dir[i].Normalize();
z_dir[i] = glob_z_direction;
Orthogonalize(y_dir[i],z_dir[i]);
x_dir[i] = Cross(y_dir[i],z_dir[i]);
loc_z_dir[i] = z_dir[i];
}
else
{
z_dir[i] = glob_z_direction;
loc_z_dir[i] = glob_z_direction;
}
}
profile->GetCoeff(profile_spline_coeff);
latest_point3d = -1.111e30;
}
ExtrusionFace :: ExtrusionFace(const SplineSeg<2> * profile_in,
const SplineGeometry<3> * path_in,
const Vec<3> & z_direction) :
profile(profile_in), path(path_in), glob_z_direction(z_direction)
{
deletable = false;
Init();
}
ExtrusionFace :: ExtrusionFace(const ARRAY<double> & raw_data)
{
deletable = true;
int pos=0;
ARRAY< Point<2> > p(3);
int ptype = int(raw_data[pos]); pos++;
for(int i=0; i<ptype; i++)
{
p[i](0) = raw_data[pos]; pos++;
p[i](1) = raw_data[pos]; pos++;
}
if(ptype == 2)
{
profile = new LineSeg<2>(GeomPoint<2>(p[0],1),
GeomPoint<2>(p[1],1));
//(*testout) << "appending LineSeg<2> " << p[0]
// << " to " << p[1] << endl;
}
else if(ptype == 3)
{
profile = new SplineSeg3<2>(GeomPoint<2>(p[0],1),
GeomPoint<2>(p[1],1),
GeomPoint<2>(p[2],1));
//(*testout) << "appending SplineSeg<3> "
// << p[0] << " -- " << p[1] << " -- " << p[2] << endl;
}
path = new SplineGeometry<3>;
pos = const_cast< SplineGeometry<3> *>(path)->Load(raw_data,pos);
for(int i=0; i<3; i++)
{
glob_z_direction(i) = raw_data[pos];
pos++;
}
//(*testout) << "read glob_z_direction " << glob_z_direction << endl;
Init();
}
ExtrusionFace :: ~ExtrusionFace()
{
if(deletable)
{
delete profile;
delete path;
}
}
int ExtrusionFace :: IsIdentic (const Surface & s2, int & inv, double eps) const
{
const ExtrusionFace * ext2 = dynamic_cast<const ExtrusionFace*>(&s2);
if(!ext2) return 0;
if(ext2 == this)
return 1;
return 0;
}
void ExtrusionFace :: Orthogonalize(const Vec<3> & v1, Vec<3> & v2) const
{
v2 -= (v1*v2)*v1;
v2.Normalize();
}
void ExtrusionFace :: CalcProj(const Point<3> & point3d, Point<2> & point2d,
int & seg, double & t) const
{
if(Dist2(point3d,latest_point3d) < 1e-25*Dist2(path->GetSpline(0).StartPI(),path->GetSpline(0).EndPI()))
{
point2d = latest_point2d;
seg = latest_seg;
t = latest_t;
return;
}
latest_point3d = point3d;
double cutdist(-1);
ARRAY<double> mindist(path->GetNSplines());
for(int i=0; i<path->GetNSplines(); i++)
{
double auxcut(-1);
double auxmin(-1);
if(spline3_path[i])
{
Point<3> startp(path->GetSpline(i).StartPI());
Point<3> endp(path->GetSpline(i).EndPI());
Point<3> tanp(spline3_path[i]->TangentPoint());
double da,db,dc;
double l;
Vec<3> dir = endp-startp;
l = dir.Length(); dir *= 1./l;
Vec<3> topoint = point3d - startp;
double s = topoint * dir;
if(s<=0)
da = topoint.Length();
else if(s>=l)
da = Dist(endp,point3d);
else
da = sqrt(topoint.Length2() - s*s);
dir = tanp - startp;
l = dir.Length(); dir *= 1./l;
topoint = point3d - startp;
s = topoint * dir;
if(s<=0)
db = topoint.Length();
else if(s>=l)
db = Dist(tanp,point3d);
else
db = sqrt(topoint.Length2() - s*s);
dir = endp - tanp;
l = dir.Length(); dir *= 1./l;
topoint = point3d - tanp;
s = topoint * dir;
if(s<=0)
dc = topoint.Length();
else if(s>=l)
dc = Dist(endp,point3d);
else
dc = sqrt(topoint.Length2() - s*s);
if(da > db && da > dc)
auxcut = da;
else
auxcut = max2(da,min2(db,dc));
auxmin = min3(da,db,dc);
}
else if(line_path[i])
{
double l;
Vec<3> dir = path->GetSpline(i).EndPI() - path->GetSpline(i).StartPI();
l = dir.Length(); dir *= 1./l;
Vec<3> topoint = point3d - path->GetSpline(i).StartPI();
double s = topoint * dir;
if(s<=0)
auxcut = topoint.Length();
else if(s>=l)
auxcut = Dist(path->GetSpline(i).EndPI(),point3d);
else
auxcut = sqrt(topoint.Length2() - s*s);
auxmin = auxcut;
}
mindist[i] = auxmin;
if(i==0 || auxcut < cutdist)
cutdist = auxcut;
/*
double d1 = Dist2(point3d,path.GetSpline(i).StartPI());
double d2 = Dist2(point3d,path.GetSpline(i).EndPI());
if(d1 <= d2)
{
mindist[i] = d1;
if(i==0 || d2 < cutdist)
cutdist = d2;
}
else
{
mindist[i] = d2;
if(i==0 || d1 < cutdist)
cutdist = d1;
}
*/
}
//(*testout) << " cutdist " << cutdist << " mindist " << mindist << endl;
Point<2> testpoint2d;
Point<3> testpoint3d;
double minproj(-1);
bool minproj_set(false);
//(*testout) << "point "<< point3d << " candidates: ";
for(int i=0; i<path->GetNSplines(); i++)
{
if(mindist[i] > cutdist) continue;
//(*testout) << i << " ";
double thist = CalcProj(point3d,testpoint2d,i);
testpoint3d = p0[i] + testpoint2d(0)*x_dir[i] + testpoint2d(1)*loc_z_dir[i];
double d = Dist2(point3d,testpoint3d);
//(*testout) << "(d="<<d<<") ";
if(!minproj_set || d < minproj)
{
minproj_set = true;
minproj = d;
point2d = testpoint2d;
t = thist;
seg = i;
latest_seg = i;
latest_t = t;
latest_point2d = point2d;
}
}
//(*testout) << endl;
//(*testout) << " t " << t << endl;
}
double ExtrusionFace :: CalcProj(const Point<3> & point3d, Point<2> & point2d,
const int seg) const
{
double t(-1);
if(line_path[seg])
{
point2d(0) = (point3d-line_path[seg]->StartPI())*x_dir[seg];
point2d(1) = (point3d-line_path[seg]->StartPI())*z_dir[seg];
double l = Dist(line_path[seg]->StartPI(),
line_path[seg]->EndPI());
t = min2(max2((point3d - line_path[seg]->StartPI()) * y_dir[seg],0.),
l);
p0[seg] = line_path[seg]->StartPI() + t*y_dir[seg];
t *= 1./l;
}
else if(spline3_path[seg])
{
spline3_path[seg]->Project(point3d,p0[seg],t);
y_dir[seg] = spline3_path[seg]->GetTangent(t); y_dir[seg].Normalize();
loc_z_dir[seg] = z_dir[seg];
Orthogonalize(y_dir[seg],loc_z_dir[seg]);
x_dir[seg] = Cross(y_dir[seg],loc_z_dir[seg]);
Vec<3> dir = point3d-p0[seg];
point2d(0) = x_dir[seg]*dir;
point2d(1) = loc_z_dir[seg]*dir;
}
return t;
}
double ExtrusionFace :: CalcFunctionValue (const Point<3> & point) const
{
Point<2> p;
double dummyd;
int dummyi;
CalcProj(point,p,dummyi,dummyd);
//(*testout) << "spline " << dummyi << " t " << dummyd << endl;
return profile_spline_coeff(0)*p(0)*p(0) + profile_spline_coeff(1)*p(1)*p(1)
+ profile_spline_coeff(2)*p(0)*p(1) + profile_spline_coeff(3)*p(0)
+ profile_spline_coeff(4)*p(1) + profile_spline_coeff(5);
}
void ExtrusionFace :: CalcGradient (const Point<3> & point, Vec<3> & grad) const
{
int i;
Point<2> p2d;
double t_path;
int seg;
CalcProj(point,p2d,seg,t_path);
Point<3> phi;
Vec<3> phip,phipp,phi_minus_point;
path->GetSpline(seg).GetDerivatives(t_path,phi,phip,phipp);
phi_minus_point = phi-point;
Vec<3> grad_t = phip;
double facA = phipp*phi_minus_point + phip*phip;
grad_t *= 1./facA;
ARRAY < Vec<3> > dphi_dX(3);
for(i=0; i<3; i++)
dphi_dX[i] = grad_t(i)*phip;
ARRAY < Vec<3> > dy_dir_dX(3);
double lphip = phip.Length();
dy_dir_dX[0] = dy_dir_dX[1] = dy_dir_dX[2] =
(1./lphip) * phipp - ((phip*phipp)/pow(lphip,3)) * phip;
for(i=0; i<3; i++)
dy_dir_dX[i] *= grad_t(i);
ARRAY < Vec<3> > dx_dir_dX(3);
for(i=0; i<3; i++)
dx_dir_dX[i] = Cross(dy_dir_dX[i],z_dir[seg]);
Vec<3> grad_xbar;
for(i=0; i<3; i++)
grad_xbar(i) = -1.*(phi_minus_point * dx_dir_dX[i]) + x_dir[seg](i) - x_dir[seg] * dphi_dX[i];
double zy = z_dir[seg]*y_dir[seg];
Vec<3> grad_ybar;
Vec<3> aux = z_dir[seg] - zy*y_dir[seg];
for(i=0; i<3; i++)
grad_ybar(i) = ( (z_dir[seg]*dy_dir_dX[i])*y_dir[seg] + zy*dy_dir_dX[i] ) * phi_minus_point +
aux[i] -
aux * dphi_dX[i];
const double dFdxbar = 2.*profile_spline_coeff(0)*p2d(0) +
profile_spline_coeff(2)*p2d(1) + profile_spline_coeff(3);
const double dFdybar = 2.*profile_spline_coeff(1)*p2d(1) +
profile_spline_coeff(2)*p2d(0) + profile_spline_coeff(4);
grad = dFdxbar * grad_xbar + dFdybar * grad_ybar;
}
void ExtrusionFace :: CalcHesse (const Point<3> & point, Mat<3> & hesse) const
{
const double eps = 1e-7*Dist(path->GetSpline(0).StartPI(),path->GetSpline(0).EndPI());
/*
Point<3> auxpoint1(point),auxpoint2(point);
Vec<3> auxvec,auxgrad1,auxgrad2;
for(int i=0; i<3; i++)
{
auxpoint1(i) -= eps;
auxpoint2(i) += eps;
CalcGradient(auxpoint1,auxgrad1);
CalcGradient(auxpoint2,auxgrad2);
auxvec = (1./(2.*eps)) * (auxgrad2-auxgrad1);
for(int j=0; j<3; j++)
hesse(i,j) = auxvec(j);
auxpoint1(i) = point(i);
auxpoint2(i) = point(i);
}
*/
Vec<3> grad;
CalcGradient(point,grad);
Point<3> auxpoint(point);
Vec<3> auxvec,auxgrad;
for(int i=0; i<3; i++)
{
auxpoint(i) -= eps;
CalcGradient(auxpoint,auxgrad);
auxvec = (1./eps) * (grad-auxgrad);
for(int j=0; j<3; j++)
hesse(i,j) = auxvec(j);
auxpoint(i) = point(i);
}
for(int i=0; i<3; i++)
for(int j=i+1; j<3; j++)
hesse(i,j) = hesse(j,i) = 0.5*(hesse(i,j)+hesse(j,i));
}
double ExtrusionFace :: HesseNorm () const
{
return fabs(profile_spline_coeff(0) + profile_spline_coeff(1)) +
sqrt(pow(profile_spline_coeff(0)+profile_spline_coeff(1),2)+4.*pow(profile_spline_coeff(2),2));
}
double ExtrusionFace :: MaxCurvature () const
{
double retval,actmax;
retval = profile->MaxCurvature();
for(int i=0; i<path->GetNSplines(); i++)
{
actmax = path->GetSpline(i).MaxCurvature();
if(actmax > retval)
retval = actmax;
}
return 2.*retval;
}
void ExtrusionFace :: Project (Point<3> & p) const
{
double dummyt;
int seg;
Point<2> p2d;
CalcProj(p,p2d,seg,dummyt);
profile->Project(p2d,p2d,profile_par);
p = p0[seg] + p2d(0)*x_dir[seg] + p2d(1)*loc_z_dir[seg];
Vec<2> tangent2d = profile->GetTangent(profile_par);
profile_tangent = tangent2d(0)*x_dir[seg] + tangent2d(1)*y_dir[seg];
}
Point<3> ExtrusionFace :: GetSurfacePoint () const
{
p0[0] = path->GetSpline(0).GetPoint(0.5);
if(!line_path[0])
{
y_dir[0] = path->GetSpline(0).GetTangent(0.5);
y_dir[0].Normalize();
loc_z_dir[0] = z_dir[0];
Orthogonalize(y_dir[0],loc_z_dir[0]);
x_dir[0] = Cross(y_dir[0],loc_z_dir[0]);
}
Point<2> locpoint = profile->GetPoint(0.5);
return p0[0] + locpoint(0)*x_dir[0] + locpoint(1)*loc_z_dir[0];
}
bool ExtrusionFace :: BoxIntersectsFace(const Box<3> & box) const
{
Point<3> center = box.Center();
Project(center);
//(*testout) << "box.Center() " << box.Center() << " projected " << center << " diam " << box.Diam()
// << " dist " << Dist(box.Center(),center) << endl;
return (Dist(box.Center(),center) < 0.5*box.Diam());
}
void ExtrusionFace :: LineIntersections ( const Point<3> & p,
const Vec<3> & v,
const double eps,
int & before,
int & after,
bool & intersecting ) const
{
Point<2> p2d;
Vec<2> v2d;
intersecting = false;
double segt;
int seg;
CalcProj(p,p2d,seg,segt);
if(seg == 0 && segt < 1e-20)
{
Vec<3> v1,v2;
v1 = path->GetSpline(0).GetTangent(0);
v2 = p-p0[seg];
if(v1*v2 < -eps)
return;
}
if(seg == path->GetNSplines()-1 && 1.-segt < 1e-20)
{
Vec<3> v1,v2;
v1 = path->GetSpline(seg).GetTangent(1);
v2 = p-p0[seg];
if(v1*v2 > eps)
return;
}
v2d(0) = v * x_dir[seg];
v2d(1) = v * loc_z_dir[seg];
Vec<2> n(v2d(1),-v2d(0));
ARRAY < Point<2> > ips;
profile->LineIntersections(v2d(1),
-v2d(0),
-v2d(1)*p2d(0) + v2d(0)*p2d(1),
ips,eps);
int comp;
if(fabs(v2d(0)) >= fabs(v2d(1)))
comp = 0;
else
comp = 1;
//(*testout) << "p2d " << p2d;
for(int i=0; i<ips.Size(); i++)
{
//(*testout) << " ip " << ips[i];
double t = (ips[i](comp)-p2d(comp))/v2d(comp);
if(t < -eps)
before++;
else if(t > eps)
after++;
else
intersecting = true;
}
//(*testout) << endl;
}
void ExtrusionFace :: Print (ostream & str) const{}
INSOLID_TYPE ExtrusionFace :: VecInFace ( const Point<3> & p,
const Vec<3> & v,
const double eps ) const
{
Vec<3> normal1;
CalcGradient(p,normal1); normal1.Normalize();
double d1 = normal1*v;
if(d1 > eps)
return IS_OUTSIDE;
if(d1 < -eps)
return IS_INSIDE;
return DOES_INTERSECT;
/*
Point<2> p2d;
double t_path;
int seg;
CalcProj(p,p2d,seg,t_path);
double t;
profile.Project(p2d,p2d,t);
Vec<2> profile_tangent = profile.GetTangent(t);
double d;
Vec<3> normal1;
CalcGradient(p,normal1); normal1.Normalize();
double d1 = normal1*v;
Vec<2> v2d;
v2d(0) = v*x_dir[seg];
v2d(1) = v*loc_z_dir[seg];
Vec<2> normal(-profile_tangent(1),profile_tangent(0));
//d = normal*v2d;
d = d1;
if(d > eps)
return IS_OUTSIDE;
if(d < -eps)
return IS_INSIDE;
return DOES_INTERSECT;
*/
}
void ExtrusionFace :: GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & boundingbox,
double facets) const
{
int n = int(facets) + 1;
int i,j,k;
int nump = 0;
for(k=0; k<path->GetNSplines(); k++)
{
for(i=0; i<=n; i++)
{
Point<3> origin = path->GetSpline(k).GetPoint(double(i)/double(n));
if(!line_path[k])
{
y_dir[k] = path->GetSpline(k).GetTangent(double(i)/double(n));
y_dir[k].Normalize();
}
loc_z_dir[k] = z_dir[k];
Orthogonalize(y_dir[k],loc_z_dir[k]);
if(!line_path[k])
x_dir[k] = Cross(y_dir[k],loc_z_dir[k]);
for(j=0; j<=n; j++)
{
Point<2> locp = profile->GetPoint(double(j)/double(n));
tas.AddPoint(origin + locp(0)*x_dir[k] + locp(1)*loc_z_dir[k]);
nump++;
}
}
}
for(k=0; k<path->GetNSplines(); k++)
for(i=0; i<n; i++)
for(j=0; j<n; j++)
{
int pi = k*(n+1)*(n+1) + (n+1)*i +j;
tas.AddTriangle( TATriangle (0, pi,pi+1,pi+n+1));
tas.AddTriangle( TATriangle (0, pi+1,pi+n+1,pi+n+2));
}
}
void ExtrusionFace :: GetRawData(ARRAY<double> & data) const
{
data.DeleteAll();
profile->GetRawData(data);
path->GetRawData(data);
for(int i=0; i<3; i++)
data.Append(glob_z_direction[i]);
//(*testout) << "written raw data " << data << endl;
}
Extrusion :: Extrusion(const SplineGeometry<3> & path_in,
const SplineGeometry<2> & profile_in,
const Vec<3> & z_dir) :
path(path_in), profile(profile_in), z_direction(z_dir)
{
surfaceactive.SetSize(0);
surfaceids.SetSize(0);
for(int j=0; j<profile.GetNSplines(); j++)
{
ExtrusionFace * face = new ExtrusionFace(&(profile.GetSpline(j)),
&path,
z_direction);
faces.Append(face);
surfaceactive.Append(true);
surfaceids.Append(0);
}
}
Extrusion :: ~Extrusion()
{
for(int i=0; i<faces.Size(); i++)
delete faces[i];
}
INSOLID_TYPE Extrusion :: BoxInSolid (const BoxSphere<3> & box) const
{
for(int i=0; i<faces.Size(); i++)
{
if(faces[i]->BoxIntersectsFace(box))
return DOES_INTERSECT;
}
return PointInSolid(box.Center(),0);
}
INSOLID_TYPE Extrusion :: PointInSolid (const Point<3> & p,
const double eps,
ARRAY<int> * const facenums) const
{
Vec<3> random_vec(-0.4561,0.7382,0.4970247);
int before(0), after(0);
bool intersects(false);
bool does_intersect(false);
for(int i=0; i<faces.Size(); i++)
{
faces[i]->LineIntersections(p,random_vec,eps,before,after,intersects);
//(*testout) << "intersects " << intersects << " before " << before << " after " << after << endl;
if(intersects)
{
if(facenums)
{
facenums->Append(i);
does_intersect = true;
}
else
return DOES_INTERSECT;
}
}
if(does_intersect)
return DOES_INTERSECT;
if(before % 2 == 0)
return IS_OUTSIDE;
return IS_INSIDE;
}
INSOLID_TYPE Extrusion :: PointInSolid (const Point<3> & p,
double eps) const
{
return PointInSolid(p,eps,NULL);
}
INSOLID_TYPE Extrusion :: VecInSolid (const Point<3> & p,
const Vec<3> & v,
double eps) const
{
ARRAY<int> facenums;
INSOLID_TYPE pInSolid = PointInSolid(p,eps,&facenums);
if(pInSolid != DOES_INTERSECT)
return pInSolid;
double d(0);
if(facenums.Size() == 1)
{
Vec<3> normal;
faces[facenums[0]]->CalcGradient(p,normal);
normal.Normalize();
d = normal*v;
latestfacenum = facenums[0];
}
else if (facenums.Size() == 2)
{
Vec<3> checkvec;
Point<3> dummy(p);
faces[facenums[0]]->Project(dummy);
if(fabs(faces[facenums[0]]->GetProfilePar()) < 0.1)
{
int aux = facenums[0];
facenums[0] = facenums[1]; facenums[1] = aux;
}
checkvec = faces[facenums[0]]->GetYDir();
Vec<3> n0, n1;
faces[facenums[0]]->CalcGradient(p,n0);
faces[facenums[1]]->CalcGradient(p,n1);
n0.Normalize();
n1.Normalize();
Vec<3> t = Cross(n0,n1);
if(checkvec*t < 0) t*= (-1.);
Vec<3> t0 = Cross(n0,t);
Vec<3> t1 = Cross(t,n1);
t0.Normalize();
t1.Normalize();
const double t0v = t0*v;
const double t1v = t1*v;
if(t0v > t1v)
{
latestfacenum = facenums[0];
d = n0*v;
}
else
{
latestfacenum = facenums[1];
d = n1*v;
}
if(fabs(t0v) < eps && fabs(t1v) < eps)
latestfacenum = -1;
}
else
{
cerr << "WHY ARE THERE " << facenums.Size() << " FACES?" << endl;
}
if(d > eps)
return IS_OUTSIDE;
if(d < -eps)
return IS_INSIDE;
return DOES_INTERSECT;
}
// checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid
INSOLID_TYPE Extrusion :: VecInSolid2 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const
{
INSOLID_TYPE retval;
retval = VecInSolid(p,v1,eps);
// *testout << "extr, vecinsolid=" << int(retval) << endl;
if(retval != DOES_INTERSECT)
return retval;
if(latestfacenum >= 0)
return faces[latestfacenum]->VecInFace(p,v2,0);
else
return VecInSolid(p,v2,eps);
}
int Extrusion :: GetNSurfaces() const
{
return faces.Size();
}
Surface & Extrusion :: GetSurface (int i)
{
return *faces[i];
}
const Surface & Extrusion :: GetSurface (int i) const
{
return *faces[i];
}
void Extrusion :: Reduce (const BoxSphere<3> & box)
{
for(int i=0; i<faces.Size(); i++)
surfaceactive[i] = faces[i]->BoxIntersectsFace(box);
}
void Extrusion :: UnReduce ()
{
for(int i=0; i<faces.Size(); i++)
surfaceactive[i] = true;
}
}

144
libsrc/csg/extrusion.hpp Normal file
View File

@ -0,0 +1,144 @@
#ifndef _EXTRUSION_HPP
#define _EXTRUSION_HPP
class Extrusion;
class ExtrusionFace : public Surface
{
private:
const SplineSeg<2> * profile;
const SplineGeometry<3> * path;
Vec<3> glob_z_direction;
bool deletable;
ARRAY< const SplineSeg3<3> * > spline3_path;
ARRAY< const LineSeg<3> * > line_path;
mutable ARRAY < Vec<3> > x_dir, y_dir, z_dir, loc_z_dir;
mutable ARRAY < Point<3> > p0;
mutable Vec<3> profile_tangent;
mutable double profile_par;
mutable Vector profile_spline_coeff;
mutable int latest_seg;
mutable double latest_t;
mutable Point<2> latest_point2d;
mutable Point<3> latest_point3d;
private:
void Orthogonalize(const Vec<3> & v1, Vec<3> & v2) const;
void Init(void);
public:
double CalcProj(const Point<3> & point3d, Point<2> & point2d,
const int seg) const;
void CalcProj(const Point<3> & point3d, Point<2> & point2d,
int & seg, double & t) const;
public:
ExtrusionFace(const SplineSeg<2> * profile_in,
const SplineGeometry<3> * path_in,
const Vec<3> & z_direction);
ExtrusionFace(const ARRAY<double> & raw_data);
~ExtrusionFace();
virtual int IsIdentic (const Surface & s2, int & inv, double eps) const;
virtual double CalcFunctionValue (const Point<3> & point) const;
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const;
virtual double HesseNorm () const;
virtual double MaxCurvature () const;
//virtual double MaxCurvatureLoc (const Point<3> & /* c */ ,
// double /* rad */) const;
virtual void Project (Point<3> & p) const;
virtual Point<3> GetSurfacePoint () const;
virtual void Print (ostream & str) const;
virtual void GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & boundingbox,
double facets) const;
const SplineGeometry<3> & GetPath(void) const {return *path;}
const SplineSeg<2> & GetProfile(void) const {return *profile;}
bool BoxIntersectsFace(const Box<3> & box) const;
void LineIntersections ( const Point<3> & p,
const Vec<3> & v,
const double eps,
int & before,
int & after,
bool & intersecting ) const;
INSOLID_TYPE VecInFace ( const Point<3> & p,
const Vec<3> & v,
const double eps ) const;
const Vec<3> & GetYDir ( void ) const {return y_dir[latest_seg];}
const Vec<3> & GetProfileTangent (void) const {return profile_tangent;}
double GetProfilePar(void) const {return profile_par;}
void GetRawData(ARRAY<double> & data) const;
};
class Extrusion : public Primitive
{
private:
const SplineGeometry<3> & path;
const SplineGeometry<2> & profile;
const Vec<3> & z_direction;
ARRAY<ExtrusionFace*> faces;
mutable int latestfacenum;
public:
Extrusion(const SplineGeometry<3> & path_in,
const SplineGeometry<2> & profile_in,
const Vec<3> & z_dir);
~Extrusion();
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
virtual INSOLID_TYPE PointInSolid (const Point<3> & p,
double eps) const;
INSOLID_TYPE PointInSolid (const Point<3> & p,
double eps,
ARRAY<int> * const facenums) const;
virtual INSOLID_TYPE VecInSolid (const Point<3> & p,
const Vec<3> & v,
double eps) const;
// checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid
virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const;
virtual int GetNSurfaces() const;
virtual Surface & GetSurface (int i = 0);
virtual const Surface & GetSurface (int i = 0) const;
virtual void Reduce (const BoxSphere<3> & box);
virtual void UnReduce ();
};
#endif //_EXTRUSION_HPP

209
libsrc/csg/gencyl.cpp Normal file
View File

@ -0,0 +1,209 @@
#include <linalg.hpp>
#include <csg.hpp>
namespace netgen
{
GeneralizedCylinder :: GeneralizedCylinder (ExplicitCurve2d & acrosssection,
Point<3> ap, Vec<3> ae1, Vec<3> ae2)
: crosssection(acrosssection)
{
planep = ap;
planee1 = ae1;
planee2 = ae2;
planee3 = Cross (planee1, planee2);
(*testout) << "Vecs = " << planee1 << " " << planee2 << " " << planee3 << endl;
};
void GeneralizedCylinder :: Project (Point<3> & p) const
{
Point<2> p2d;
double z;
p2d = Point<2> (planee1 * (p - planep), planee2 * (p - planep));
z = planee3 * (p - planep);
crosssection.Project (p2d);
p = planep + p2d(0) * planee1 + p2d(1) * planee2 + z * planee3;
}
int GeneralizedCylinder ::BoxInSolid (const BoxSphere<3> & box) const
{
Point<3> p3d;
Point<2> p2d, projp;
double t;
Vec<2> tan, n;
p3d = box.Center();
p2d = Point<2> (planee1 * (p3d - planep), planee2 * (p3d - planep));
t = crosssection.ProjectParam (p2d);
projp = crosssection.Eval (t);
tan = crosssection.EvalPrime (t);
n(0) = tan(1);
n(1) = -tan(0);
if (Dist (p2d, projp) < box.Diam()/2)
return 2;
if (n * (p2d - projp) > 0)
{
return 0;
}
return 1;
}
double GeneralizedCylinder :: CalcFunctionValue (const Point<3> & point) const
{
Point<2> p2d, projp;
double t;
Vec<2> tan, n;
p2d = Point<2> (planee1 * (point - planep), planee2 * (point - planep));
t = crosssection.ProjectParam (p2d);
projp = crosssection.Eval (t);
tan = crosssection.EvalPrime (t);
n(0) = tan(1);
n(1) = -tan(0);
n /= n.Length();
return n * (p2d - projp);
}
void GeneralizedCylinder :: CalcGradient (const Point<3> & point, Vec<3> & grad) const
{
Point<2> p2d, projp;
double t;
Vec<2> tan, n;
p2d = Point<2> (planee1 * (point - planep), planee2 * (point - planep));
t = crosssection.ProjectParam (p2d);
projp = crosssection.Eval (t);
tan = crosssection.EvalPrime (t);
n(0) = tan(1);
n(1) = -tan(0);
n /= n.Length();
grad = n(0) * planee1 + n(1) * planee2;
}
void GeneralizedCylinder :: CalcHesse (const Point<3> & point, Mat<3> & hesse) const
{
Point<2> p2d, projp;
double t, dist, val;
Point<2> curvp;
Vec<2> curvpp;
Mat<2> h2d;
Mat<3,2> vmat;
int i, j, k, l;
p2d = Point<2> (planee1 * (point - planep), planee2 * (point - planep));
t = crosssection.ProjectParam (p2d);
curvp = crosssection.CurvCircle (t);
curvpp = p2d-curvp;
dist = curvpp.Length();
curvpp /= dist;
h2d(0, 0) = (1 - curvpp(0) * curvpp(0) ) / dist;
h2d(0, 1) = h2d(1, 0) = (- curvpp(0) * curvpp(1) ) / dist;
h2d(1, 1) = (1 - curvpp(1) * curvpp(1) ) / dist;
vmat(0,0) = planee1(0);
vmat(1,0) = planee1(1);
vmat(2,0) = planee1(2);
vmat(0,1) = planee2(0);
vmat(1,1) = planee2(1);
vmat(2,1) = planee2(2);
for (i = 0; i < 3; i++)
for (j = 0; j < 3; j++)
{
val = 0;
for (k = 0; k < 2; k++)
for (l = 0; l < 2; l++)
val += vmat(i,k) * h2d(k,l) * vmat(j,l);
hesse(i,j) = val;
}
}
double GeneralizedCylinder :: HesseNorm () const
{
return crosssection.MaxCurvature();
}
double GeneralizedCylinder :: MaxCurvatureLoc (const Point<3> & c, double rad) const
{
Point<2> c2d = Point<2> (planee1 * (c - planep), planee2 * (c - planep));
return crosssection.MaxCurvatureLoc(c2d, rad);
}
Point<3> GeneralizedCylinder :: GetSurfacePoint () const
{
Point<2> p2d;
p2d = crosssection.Eval(0);
return planep + p2d(0) * planee1 + p2d(1) * planee2;
}
void GeneralizedCylinder :: Reduce (const BoxSphere<3> & box)
{
Point<2> c2d = Point<2> (planee1 * (box.Center() - planep),
planee2 * (box.Center() - planep));
crosssection.Reduce (c2d, box.Diam()/2);
}
void GeneralizedCylinder :: UnReduce ()
{
crosssection.UnReduce ();
}
void GeneralizedCylinder :: Print (ostream & str) const
{
str << "Generalized Cylinder" << endl;
crosssection.Print (str);
}
#ifdef MYGRAPH
void GeneralizedCylinder :: Plot (const class ROT3D & rot) const
{
Point<2> p2d;
Point<3> p, oldp;
double t, tmin, tmax, dt;
tmin = crosssection.MinParam();
tmax = crosssection.MaxParam();
dt = (tmax - tmin)/ 500;
p2d = crosssection.Eval(tmin);
p = planep + p2d(0) * planee1 + p2d(1) * planee2;
for (t = tmin; t <= tmax+dt; t += dt)
{
if (crosssection.SectionUsed (t))
MySetColor (RED);
else
MySetColor (BLUE);
oldp = p;
p2d = crosssection.Eval(t);
p = planep + p2d(0) * planee1 + p2d(1) * planee2;
MyLine3D (p, oldp, rot);
}
}
#endif
}

64
libsrc/csg/gencyl.hpp Normal file
View File

@ -0,0 +1,64 @@
#ifndef FILE_GENCYL
#define FILE_GENCYL
/**************************************************************************/
/* File: gencyl.hh */
/* Author: Joachim Schoeberl */
/* Date: 14. Oct. 96 */
/**************************************************************************/
/*
Generalized Cylinder
*/
///
class GeneralizedCylinder : public Surface
{
///
ExplicitCurve2d & crosssection;
///
Point<3> planep;
///
Vec<3> planee1, planee2, planee3;
/// Vec<3> ex, ey, ez;
Vec2d e2x, e2y;
///
Point<3> cp;
public:
///
GeneralizedCylinder (ExplicitCurve2d & acrosssection,
Point<3> ap, Vec<3> ae1, Vec<3> ae2);
///
virtual void Project (Point<3> & p) const;
///
virtual int BoxInSolid (const BoxSphere<3> & box) const;
/// 0 .. no, 1 .. yes, 2 .. maybe
virtual double CalcFunctionValue (const Point<3> & point) const;
///
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
///
virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const;
///
virtual double HesseNorm () const;
///
virtual double MaxCurvatureLoc (const Point<3> & c, double rad) const;
///
virtual Point<3> GetSurfacePoint () const;
///
virtual void Print (ostream & str) const;
///
virtual void Reduce (const BoxSphere<3> & box);
///
virtual void UnReduce ();
};
#endif

854
libsrc/csg/genmesh.cpp Normal file
View File

@ -0,0 +1,854 @@
#include <mystdlib.h>
#include <myadt.hpp>
#include <linalg.hpp>
#include <csg.hpp>
#include <meshing.hpp>
namespace netgen
{
ARRAY<SpecialPoint> specpoints;
static ARRAY<MeshPoint> spoints;
#define TCL_OK 0
#define TCL_ERROR 1
static void FindPoints (CSGeometry & geom, Mesh & mesh)
{
PrintMessage (1, "Start Findpoints");
const char * savetask = multithread.task;
multithread.task = "Find points";
for (int i = 0; i < geom.GetNUserPoints(); i++)
{
mesh.AddPoint(geom.GetUserPoint (i));
mesh.Points().Last().Singularity (geom.GetUserPointRefFactor(i));
mesh.AddLockedPoint (PointIndex (i+1));
}
SpecialPointCalculation spc;
spc.SetIdEps(geom.GetIdEps());
if (spoints.Size() == 0)
spc.CalcSpecialPoints (geom, spoints);
PrintMessage (2, "Analyze spec points");
spc.AnalyzeSpecialPoints (geom, spoints, specpoints);
PrintMessage (5, "done");
(*testout) << specpoints.Size() << " special points:" << endl;
for (int i = 0; i < specpoints.Size(); i++)
specpoints[i].Print (*testout);
/*
for (int i = 1; i <= geom.identifications.Size(); i++)
geom.identifications.Elem(i)->IdentifySpecialPoints (specpoints);
*/
multithread.task = savetask;
}
static void FindEdges (CSGeometry & geom, Mesh & mesh, const bool setmeshsize = false)
{
EdgeCalculation ec (geom, specpoints);
ec.SetIdEps(geom.GetIdEps());
ec.Calc (mparam.maxh, mesh);
for (int i = 0; i < geom.singedges.Size(); i++)
{
geom.singedges[i]->FindPointsOnEdge (mesh);
if(setmeshsize)
geom.singedges[i]->SetMeshSize(mesh,10.*geom.BoundingBox().Diam());
}
for (int i = 0; i < geom.singpoints.Size(); i++)
geom.singpoints[i]->FindPoints (mesh);
for (int i = 1; i <= mesh.GetNSeg(); i++)
{
//(*testout) << "segment " << mesh.LineSegment(i) << endl;
int ok = 0;
for (int k = 1; k <= mesh.GetNFD(); k++)
if (mesh.GetFaceDescriptor(k).SegmentFits (mesh.LineSegment(i)))
{
ok = k;
//(*testout) << "fits to " << k << endl;
}
if (!ok)
{
ok = mesh.AddFaceDescriptor (FaceDescriptor (mesh.LineSegment(i)));
//(*testout) << "did not find, now " << ok << endl;
}
//(*testout) << "change from " << mesh.LineSegment(i).si;
mesh.LineSegment(i).si = ok;
//(*testout) << " to " << mesh.LineSegment(i).si << endl;
}
if (geom.identifications.Size())
{
PrintMessage (3, "Find Identifications");
for (int i = 0; i < geom.identifications.Size(); i++)
{
geom.identifications[i]->IdentifyPoints (mesh);
//(*testout) << "identification " << i << " is "
// << *geom.identifications[i] << endl;
}
for (int i = 0; i < geom.identifications.Size(); i++)
geom.identifications[i]->IdentifyFaces (mesh);
}
// find intersecting segments
PrintMessage (3, "Check intersecting edges");
Point3d pmin, pmax;
mesh.GetBox (pmin, pmax);
Box3dTree segtree (pmin, pmax);
for (SegmentIndex si = 0; si < mesh.GetNSeg(); si++)
{
if (mesh[si].seginfo)
{
Box<3> hbox;
hbox.Set (mesh[mesh[si].p1]);
hbox.Add (mesh[mesh[si].p2]);
segtree.Insert (hbox.PMin(), hbox.PMax(), si);
}
}
ARRAY<int> loc;
if (!ec.point_on_edge_problem)
for (SegmentIndex si = 0; si < mesh.GetNSeg(); si++)
{
if (!mesh[si].seginfo) continue;
Box<3> hbox;
hbox.Set (mesh[mesh[si].p1]);
hbox.Add (mesh[mesh[si].p2]);
hbox.Increase (1e-6);
segtree.GetIntersecting (hbox.PMin(), hbox.PMax(), loc);
// for (SegmentIndex sj = 0; sj < si; sj++)
for (int j = 0; j < loc.Size(); j++)
{
SegmentIndex sj = loc[j];
if (sj >= si) continue;
if (!mesh[si].seginfo || !mesh[sj].seginfo) continue;
if (mesh[mesh[si].p1].GetLayer() != mesh[mesh[sj].p2].GetLayer()) continue;
Point<3> pi1 = mesh[mesh[si].p1];
Point<3> pi2 = mesh[mesh[si].p2];
Point<3> pj1 = mesh[mesh[sj].p1];
Point<3> pj2 = mesh[mesh[sj].p2];
Vec<3> vi = pi2 - pi1;
Vec<3> vj = pj2 - pj1;
if (sqr (vi * vj) > (1.-1e-6) * Abs2 (vi) * Abs2 (vj)) continue;
// pi1 + vi t = pj1 + vj s
Mat<3,2> mat;
Vec<3> rhs;
Vec<2> sol;
for (int jj = 0; jj < 3; jj++)
{
mat(jj,0) = vi(jj);
mat(jj,1) = -vj(jj);
rhs(jj) = pj1(jj)-pi1(jj);
}
mat.Solve (rhs, sol);
//(*testout) << "mat " << mat << endl << "rhs " << rhs << endl << "sol " << sol << endl;
if (sol(0) > 1e-6 && sol(0) < 1-1e-6 &&
sol(1) > 1e-6 && sol(1) < 1-1e-6 &&
Abs (rhs - mat*sol) < 1e-6)
{
Point<3> ip = pi1 + sol(0) * vi;
//(*testout) << "ip " << ip << endl;
Point<3> pip = ip;
ProjectToEdge (geom.GetSurface (mesh[si].surfnr1),
geom.GetSurface (mesh[si].surfnr2), pip);
//(*testout) << "Dist (ip, pip_si) " << Dist (ip, pip) << endl;
if (Dist (ip, pip) > 1e-6*geom.MaxSize()) continue;
pip = ip;
ProjectToEdge (geom.GetSurface (mesh[sj].surfnr1),
geom.GetSurface (mesh[sj].surfnr2), pip);
//(*testout) << "Dist (ip, pip_sj) " << Dist (ip, pip) << endl;
if (Dist (ip, pip) > 1e-6*geom.MaxSize()) continue;
cout << "Intersection at " << ip << endl;
geom.AddUserPoint (ip);
spoints.Append (MeshPoint (ip, mesh[mesh[si].p1].GetLayer()));
mesh.AddPoint (ip);
(*testout) << "found intersection at " << ip << endl;
(*testout) << "sol = " << sol << endl;
(*testout) << "res = " << (rhs - mat*sol) << endl;
(*testout) << "segs = " << pi1 << " - " << pi2 << endl;
(*testout) << "and = " << pj1 << " - " << pj2 << endl << endl;
}
}
}
}
static void MeshSurface (CSGeometry & geom, Mesh & mesh)
{
const char * savetask = multithread.task;
multithread.task = "Surface meshing";
ARRAY<Segment> segments;
int noldp = mesh.GetNP();
double starttime = GetTime();
// find master faces from identified
ARRAY<int> masterface(mesh.GetNFD());
for (int i = 1; i <= mesh.GetNFD(); i++)
masterface.Elem(i) = i;
ARRAY<INDEX_2> fpairs;
bool changed;
do
{
changed = 0;
for (int i = 0; i < geom.identifications.Size(); i++)
{
geom.identifications[i]->GetIdentifiedFaces (fpairs);
for (int j = 0; j < fpairs.Size(); j++)
{
if (masterface.Get(fpairs[j].I1()) <
masterface.Get(fpairs[j].I2()))
{
changed = 1;
masterface.Elem(fpairs[j].I2()) =
masterface.Elem(fpairs[j].I1());
}
if (masterface.Get(fpairs[j].I2()) <
masterface.Get(fpairs[j].I1()))
{
changed = 1;
masterface.Elem(fpairs[j].I1()) =
masterface.Elem(fpairs[j].I2());
}
}
}
}
while (changed);
int bccnt=0;
for (int k = 0; k < geom.GetNSurf(); k++)
bccnt = max2 (bccnt, geom.GetSurface(k)->GetBCProperty());
for (int k = 1; k <= mesh.GetNFD(); k++)
{
bool increased = false;
FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
const Surface * surf = geom.GetSurface(fd.SurfNr());
if (fd.TLOSurface() &&
geom.GetTopLevelObject(fd.TLOSurface()-1) -> GetBCProp() > 0)
fd.SetBCProperty (geom.GetTopLevelObject(fd.TLOSurface()-1) -> GetBCProp());
else if (surf -> GetBCProperty() != -1)
fd.SetBCProperty (surf->GetBCProperty());
else
{
bccnt++;
fd.SetBCProperty (bccnt);
increased = true;
}
for (int l = 0; l < geom.bcmodifications.Size(); l++)
{
if (geom.GetSurfaceClassRepresentant (fd.SurfNr()) ==
geom.GetSurfaceClassRepresentant (geom.bcmodifications[l].si) &&
(fd.DomainIn() == geom.bcmodifications[l].tlonr+1 ||
fd.DomainOut() == geom.bcmodifications[l].tlonr+1))
{
if(geom.bcmodifications[l].bcname == NULL)
fd.SetBCProperty (geom.bcmodifications[l].bcnr);
else
{
if(!increased)
{
bccnt++;
fd.SetBCProperty (bccnt);
increased = true;
}
}
}
}
}
mesh.SetNBCNames( bccnt );
for (int k = 1; k <= mesh.GetNFD(); k++)
{
FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
const Surface * surf = geom.GetSurface(fd.SurfNr());
if (fd.TLOSurface() )
{
int bcp = fd.BCProperty();
string nextbcname = geom.GetTopLevelObject(fd.TLOSurface()-1) -> GetBCName();
if ( nextbcname != "default" )
mesh.SetBCName ( bcp - 1 , nextbcname );
}
else // if (surf -> GetBCProperty() != -1)
{
int bcp = fd.BCProperty();
string nextbcname = surf->GetBCName();
if ( nextbcname != "default" )
mesh.SetBCName ( bcp - 1, nextbcname );
}
}
for (int k = 1; k <= mesh.GetNFD(); k++)
{
FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
fd.SetBCName ( mesh.GetBCNamePtr ( fd.BCProperty() - 1 ) );
}
//!!
for (int k = 1; k <= mesh.GetNFD(); k++)
{
FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
//const Surface * surf = geom.GetSurface(fd.SurfNr());
for (int l = 0; l < geom.bcmodifications.Size(); l++)
{
if (geom.GetSurfaceClassRepresentant (fd.SurfNr()) ==
geom.GetSurfaceClassRepresentant (geom.bcmodifications[l].si) &&
(fd.DomainIn() == geom.bcmodifications[l].tlonr+1 ||
fd.DomainOut() == geom.bcmodifications[l].tlonr+1) &&
geom.bcmodifications[l].bcname != NULL
)
{
int bcp = fd.BCProperty();
mesh.SetBCName ( bcp - 1, *(geom.bcmodifications[l].bcname) );
fd.SetBCName ( mesh.GetBCNamePtr ( bcp - 1) );
}
}
}
for(int k = 0; k<geom.bcmodifications.Size(); k++)
{
delete geom.bcmodifications[k].bcname;
geom.bcmodifications[k].bcname = NULL;
}
//!!
for (int j = 0; j < geom.singfaces.Size(); j++)
{
ARRAY<int> surfs;
geom.GetIndependentSurfaceIndices (geom.singfaces[j]->GetSolid(),
geom.BoundingBox(), surfs);
for (int k = 1; k <= mesh.GetNFD(); k++)
{
FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
for (int l = 0; l < surfs.Size(); l++)
if (surfs[l] == fd.SurfNr())
{
if (geom.singfaces[j]->GetDomainNr() == fd.DomainIn())
fd.domin_singular = 1;
if (geom.singfaces[j]->GetDomainNr() == fd.DomainOut())
fd.domout_singular = 1;
}
}
}
// assemble edge hash-table
mesh.CalcSurfacesOfNode();
for (int k = 1; k <= mesh.GetNFD(); k++)
{
multithread.percent = 100.0 * k / (mesh.GetNFD()+1e-10);
if (masterface.Get(k) != k)
continue;
FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
(*testout) << "Surface " << k << endl;
(*testout) << "Face Descriptor: " << fd << endl;
PrintMessage (1, "Surface ", k, " / ", mesh.GetNFD());
int oldnf = mesh.GetNSE();
const Surface * surf =
geom.GetSurface((mesh.GetFaceDescriptor(k).SurfNr()));
Meshing2Surfaces meshing(*surf, geom.BoundingBox());
meshing.SetStartTime (starttime);
for (PointIndex pi = PointIndex::BASE; pi < noldp+PointIndex::BASE; pi++)
{
//if(surf->PointOnSurface(mesh[pi]))
meshing.AddPoint (mesh[pi], pi, NULL,
(surf->PointOnSurface(mesh[pi])!=0));
}
segments.SetSize (0);
for (SegmentIndex si = 0; si < mesh.GetNSeg(); si++)
if (mesh[si].si == k)
{
segments.Append (mesh[si]);
(*testout) << "appending segment " << mesh[si] << endl;
//<< " from " << mesh[mesh[si][0]]
// << " to " <<mesh[mesh[si][1]]<< endl;
}
(*testout) << "num-segments " << segments.Size() << endl;
for (int i = 1; i <= geom.identifications.Size(); i++)
{
geom.identifications.Get(i)->
BuildSurfaceElements(segments, mesh, surf);
}
for (int si = 0; si < segments.Size(); si++)
{
PointGeomInfo gi;
gi.trignum = k;
meshing.AddBoundaryElement (segments[si].p1 + 1 - PointIndex::BASE,
segments[si].p2 + 1 - PointIndex::BASE,
gi, gi);
}
double maxh = mparam.maxh;
if (fd.DomainIn() != 0)
{
const Solid * s1 =
geom.GetTopLevelObject(fd.DomainIn()-1) -> GetSolid();
if (s1->GetMaxH() < maxh)
maxh = s1->GetMaxH();
maxh = min2(maxh, geom.GetTopLevelObject(fd.DomainIn()-1)->GetMaxH());
}
if (fd.DomainOut() != 0)
{
const Solid * s1 =
geom.GetTopLevelObject(fd.DomainOut()-1) -> GetSolid();
if (s1->GetMaxH() < maxh)
maxh = s1->GetMaxH();
maxh = min2(maxh, geom.GetTopLevelObject(fd.DomainOut()-1)->GetMaxH());
}
if (fd.TLOSurface() != 0)
{
double hi = geom.GetTopLevelObject(fd.TLOSurface()-1) -> GetMaxH();
if (hi < maxh) maxh = hi;
}
(*testout) << "domin = " << fd.DomainIn() << ", domout = " << fd.DomainOut()
<< ", tlo-surf = " << fd.TLOSurface()
<< " mpram.maxh = " << mparam.maxh << ", maxh = " << maxh << endl;
mparam.checkoverlap = 0;
MESHING2_RESULT res =
meshing.GenerateMesh (mesh, maxh, k);
if (res != MESHING2_OK)
{
PrintError ("Problem in Surface mesh generation");
throw NgException ("Problem in Surface mesh generation");
}
if (multithread.terminate) return;
for (int i = oldnf+1; i <= mesh.GetNSE(); i++)
mesh.SurfaceElement(i).SetIndex (k);
// mesh.CalcSurfacesOfNode();
if (segments.Size())
{
// surface was meshed, not copied
PrintMessage (2, "Optimize Surface");
for (int i = 1; i <= mparam.optsteps2d; i++)
{
if (multithread.terminate) return;
{
MeshOptimize2dSurfaces meshopt(geom);
meshopt.SetFaceIndex (k);
meshopt.SetImproveEdges (0);
meshopt.SetMetricWeight (mparam.elsizeweight);
meshopt.SetWriteStatus (0);
meshopt.EdgeSwapping (mesh, (i > mparam.optsteps2d/2));
}
if (multithread.terminate) return;
{
// mesh.CalcSurfacesOfNode();
MeshOptimize2dSurfaces meshopt(geom);
meshopt.SetFaceIndex (k);
meshopt.SetImproveEdges (0);
meshopt.SetMetricWeight (mparam.elsizeweight);
meshopt.SetWriteStatus (0);
meshopt.ImproveMesh (mesh);
}
{
MeshOptimize2dSurfaces meshopt(geom);
meshopt.SetFaceIndex (k);
meshopt.SetImproveEdges (0);
meshopt.SetMetricWeight (mparam.elsizeweight);
meshopt.SetWriteStatus (0);
meshopt.CombineImprove (mesh);
// mesh.CalcSurfacesOfNode();
}
if (multithread.terminate) return;
{
MeshOptimize2dSurfaces meshopt(geom);
meshopt.SetFaceIndex (k);
meshopt.SetImproveEdges (0);
meshopt.SetMetricWeight (mparam.elsizeweight);
meshopt.SetWriteStatus (0);
meshopt.ImproveMesh (mesh);
}
}
}
PrintMessage (3, (mesh.GetNSE() - oldnf), " elements, ", mesh.GetNP(), " points");
#ifdef OPENGL
extern void Render();
Render();
#endif
}
mesh.Compress();
do
{
changed = 0;
for (int k = 1; k <= mesh.GetNFD(); k++)
{
multithread.percent = 100.0 * k / (mesh.GetNFD()+1e-10);
if (masterface.Get(k) == k)
continue;
FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
(*testout) << "Surface " << k << endl;
(*testout) << "Face Descriptor: " << fd << endl;
PrintMessage (2, "Surface ", k);
int oldnf = mesh.GetNSE();
const Surface * surf =
geom.GetSurface((mesh.GetFaceDescriptor(k).SurfNr()));
/*
if (surf -> GetBCProperty() != -1)
fd.SetBCProperty (surf->GetBCProperty());
else
{
bccnt++;
fd.SetBCProperty (bccnt);
}
*/
segments.SetSize (0);
for (int i = 1; i <= mesh.GetNSeg(); i++)
{
Segment * seg = &mesh.LineSegment(i);
if (seg->si == k)
segments.Append (*seg);
}
for (int i = 1; i <= geom.identifications.Size(); i++)
{
geom.identifications.Elem(i)->GetIdentifiedFaces (fpairs);
int found = 0;
for (int j = 1; j <= fpairs.Size(); j++)
if (fpairs.Get(j).I1() == k || fpairs.Get(j).I2() == k)
found = 1;
if (!found)
continue;
geom.identifications.Get(i)->
BuildSurfaceElements(segments, mesh, surf);
if (!segments.Size())
break;
}
if (multithread.terminate) return;
for (int i = oldnf+1; i <= mesh.GetNSE(); i++)
mesh.SurfaceElement(i).SetIndex (k);
if (!segments.Size())
{
masterface.Elem(k) = k;
changed = 1;
}
PrintMessage (3, (mesh.GetNSE() - oldnf), " elements, ", mesh.GetNP(), " points");
}
#ifdef OPENGL
extern void Render();
Render();
#endif
}
while (changed);
mesh.SplitSeparatedFaces();
mesh.CalcSurfacesOfNode();
multithread.task = savetask;
}
int GenerateMesh (CSGeometry & geom,
Mesh *& mesh,
int perfstepsstart, int perfstepsend,
const char * optstr)
{
if (mesh && mesh->GetNSE() &&
!geom.GetNSolids())
{
if (perfstepsstart < MESHCONST_MESHVOLUME)
perfstepsstart = MESHCONST_MESHVOLUME;
}
if (perfstepsstart <= MESHCONST_ANALYSE)
{
delete mesh;
mesh = new Mesh();
mesh->SetGlobalH (mparam.maxh);
mesh->SetMinimalH (mparam.minh);
ARRAY<double> maxhdom(geom.GetNTopLevelObjects());
for (int i = 0; i < maxhdom.Size(); i++)
maxhdom[i] = geom.GetTopLevelObject(i)->GetMaxH();
mesh->SetMaxHDomain (maxhdom);
if (mparam.uselocalh)
{
double maxsize = geom.MaxSize();
mesh->SetLocalH (Point<3>(-maxsize, -maxsize, -maxsize),
Point<3>(maxsize, maxsize, maxsize),
mparam.grading);
mesh -> LoadLocalMeshSize (mparam.meshsizefilename);
}
spoints.SetSize(0);
FindPoints (geom, *mesh);
PrintMessage (5, "find points done");
#ifdef LOG_STREAM
(*logout) << "Special points found" << endl
<< "time = " << GetTime() << " sec" << endl
<< "points: " << mesh->GetNP() << endl << endl;
#endif
}
if (multithread.terminate || perfstepsend <= MESHCONST_ANALYSE)
return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHEDGES)
{
FindEdges (geom, *mesh, true);
if (multithread.terminate) return TCL_OK;
#ifdef LOG_STREAM
(*logout) << "Edges meshed" << endl
<< "time = " << GetTime() << " sec" << endl
<< "points: " << mesh->GetNP() << endl;
#endif
if (multithread.terminate)
return TCL_OK;
if (mparam.uselocalh)
{
mesh->CalcLocalH();
mesh->DeleteMesh();
FindPoints (geom, *mesh);
if (multithread.terminate) return TCL_OK;
FindEdges (geom, *mesh, true);
if (multithread.terminate) return TCL_OK;
mesh->DeleteMesh();
FindPoints (geom, *mesh);
if (multithread.terminate) return TCL_OK;
FindEdges (geom, *mesh);
if (multithread.terminate) return TCL_OK;
}
}
if (multithread.terminate || perfstepsend <= MESHCONST_MESHEDGES)
return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHSURFACE)
{
MeshSurface (geom, *mesh);
if (multithread.terminate) return TCL_OK;
#ifdef LOG_STREAM
(*logout) << "Surfaces meshed" << endl
<< "time = " << GetTime() << " sec" << endl
<< "points: " << mesh->GetNP() << endl;
#endif
if (mparam.uselocalh && 0)
{
mesh->CalcLocalH();
mesh->DeleteMesh();
FindPoints (geom, *mesh);
if (multithread.terminate) return TCL_OK;
FindEdges (geom, *mesh);
if (multithread.terminate) return TCL_OK;
MeshSurface (geom, *mesh);
if (multithread.terminate) return TCL_OK;
}
#ifdef LOG_STREAM
(*logout) << "Surfaces remeshed" << endl
<< "time = " << GetTime() << " sec" << endl
<< "points: " << mesh->GetNP() << endl;
#endif
#ifdef STAT_STREAM
(*statout) << mesh->GetNSeg() << " & "
<< mesh->GetNSE() << " & - &"
<< GetTime() << " & " << endl;
#endif
MeshQuality2d (*mesh);
mesh->CalcSurfacesOfNode();
}
if (multithread.terminate || perfstepsend <= MESHCONST_OPTSURFACE)
return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHVOLUME)
{
multithread.task = "Volume meshing";
MESHING3_RESULT res =
MeshVolume (mparam, *mesh);
if (res != MESHING3_OK) return TCL_ERROR;
if (multithread.terminate) return TCL_OK;
RemoveIllegalElements (*mesh);
if (multithread.terminate) return TCL_OK;
MeshQuality3d (*mesh);
for (int i = 0; i < geom.GetNTopLevelObjects(); i++)
mesh->SetMaterial (i+1, geom.GetTopLevelObject(i)->GetMaterial().c_str());
#ifdef STAT_STREAM
(*statout) << GetTime() << " & ";
#endif
#ifdef LOG_STREAM
(*logout) << "Volume meshed" << endl
<< "time = " << GetTime() << " sec" << endl
<< "points: " << mesh->GetNP() << endl;
#endif
}
if (multithread.terminate || perfstepsend <= MESHCONST_MESHVOLUME)
return TCL_OK;
if (perfstepsstart <= MESHCONST_OPTVOLUME)
{
multithread.task = "Volume optimization";
OptimizeVolume (mparam, *mesh);
if (multithread.terminate) return TCL_OK;
#ifdef STAT_STREAM
(*statout) << GetTime() << " & "
<< mesh->GetNE() << " & "
<< mesh->GetNP() << " " << '\\' << '\\' << " \\" << "hline" << endl;
#endif
#ifdef LOG_STREAM
(*logout) << "Volume optimized" << endl
<< "time = " << GetTime() << " sec" << endl
<< "points: " << mesh->GetNP() << endl;
#endif
}
return TCL_OK;
}
}

16
libsrc/csg/geoml.hpp Normal file
View File

@ -0,0 +1,16 @@
#ifndef FILE_GEOML
#define FILE_GEOML
/* *************************************************************************/
/* File: geoml.hh */
/* Author: Joachim Schoeberl */
/* Date: 21. Jun. 98 */
/* *************************************************************************/
#include <geom/geom.hh>
#include <geom/solid.hh>
#include <geom/algprim.hh>
#include <geom/adtree.hh>
#include <geom/csgeom.hh>
#endif

1672
libsrc/csg/identify.cpp Normal file

File diff suppressed because it is too large Load Diff

204
libsrc/csg/identify.hpp Normal file
View File

@ -0,0 +1,204 @@
#ifndef FILE_IDENTIFY
#define FILE_IDENTIFY
/**************************************************************************/
/* File: identify.hh */
/* Author: Joachim Schoeberl */
/* Date: 1. Aug. 99 */
/**************************************************************************/
/**
Identify surfaces for periodic b.c. or
thin domains
*/
class SpecialPoint;
class Identification
{
protected:
const CSGeometry & geom;
// identified faces, index sorted
INDEX_2_HASHTABLE<int> identfaces;
int nr;
public:
Identification (int anr, const CSGeometry & ageom);
virtual ~Identification ();
virtual void Print (ostream & ost) const = 0;
virtual void GetData (ostream & ost) const = 0;
/// obsolete
// virtual void IdentifySpecialPoints (ARRAY<class SpecialPoint> & points);
/// can identify both special points (fixed direction)
/// (identified points, same tangent)
virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2,
const TABLE<int> & specpoint2solid,
const TABLE<int> & specpoint2surface) const;
///
virtual int Identifyable (const Point<3> & p1, const Point<3> & sp2) const;
/// is it possible to identify sp1 with some other ?
virtual int IdentifyableCandidate (const SpecialPoint & sp1) const;
/// are points (if connected) by a short edge (direction anyhow) ?
virtual int ShortEdge (const SpecialPoint & sp1, const SpecialPoint & sp2) const;
/// add entries in mesh identification tables
virtual void IdentifyPoints (class Mesh & mesh);
/// add entries to identified faces (based on segment infos)
virtual void IdentifyFaces (class Mesh & mesh);
/// get point on other surface, add entry in mesh identifications
virtual int GetIdentifiedPoint (class Mesh & mesh, int pi1);
/// copy surfaces, or fill rectangles
virtual void BuildSurfaceElements (ARRAY<class Segment> & segs,
class Mesh & mesh,
const Surface * surf);
/// insert volume elements in thin layers
virtual void BuildVolumeElements (ARRAY<class Element2d> & surfels,
class Mesh & mesh);
/// get list of identified faces
virtual void GetIdentifiedFaces (ARRAY<INDEX_2> & idfaces) const;
friend ostream & operator<< (ostream & ost, Identification & ident);
};
class PeriodicIdentification : public Identification
{
const Surface * s1;
const Surface * s2;
public:
PeriodicIdentification (int anr,
const CSGeometry & ageom,
const Surface * as1,
const Surface * as2);
virtual ~PeriodicIdentification ();
virtual void Print (ostream & ost) const;
virtual void GetData (ostream & ost) const;
// virtual void IdentifySpecialPoints (ARRAY<class SpecialPoint> & points);
virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2,
const TABLE<int> & specpoint2solid,
const TABLE<int> & specpoint2surface) const;
virtual int Identifyable (const Point<3> & p1, const Point<3> & sp2) const;
virtual int GetIdentifiedPoint (class Mesh & mesh, int pi1);
virtual void IdentifyPoints (class Mesh & mesh);
virtual void IdentifyFaces (class Mesh & mesh);
virtual void BuildSurfaceElements (ARRAY<class Segment> & segs,
class Mesh & mesh,
const Surface * surf);
};
///
class TopLevelObject;
class CloseSurfaceIdentification : public Identification
{
const Surface * s1;
const Surface * s2;
const TopLevelObject * domain;
///
int dom_nr;
/// number of refinement levels (in Z-refinement)
int ref_levels;
/// number of refinement levels for layer next to s1 (in Z-refinement)
int ref_levels_s1;
/// number of refinement levels for layer next to s2 (in Z-refinement)
int ref_levels_s2;
///
double eps_n;
ARRAY<double> slices;
/// used only for domain-local identification:
ARRAY<int> domain_surfaces;
///
bool dom_surf_valid;
///
Vec<3> direction;
///
bool usedirection;
public:
CloseSurfaceIdentification (int anr,
const CSGeometry & ageom,
const Surface * as1,
const Surface * as2,
const TopLevelObject * adomain,
const Flags & flags);
virtual ~CloseSurfaceIdentification ();
virtual void Print (ostream & ost) const;
virtual void GetData (ostream & ost) const;
// virtual void IdentifySpecialPoints (ARRAY<class SpecialPoint> & points);
virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2,
const TABLE<int> & specpoint2solid,
const TABLE<int> & specpoint2surface) const;
virtual int Identifyable (const Point<3> & p1, const Point<3> & sp2) const;
virtual int IdentifyableCandidate (const SpecialPoint & sp1) const;
virtual int ShortEdge (const SpecialPoint & sp1, const SpecialPoint & sp2) const;
virtual int GetIdentifiedPoint (class Mesh & mesh, int pi1);
const ARRAY<double> & GetSlices () const { return slices; }
virtual void IdentifyPoints (class Mesh & mesh);
virtual void IdentifyFaces (class Mesh & mesh);
virtual void BuildSurfaceElements (ARRAY<class Segment> & segs,
class Mesh & mesh,
const Surface * surf);
void BuildSurfaceElements2 (ARRAY<class Segment> & segs,
class Mesh & mesh,
const Surface * surf);
virtual void BuildVolumeElements (ARRAY<class Element2d> & surfels,
class Mesh & mesh);
int RefLevels () const { return ref_levels; }
int RefLevels1 () const { return ref_levels_s1; }
int RefLevels2 () const { return ref_levels_s2; }
bool IsSkewIdentification(void) const {return usedirection;}
const Vec<3> & GetDirection(void) const {return direction;}
const Surface & GetSurface1(void) const
{ return *s1;}
const Surface & GetSurface2(void) const
{ return *s2;}
};
class CloseEdgesIdentification : public Identification
{
const Surface * facet;
const Surface * s1;
const Surface * s2;
public:
CloseEdgesIdentification (int anr,
const CSGeometry & ageom,
const Surface * afacet,
const Surface * as1,
const Surface * as2);
virtual ~CloseEdgesIdentification ();
virtual void Print (ostream & ost) const;
virtual void GetData (ostream & ost) const;
// virtual void IdentifySpecialPoints (ARRAY<class SpecialPoint> & points);
virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2,
const TABLE<int> & specpoint2solid,
const TABLE<int> & specpoint2surface) const;
virtual void IdentifyPoints (class Mesh & mesh);
virtual void BuildSurfaceElements (ARRAY<class Segment> & segs,
class Mesh & mesh,
const Surface * surf);
};
#endif

14
libsrc/csg/manifold.cpp Normal file
View File

@ -0,0 +1,14 @@
#include <csg.hpp>
namespace netgen
{
Manifold :: Manifold ()
{
;
}
Manifold :: ~Manifold ()
{
;
}
}

22
libsrc/csg/manifold.hpp Normal file
View File

@ -0,0 +1,22 @@
#ifndef FILE_MANIFOLD
#define FILE_MANIFOLD
/**************************************************************************/
/* File: manifold.hh */
/* Author: Joachim Schoeberl */
/* Date: 7. Aug. 96 */
/**************************************************************************/
/**
Basis class for manifolds in 2d and 3d
*/
class Manifold
{
public:
///
Manifold ();
///
virtual ~Manifold ();
};
#endif

210
libsrc/csg/meshsurf.cpp Normal file
View File

@ -0,0 +1,210 @@
#include <mystdlib.h>
#include <csg.hpp>
#include <meshing.hpp>
namespace netgen
{
/*
Meshing2Surfaces :: Meshing2Surfaces (const Surface & asurface)
: surface(asurface)
{
;
}
*/
Meshing2Surfaces :: Meshing2Surfaces (const Surface & asurf,
const Box<3> & abb)
: Meshing2(abb), surface(asurf)
{
;
}
void Meshing2Surfaces :: DefineTransformation (const Point3d & p1, const Point3d & p2,
const PointGeomInfo * geominfo1,
const PointGeomInfo * geominfo2)
{
((Surface&)surface).DefineTangentialPlane (p1, p2);
}
void Meshing2Surfaces :: TransformToPlain (const Point3d & locpoint,
const MultiPointGeomInfo & geominfo,
Point2d & planepoint,
double h, int & zone)
{
Point<2> hp;
surface.ToPlane (locpoint, hp, h, zone);
planepoint.X() = hp(0);
planepoint.Y() = hp(1);
}
int Meshing2Surfaces :: TransformFromPlain (Point2d & planepoint,
Point3d & locpoint,
PointGeomInfo & gi,
double h)
{
Point<3> hp;
Point<2> hp2 (planepoint.X(), planepoint.Y());
surface.FromPlane (hp2, hp, h);
locpoint = hp;
gi.trignum = 1;
return 0;
}
double Meshing2Surfaces :: CalcLocalH (const Point3d & p, double gh) const
{
return surface.LocH (p, 3, 1, gh);
/*
double loch = mesh.lochfunc->GetH(p);
if (gh < loch) loch = gh;
return loch;
*/
}
MeshOptimize2dSurfaces :: MeshOptimize2dSurfaces (const CSGeometry & ageometry)
: MeshOptimize2d(), geometry(ageometry)
{
;
}
void MeshOptimize2dSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const
{
Point<3> hp = p;
geometry.GetSurface(surfind)->Project (hp);
p = hp;
}
void MeshOptimize2dSurfaces :: ProjectPoint2 (INDEX surfind, INDEX surfind2,
Point<3> & p) const
{
Point<3> hp = p;
ProjectToEdge ( geometry.GetSurface(surfind),
geometry.GetSurface(surfind2), hp);
p = hp;
}
void MeshOptimize2dSurfaces ::
GetNormalVector(INDEX surfind, const Point<3> & p, Vec<3> & n) const
{
Vec<3> hn = n;
geometry.GetSurface(surfind)->CalcGradient (p, hn);
hn.Normalize();
n = hn;
/*
if (geometry.GetSurface(surfind)->Inverse())
n *= -1;
*/
}
RefinementSurfaces :: RefinementSurfaces (const CSGeometry & ageometry)
: Refinement(), geometry(ageometry)
{
if(geometry.GetNSurf() == 0)
*testout << endl
<< "WARNING: Intializing 2D refinement with 0-surface geometry" << endl
<< "==========================================================" << endl
<< endl << endl;
}
RefinementSurfaces :: ~RefinementSurfaces ()
{
;
}
void RefinementSurfaces ::
PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi,
const PointGeomInfo & gi1,
const PointGeomInfo & gi2,
Point<3> & newp, PointGeomInfo & newgi)
{
Point<3> hnewp;
hnewp = p1+secpoint*(p2-p1);
if (surfi != -1)
{
geometry.GetSurface (surfi) -> Project (hnewp);
newgi.trignum = 1;
}
newp = hnewp;
}
void RefinementSurfaces ::
PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi1, int surfi2,
const EdgePointGeomInfo & ap1,
const EdgePointGeomInfo & ap2,
Point<3> & newp, EdgePointGeomInfo & newgi)
{
Point<3> hnewp = p1+secpoint*(p2-p1);
//(*testout) << "hnewp " << hnewp << " s1 " << surfi1 << " s2 " << surfi2 << endl;
if (surfi1 != -1 && surfi2 != -1 && surfi1 != surfi2)
{
netgen::ProjectToEdge (geometry.GetSurface(surfi1),
geometry.GetSurface(surfi2),
hnewp);
// (*testout) << "Pointbetween, newp = " << hnewp << endl
// << ", err = " << sqrt (sqr (hnewp(0))+ sqr(hnewp(1)) + sqr (hnewp(2))) - 1 << endl;
newgi.edgenr = 1;
//(*testout) << "hnewp (a1) " << hnewp << endl;
}
else if (surfi1 != -1)
{
geometry.GetSurface (surfi1) -> Project (hnewp);
//(*testout) << "hnewp (a2) " << hnewp << endl;
}
newp = hnewp;
};
Vec<3> RefinementSurfaces :: GetTangent (const Point<3> & p, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1) const
{
Vec<3> n1 = geometry.GetSurface (surfi1)->GetNormalVector (p);
Vec<3> n2 = geometry.GetSurface (surfi2)->GetNormalVector (p);
Vec<3> tau = Cross (n1, n2).Normalize();
return tau;
}
Vec<3> RefinementSurfaces :: GetNormal (const Point<3> & p, int surfi1,
const PointGeomInfo & gi) const
{
return geometry.GetSurface (surfi1)->GetNormalVector (p);
}
void RefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi)
{
if (surfi != -1)
geometry.GetSurface (surfi) -> Project (p);
};
void RefinementSurfaces :: ProjectToEdge (Point<3> & p, int surfi1, int surfi2, const EdgePointGeomInfo & egi) const
{
netgen::ProjectToEdge (geometry.GetSurface(surfi1),
geometry.GetSurface(surfi2),
p);
}
}

95
libsrc/csg/meshsurf.hpp Normal file
View File

@ -0,0 +1,95 @@
#ifndef FILE_MESHSURF
#define FILE_MESHSURF
///
class Meshing2Surfaces : public Meshing2
{
///
const Surface & surface;
public:
///
// Meshing2Surfaces (const Surface & asurf);
///
Meshing2Surfaces (const Surface & asurf, const Box<3> & aboundingbox);
protected:
///
virtual void DefineTransformation (const Point3d & p1, const Point3d & p2,
const PointGeomInfo * geominfo1,
const PointGeomInfo * geominfo2);
///
virtual void TransformToPlain (const Point3d & locpoint,
const MultiPointGeomInfo & geominfo,
Point2d & plainpoint,
double h, int & zone);
///
virtual int TransformFromPlain (Point2d & plainpoint,
Point3d & locpoint,
PointGeomInfo & gi,
double h);
///
virtual double CalcLocalH (const Point3d & p, double gh) const;
};
///
class MeshOptimize2dSurfaces : public MeshOptimize2d
{
///
const CSGeometry & geometry;
public:
///
MeshOptimize2dSurfaces (const CSGeometry & ageometry);
///
virtual void ProjectPoint (INDEX surfind, Point<3> & p) const;
///
virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point<3> & p) const;
///
virtual void GetNormalVector(INDEX surfind, const Point<3> & p, Vec<3> & n) const;
};
class RefinementSurfaces : public Refinement
{
const CSGeometry & geometry;
public:
RefinementSurfaces (const CSGeometry & ageometry);
virtual ~RefinementSurfaces ();
virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi,
const PointGeomInfo & gi1,
const PointGeomInfo & gi2,
Point<3> & newp, PointGeomInfo & newgi);
virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi1, int surfi2,
const EdgePointGeomInfo & ap1,
const EdgePointGeomInfo & ap2,
Point<3> & newp, EdgePointGeomInfo & newgi);
virtual Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1) const;
virtual Vec<3> GetNormal (const Point<3> & p, int surfi1,
const PointGeomInfo & gi) const;
virtual void ProjectToSurface (Point<3> & p, int surfi);
virtual void ProjectToEdge (Point<3> & p, int surfi1, int surfi2, const EdgePointGeomInfo & egi) const;
};
#endif

738
libsrc/csg/polyhedra.cpp Normal file
View File

@ -0,0 +1,738 @@
#include <mystdlib.h>
#include <linalg.hpp>
#include <csg.hpp>
namespace netgen
{
Polyhedra::Face::Face (int pi1, int pi2, int pi3,
const ARRAY<Point<3> > & points,
int ainputnr)
{
inputnr = ainputnr;
pnums[0] = pi1;
pnums[1] = pi2;
pnums[2] = pi3;
bbox.Set (points[pi1]);
bbox.Add (points[pi2]);
bbox.Add (points[pi3]);
v1 = points[pi2] - points[pi1];
v2 = points[pi3] - points[pi1];
n = Cross (v1, v2);
nn = n;
nn.Normalize();
// PseudoInverse (v1, v2, w1, w2);
Mat<2,3> mat;
Mat<3,2> inv;
for (int i = 0; i < 3; i++)
{
mat(0,i) = v1(i);
mat(1,i) = v2(i);
}
CalcInverse (mat, inv);
for (int i = 0; i < 3; i++)
{
w1(i) = inv(i,0);
w2(i) = inv(i,1);
}
}
Polyhedra :: Polyhedra ()
{
surfaceactive.SetSize(0);
surfaceids.SetSize(0);
eps_base1 = 1e-8;
}
Polyhedra :: ~Polyhedra ()
{
;
}
Primitive * Polyhedra :: CreateDefault ()
{
return new Polyhedra();
}
INSOLID_TYPE Polyhedra :: BoxInSolid (const BoxSphere<3> & box) const
{
/*
for (i = 1; i <= faces.Size(); i++)
if (FaceBoxIntersection (i, box))
return DOES_INTERSECT;
*/
for (int i = 0; i < faces.Size(); i++)
{
if (!faces[i].bbox.Intersect (box))
continue;
//(*testout) << "face " << i << endl;
const Point<3> & p1 = points[faces[i].pnums[0]];
const Point<3> & p2 = points[faces[i].pnums[1]];
const Point<3> & p3 = points[faces[i].pnums[2]];
if (fabs (faces[i].nn * (p1 - box.Center())) > box.Diam()/2)
continue;
//(*testout) << "still in loop" << endl;
double dist2 = MinDistTP2 (p1, p2, p3, box.Center());
//(*testout) << "p1 " << p1 << " p2 " << p2 << " p3 " << p3 << endl
// << " box.Center " << box.Center() << " box.Diam() " << box.Diam() << endl
// << " dist2 " << dist2 << " sqr(box.Diam()/2) " << sqr(box.Diam()/2) << endl;
if (dist2 < sqr (box.Diam()/2))
{
//(*testout) << "DOES_INTERSECT" << endl;
return DOES_INTERSECT;
}
};
return PointInSolid (box.Center(), 1e-3 * box.Diam());
}
INSOLID_TYPE Polyhedra :: PointInSolid (const Point<3> & p,
double eps) const
{
//(*testout) << "PointInSolid p " << p << " eps " << eps << endl;
//(*testout) << "bbox " << poly_bbox << endl;
if((p(0) > poly_bbox.PMax()(0) + eps) || (p(0) < poly_bbox.PMin()(0) - eps) ||
(p(1) > poly_bbox.PMax()(1) + eps) || (p(1) < poly_bbox.PMin()(1) - eps) ||
(p(2) > poly_bbox.PMax()(2) + eps) || (p(2) < poly_bbox.PMin()(2) - eps))
{
//(*testout) << "returning IS_OUTSIDE" << endl;
return IS_OUTSIDE;
}
Vec<3> n, v1, v2;
// random (?) numbers:
n(0) = -0.424621;
n(1) = 0.15432;
n(2) = 0.89212238;
int cnt = 0;
for (int i = 0; i < faces.Size(); i++)
{
const Point<3> & p1 = points[faces[i].pnums[0]];
Vec<3> v0 = p - p1;
double lam3 = faces[i].nn * v0;
if(fabs(lam3) < eps)
{
double lam1 = (faces[i].w1 * v0);
double lam2 = (faces[i].w2 * v0);
if (lam1 >= -eps_base1 && lam2 >= -eps_base1 && lam1+lam2 <= 1+eps_base1)
{
//(*testout) << "returning DOES_INTERSECT" << endl;
return DOES_INTERSECT;
}
}
else
{
lam3 = -(faces[i].n * v0) / (faces[i].n * n);
if (lam3 < 0) continue;
Vec<3> rs = v0 + lam3 * n;
double lam1 = (faces[i].w1 * rs);
double lam2 = (faces[i].w2 * rs);
if (lam1 >= 0 && lam2 >= 0 && lam1+lam2 <= 1)
cnt++;
}
}
//(*testout) << " cnt = " << cnt%2 << endl;
return (cnt % 2) ? IS_INSIDE : IS_OUTSIDE;
}
void Polyhedra :: GetTangentialSurfaceIndices (const Point<3> & p,
ARRAY<int> & surfind, double eps) const
{
for (int i = 0; i < faces.Size(); i++)
{
const Point<3> & p1 = points[faces[i].pnums[0]];
Vec<3> v0 = p - p1;
double lam3 = -(faces[i].nn * v0); // n->nn
if (fabs (lam3) > eps) continue;
double lam1 = (faces[i].w1 * v0);
double lam2 = (faces[i].w2 * v0);
if (lam1 >= -eps_base1 && lam2 >= -eps_base1 && lam1+lam2 <= 1+eps_base1)
if (!surfind.Contains (GetSurfaceId(i)))
surfind.Append (GetSurfaceId(i));
}
}
INSOLID_TYPE Polyhedra :: VecInSolid (const Point<3> & p,
const Vec<3> & v,
double eps) const
{
ARRAY<int> point_on_faces;
INSOLID_TYPE res(DOES_INTERSECT);
Vec<3> vn = v;
vn.Normalize();
for (int i = 0; i < faces.Size(); i++)
{
const Point<3> & p1 = points[faces[i].pnums[0]];
Vec<3> v0 = p - p1;
double lam3 = -(faces[i].nn * v0); // n->nn
if (fabs (lam3) > eps) continue;
//(*testout) << "lam3 <= eps" << endl;
double lam1 = (faces[i].w1 * v0);
double lam2 = (faces[i].w2 * v0);
if (lam1 >= -eps_base1 && lam2 >= -eps_base1 && lam1+lam2 <= 1+eps_base1)
{
point_on_faces.Append(i);
double scal = vn * faces[i].nn; // n->nn
res = DOES_INTERSECT;
if (scal > eps_base1) res = IS_OUTSIDE;
if (scal < -eps_base1) res = IS_INSIDE;
}
}
//(*testout) << "point_on_faces.Size() " << point_on_faces.Size()
// << " res " << res << endl;
if (point_on_faces.Size() == 0)
return PointInSolid (p, 0);
if (point_on_faces.Size() == 1)
return res;
double mindist(0);
bool first = true;
for(int i=0; i<point_on_faces.Size(); i++)
{
for(int j=0; j<3; j++)
{
double dist = Dist(p,points[faces[point_on_faces[i]].pnums[j]]);
if(dist > eps && (first || dist < mindist))
{
mindist = dist;
first = false;
}
}
}
Point<3> p2 = p + (1e-2*mindist) * vn;
res = PointInSolid (p2, eps);
// (*testout) << "mindist " << mindist << " res " << res << endl;
return res;
}
/*
INSOLID_TYPE Polyhedra :: VecInSolid2 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const
{
INSOLID_TYPE res;
res = VecInSolid(p,v1,eps);
if(res != DOES_INTERSECT)
return res;
int point_on_n_faces = 0;
Vec<3> v1n = v1;
v1n.Normalize();
Vec<3> v2n = v2;
v2n.Normalize();
for (int i = 0; i < faces.Size(); i++)
{
const Point<3> & p1 = points[faces[i].pnums[0]];
Vec<3> v0 = p - p1;
double lam3 = -(faces[i].n * v0);
if (fabs (lam3) > eps) continue;
double lam1 = (faces[i].w1 * v0);
double lam2 = (faces[i].w2 * v0);
if (lam1 >= -eps && lam2 >= -eps && lam1+lam2 <= 1+eps)
{
double scal1 = v1n * faces[i].n;
if (fabs (scal1) > eps) continue;
point_on_n_faces++;
double scal2 = v2n * faces[i].n;
res = DOES_INTERSECT;
if (scal2 > eps) res = IS_OUTSIDE;
if (scal2 < -eps) res = IS_INSIDE;
}
}
if (point_on_n_faces == 1)
return res;
cerr << "primitive::vecinsolid2 makes nonsense for polyhedra" << endl;
return Primitive :: VecInSolid2 (p, v1, v2, eps);
}
*/
INSOLID_TYPE Polyhedra :: VecInSolid2 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const
{
//(*testout) << "VecInSolid2 eps " << eps << endl;
INSOLID_TYPE res = VecInSolid(p,v1,eps);
//(*testout) << "VecInSolid = " <<res <<endl;
if(res != DOES_INTERSECT)
return res;
int point_on_n_faces = 0;
Vec<3> v1n = v1;
v1n.Normalize();
Vec<3> v2n = v2 - (v2 * v1n) * v1n;
v2n.Normalize();
double cosv2, cosv2max = -1;
for (int i = 0; i < faces.Size(); i++)
{
const Point<3> & p1 = points[faces[i].pnums[0]];
Vec<3> v0 = p - p1;
if (fabs (faces[i].nn * v0) > eps) continue; // n->nn
if (fabs (v1n * faces[i].nn) > eps_base1) continue; // n->nn
double lam1 = (faces[i].w1 * v0);
double lam2 = (faces[i].w2 * v0);
if (lam1 >= -eps_base1 && lam2 >= -eps_base1 && lam1+lam2 <= 1+eps_base1)
{
// v1 is in face
Point<3> fc = Center (points[faces[i].pnums[0]],
points[faces[i].pnums[1]],
points[faces[i].pnums[2]]);
Vec<3> vpfc = fc - p;
cosv2 = (v2n * vpfc) / vpfc.Length();
if (cosv2 > cosv2max)
{
cosv2max = cosv2;
point_on_n_faces++;
double scal2 = v2n * faces[i].nn; // n->nn
res = DOES_INTERSECT;
if (scal2 > eps_base1) res = IS_OUTSIDE;
if (scal2 < -eps_base1) res = IS_INSIDE;
}
}
}
if (point_on_n_faces >= 1)
return res;
(*testout) << "primitive::vecinsolid2 makes nonsense for polyhedra" << endl;
cerr << "primitive::vecinsolid2 makes nonsense for polyhedra" << endl;
return Primitive :: VecInSolid2 (p, v1, v2, eps);
}
void Polyhedra :: GetTangentialVecSurfaceIndices2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,
ARRAY<int> & surfind, double eps) const
{
Vec<3> v1n = v1;
v1n.Normalize();
Vec<3> v2n = v2; // - (v2 * v1n) * v1n;
v2n.Normalize();
for (int i = 0; i < faces.Size(); i++)
{
const Point<3> & p1 = points[faces[i].pnums[0]];
Vec<3> v0 = p - p1;
if (fabs (v0 * faces[i].nn) > eps) continue; // n->nn
if (fabs (v1n * faces[i].nn) > eps_base1) continue; // n->nn
if (fabs (v2n * faces[i].nn) > eps_base1) continue; // n->nn
double lam01 = (faces[i].w1 * v0);
double lam02 = (faces[i].w2 * v0);
double lam03 = 1-lam01-lam02;
double lam11 = (faces[i].w1 * v1);
double lam12 = (faces[i].w2 * v1);
double lam13 = -lam11-lam12;
double lam21 = (faces[i].w1 * v2);
double lam22 = (faces[i].w2 * v2);
double lam23 = -lam21-lam22;
bool ok1 = lam01 > eps_base1 ||
(lam01 > -eps_base1 && lam11 > eps_base1) ||
(lam01 > -eps_base1 && lam11 > -eps_base1 && lam21 > eps_base1);
bool ok2 = lam02 > eps_base1 ||
(lam02 > -eps_base1 && lam12 > eps_base1) ||
(lam02 > -eps_base1 && lam12 > -eps_base1 && lam22 > eps_base1);
bool ok3 = lam03 > eps_base1 ||
(lam03 > -eps_base1 && lam13 > eps_base1) ||
(lam03 > -eps_base1 && lam13 > -eps_base1 && lam23 > eps_base1);
if (ok1 && ok2 && ok3)
{
if (!surfind.Contains (GetSurfaceId(faces[i].planenr)))
surfind.Append (GetSurfaceId(faces[i].planenr));
}
}
}
void Polyhedra :: GetPrimitiveData (const char *& classname,
ARRAY<double> & coeffs) const
{
classname = "Polyhedra";
coeffs.SetSize(0);
coeffs.Append (points.Size());
coeffs.Append (faces.Size());
coeffs.Append (planes.Size());
/*
int i, j;
for (i = 1; i <= planes.Size(); i++)
{
planes.Elem(i)->Print (*testout);
}
for (i = 1; i <= faces.Size(); i++)
{
(*testout) << "face " << i << " has plane " << faces.Get(i).planenr << endl;
for (j = 1; j <= 3; j++)
(*testout) << points.Get(faces.Get(i).pnums[j-1]);
(*testout) << endl;
}
*/
}
void Polyhedra :: SetPrimitiveData (ARRAY<double> & /* coeffs */)
{
;
}
void Polyhedra :: Reduce (const BoxSphere<3> & box)
{
for (int i = 0; i < planes.Size(); i++)
surfaceactive[i] = 0;
for (int i = 0; i < faces.Size(); i++)
if (FaceBoxIntersection (i, box))
surfaceactive[faces[i].planenr] = 1;
}
void Polyhedra :: UnReduce ()
{
for (int i = 0; i < planes.Size(); i++)
surfaceactive[i] = 1;
}
int Polyhedra :: AddPoint (const Point<3> & p)
{
if(points.Size() == 0)
poly_bbox.Set(p);
else
poly_bbox.Add(p);
return points.Append (p);
}
int Polyhedra :: AddFace (int pi1, int pi2, int pi3, int inputnum)
{
(*testout) << "polyhedra, add face " << pi1 << ", " << pi2 << ", " << pi3 << endl;
if(pi1 == pi2 || pi2 == pi3 || pi3 == pi1)
{
ostringstream msg;
msg << "Illegal point numbers for polyhedron face: " << pi1+1 << ", " << pi2+1 << ", " << pi3+1;
throw NgException(msg.str());
}
faces.Append (Face (pi1, pi2, pi3, points, inputnum));
Point<3> p1 = points[pi1];
Point<3> p2 = points[pi2];
Point<3> p3 = points[pi3];
Vec<3> v1 = p2 - p1;
Vec<3> v2 = p3 - p1;
Vec<3> n = Cross (v1, v2);
n.Normalize();
Plane pl (p1, n);
// int inverse;
// int identicto = -1;
// for (int i = 0; i < planes.Size(); i++)
// if (pl.IsIdentic (*planes[i], inverse, 1e-9*max3(v1.Length(),v2.Length(),Dist(p2,p3))))
// {
// if (!inverse)
// identicto = i;
// }
// // cout << "is identic = " << identicto << endl;
// identicto = -1; // changed April 10, JS
// if (identicto != -1)
// faces.Last().planenr = identicto;
// else
{
planes.Append (new Plane (p1, n));
surfaceactive.Append (1);
surfaceids.Append (0);
faces.Last().planenr = planes.Size()-1;
}
// (*testout) << "is plane nr " << faces.Last().planenr << endl;
return faces.Size();
}
int Polyhedra :: FaceBoxIntersection (int fnr, const BoxSphere<3> & box) const
{
/*
(*testout) << "check face box intersection, fnr = " << fnr << endl;
(*testout) << "box = " << box << endl;
(*testout) << "face-box = " << faces[fnr].bbox << endl;
*/
if (!faces[fnr].bbox.Intersect (box))
return 0;
const Point<3> & p1 = points[faces[fnr].pnums[0]];
const Point<3> & p2 = points[faces[fnr].pnums[1]];
const Point<3> & p3 = points[faces[fnr].pnums[2]];
double dist2 = MinDistTP2 (p1, p2, p3, box.Center());
/*
(*testout) << "p1 = " << p1 << endl;
(*testout) << "p2 = " << p2 << endl;
(*testout) << "p3 = " << p3 << endl;
(*testout) << "box.Center() = " << box.Center() << endl;
(*testout) << "center = " << box.Center() << endl;
(*testout) << "dist2 = " << dist2 << endl;
(*testout) << "diam = " << box.Diam() << endl;
*/
if (dist2 < sqr (box.Diam()/2))
{
// (*testout) << "intersect" << endl;
return 1;
}
return 0;
}
void Polyhedra :: GetPolySurfs(ARRAY < ARRAY<int> * > & polysurfs)
{
int maxnum = -1;
for(int i = 0; i<faces.Size(); i++)
{
if(faces[i].inputnr > maxnum)
maxnum = faces[i].inputnr;
}
polysurfs.SetSize(maxnum+1);
for(int i=0; i<polysurfs.Size(); i++)
polysurfs[i] = new ARRAY<int>;
for(int i = 0; i<faces.Size(); i++)
polysurfs[faces[i].inputnr]->Append(faces[i].planenr);
}
void Polyhedra::CalcSpecialPoints (ARRAY<Point<3> > & pts) const
{
for (int i = 0; i < points.Size(); i++)
pts.Append (points[i]);
}
void Polyhedra :: AnalyzeSpecialPoint (const Point<3> & /* pt */,
ARRAY<Point<3> > & /* specpts */) const
{
;
}
Vec<3> Polyhedra :: SpecialPointTangentialVector (const Point<3> & p, int s1, int s2) const
{
const double eps = 1e-10*poly_bbox.Diam();
for (int fi1 = 0; fi1 < faces.Size(); fi1++)
for (int fi2 = 0; fi2 < faces.Size(); fi2++)
{
int si1 = faces[fi1].planenr;
int si2 = faces[fi2].planenr;
if (surfaceids[si1] != s1 || surfaceids[si2] != s2) continue;
//(*testout) << "check pair fi1/fi2 " << fi1 << "/" << fi2 << endl;
Vec<3> n1 = GetSurface(si1) . GetNormalVector (p);
Vec<3> n2 = GetSurface(si2) . GetNormalVector (p);
Vec<3> t = Cross (n1, n2);
//(*testout) << "t = " << t << endl;
/*
int samepts = 0;
for (int j = 0; j < 3; j++)
for (int k = 0; k < 3; k++)
if (Dist(points[faces[fi1].pnums[j]],
points[faces[fi2].pnums[k]]) < eps)
samepts++;
if (samepts < 2) continue;
*/
bool shareedge = false;
for(int j = 0; !shareedge && j < 3; j++)
{
Vec<3> v1 = points[faces[fi1].pnums[(j+1)%3]] - points[faces[fi1].pnums[j]];
double smax = v1.Length();
v1 *= 1./smax;
int pospos;
if(fabs(v1(0)) > 0.5)
pospos = 0;
else if(fabs(v1(1)) > 0.5)
pospos = 1;
else
pospos = 2;
double sp = (p(pospos) - points[faces[fi1].pnums[j]](pospos)) / v1(pospos);
if(sp < -eps || sp > smax+eps)
continue;
for (int k = 0; !shareedge && k < 3; k ++)
{
Vec<3> v2 = points[faces[fi2].pnums[(k+1)%3]] - points[faces[fi2].pnums[k]];
v2.Normalize();
if(v2 * v1 > 0)
v2 -= v1;
else
v2 += v1;
//(*testout) << "v2.Length2() " << v2.Length2() << endl;
if(v2.Length2() > 1e-18)
continue;
double sa,sb;
sa = (points[faces[fi2].pnums[k]](pospos) - points[faces[fi1].pnums[j]](pospos)) / v1(pospos);
sb = (points[faces[fi2].pnums[(k+1)%3]](pospos) - points[faces[fi1].pnums[j]](pospos)) / v1(pospos);
if(Dist(points[faces[fi1].pnums[j]] + sa*v1, points[faces[fi2].pnums[k]]) > eps)
continue;
if(sa > sb)
{
double aux = sa; sa = sb; sb = aux;
}
//testout->precision(20);
//(*testout) << "sa " << sa << " sb " << sb << " smax " << smax << " sp " << sp << " v1 " << v1 << endl;
//testout->precision(8);
shareedge = (sa < -eps && sb > eps) ||
(sa < smax-eps && sb > smax+eps) ||
(sa > -eps && sb < smax+eps);
if(!shareedge)
continue;
sa = max2(sa,0.);
sb = min2(sb,smax);
if(sp < sa+eps)
shareedge = (t * v1 > 0);
else if (sp > sb-eps)
shareedge = (t * v1 < 0);
}
}
if (!shareedge) continue;
t.Normalize();
return t;
}
return Vec<3> (0,0,0);
}
}

99
libsrc/csg/polyhedra.hpp Normal file
View File

@ -0,0 +1,99 @@
#ifndef FILE_POLYHEDRA
#define FILE_POLYHEDRA
/**************************************************************************/
/* File: polyhedra.hh */
/* Author: Joachim Schoeberl */
/* Date: 19. Mar. 2000 */
/**************************************************************************/
/*
Polyhedral primitive
*/
class Polyhedra : public Primitive
{
class Face {
public:
int pnums[3];
int planenr;
int inputnr;
Box<3> bbox;
// Point<3> center;
Vec<3> v1, v2; // edges
Vec<3> w1, w2; // pseudo-inverse
Vec<3> n; // normal to face
Vec<3> nn; // normed normal
Face () { ; }
Face (int pi1, int pi2, int pi3,
const ARRAY<Point<3> > & points,
int ainputnr);
};
ARRAY<Point<3> > points;
ARRAY<Face> faces;
ARRAY<Plane*> planes;
Box<3> poly_bbox;
double eps_base1;
public:
Polyhedra ();
virtual ~Polyhedra ();
static Primitive * CreateDefault ();
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
virtual INSOLID_TYPE PointInSolid (const Point<3> & p,
double eps) const;
virtual INSOLID_TYPE VecInSolid (const Point<3> & p,
const Vec<3> & v,
double eps) const;
// checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid
virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const;
virtual void GetTangentialSurfaceIndices (const Point<3> & p,
ARRAY<int> & surfind, double eps) const;
virtual void GetTangentialVecSurfaceIndices2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,
ARRAY<int> & surfind, double eps) const;
virtual void CalcSpecialPoints (ARRAY<Point<3> > & pts) const;
virtual void AnalyzeSpecialPoint (const Point<3> & pt,
ARRAY<Point<3> > & specpts) const;
virtual Vec<3> SpecialPointTangentialVector (const Point<3> & p, int s1, int s2) const;
virtual int GetNSurfaces() const
{ return planes.Size(); }
virtual Surface & GetSurface (int i)
{ return *planes[i]; }
virtual const Surface & GetSurface (int i) const
{ return *planes[i]; }
virtual void GetPrimitiveData (const char *& classname, ARRAY<double> & coeffs) const;
virtual void SetPrimitiveData (ARRAY<double> & coeffs);
virtual void Reduce (const BoxSphere<3> & box);
virtual void UnReduce ();
int AddPoint (const Point<3> & p);
int AddFace (int pi1, int pi2, int pi3, int inputnum);
void GetPolySurfs(ARRAY < ARRAY<int> * > & polysurfs);
protected:
int FaceBoxIntersection (int fnr, const BoxSphere<3> & box) const;
// void CalcData();
};
#endif

904
libsrc/csg/revolution.cpp Normal file
View File

@ -0,0 +1,904 @@
#include <mystdlib.h>
#include <linalg.hpp>
#include <csg.hpp>
namespace netgen
{
void RevolutionFace :: Init(void)
{
const LineSeg<2> * line = dynamic_cast<const LineSeg<2>*>(spline);
const SplineSeg3<2> * spline3 = dynamic_cast<const SplineSeg3<2>*>(spline);
if(line)
{
checklines_start.Append(new Point<2>(line->StartPI()));
checklines_vec.Append(new Vec<2>(line->EndPI() - line->StartPI()));
(*checklines_vec.Last()) *= 1./pow(checklines_vec.Last()->Length(),2); //!!
}
else if (spline3)
{
checklines_start.Append(new Point<2>(spline3->EndPI()));
checklines_start.Append(new Point<2>(spline3->TangentPoint()));
checklines_start.Append(new Point<2>(spline3->StartPI()));
checklines_vec.Append(new Vec<2>(spline3->StartPI() - spline3->EndPI()));
(*checklines_vec.Last()) *= 1./pow(checklines_vec.Last()->Length(),2); //!!
checklines_vec.Append(new Vec<2>(spline3->EndPI() - spline3->TangentPoint()));
(*checklines_vec.Last()) *= 1./pow(checklines_vec.Last()->Length(),2); //!!
checklines_vec.Append(new Vec<2>(spline3->TangentPoint() - spline3->StartPI()));
(*checklines_vec.Last()) *= 1./pow(checklines_vec.Last()->Length(),2); //!!
}
for(int i=0; i<checklines_vec.Size(); i++)
{
checklines_normal.Append(new Vec<2>);
(*checklines_normal.Last())(0) = - (*checklines_vec[i])(1);
(*checklines_normal.Last())(1) = (*checklines_vec[i])(0);
checklines_normal.Last()->Normalize();
}
}
RevolutionFace :: RevolutionFace(const SplineSeg<2> & spline_in,
const Point<3> & p,
const Vec<3> & vec,
bool first,
bool last,
const int id_in) :
spline(&spline_in), p0(p), v_axis(vec), isfirst(first), islast(last), id(id_in)
{
deletable = false;
Init();
}
RevolutionFace :: RevolutionFace(const ARRAY<double> & raw_data)
{
deletable = true;
int pos = 0;
ARRAY< Point<2> > p(3);
int stype = int(raw_data[pos]); pos++;
for(int i=0; i<stype; i++)
{
p[i](0) = raw_data[pos]; pos++;
p[i](1) = raw_data[pos]; pos++;
}
if(stype == 2)
{
spline = new LineSeg<2>(GeomPoint<2>(p[0],1),
GeomPoint<2>(p[1],1));
//(*testout) << "appending LineSeg<2> " << p[0]
// << " to " << p[1] << endl;
}
else if(stype == 3)
{
spline = new SplineSeg3<2>(GeomPoint<2>(p[0],1),
GeomPoint<2>(p[1],1),
GeomPoint<2>(p[2],1));
//(*testout) << "appending SplineSeg<3> "
// << p[0] << " -- " << p[1] << " -- " << p[2] << endl;
}
for(int i=0; i<3; i++)
{
p0(i) = raw_data[pos];
pos++;
}
for(int i=0; i<3; i++)
{
v_axis(i) = raw_data[pos];
pos++;
}
isfirst = (raw_data[pos] > 0.9);
pos++;
islast = (raw_data[pos] < 0.1);
pos++;
}
RevolutionFace :: ~RevolutionFace()
{
for(int i=0; i<checklines_start.Size(); i++)
{
delete checklines_start[i];
delete checklines_vec[i];
delete checklines_normal[i];
}
if(deletable)
delete spline;
}
void RevolutionFace :: CalcProj(const Point<3> & point3d, Point<2> & point2d,
const Vec<3> & vector3d, Vec<2> & vector2d) const
{
Vec<3> pmp0 = point3d-p0;
CalcProj0(pmp0,point2d);
Vec<3> y=pmp0-point2d(0)*v_axis; y.Normalize();
vector2d(0) = vector3d*v_axis;
vector2d(1) = vector3d*y;
}
void RevolutionFace :: CalcProj(const Point<3> & point3d, Point<2> & point2d) const
{
Vec<3> pmp0 = point3d-p0;
CalcProj0(pmp0,point2d);
}
void RevolutionFace :: CalcProj0(const Vec<3> & point3d_minus_p0, Point<2> & point2d) const
{
point2d(0) = point3d_minus_p0 * v_axis;
point2d(1) = sqrt( point3d_minus_p0 * point3d_minus_p0 - point2d(0)*point2d(0) );
}
int RevolutionFace ::IsIdentic (const Surface & s2, int & inv, double eps) const
{
const RevolutionFace * rev2 = dynamic_cast<const RevolutionFace*>(&s2);
if(!rev2) return 0;
if(rev2 == this)
return 1;
return 0;
}
double RevolutionFace :: CalcFunctionValue (const Point<3> & point) const
{
if(spline_coefficient.Size() == 0)
spline->GetCoeff(spline_coefficient);
Point<2> p;
CalcProj(point,p);
return spline_coefficient(0)*p(0)*p(0) + spline_coefficient(1)*p(1)*p(1)
+ spline_coefficient(2)*p(0)*p(1) + spline_coefficient(3)*p(0)
+ spline_coefficient(4)*p(1) + spline_coefficient(5);
}
void RevolutionFace :: CalcGradient (const Point<3> & point, Vec<3> & grad) const
{
if(spline_coefficient.Size() == 0)
spline->GetCoeff(spline_coefficient);
Vec<3> point_minus_p0 = point-p0;
Point<2> p;
CalcProj0(point_minus_p0,p);
const double dFdxbar = 2.*spline_coefficient(0)*p(0) + spline_coefficient(2)*p(1) + spline_coefficient(3);
if(fabs(p(1)) > 1e-10)
{
const double dFdybar = 2.*spline_coefficient(1)*p(1) + spline_coefficient(2)*p(0) + spline_coefficient(4);
grad(0) = dFdxbar*v_axis(0) + dFdybar * ( point_minus_p0(0)-v_axis(0)*p(0) )/p(1);
grad(1) = dFdxbar*v_axis(1) + dFdybar * ( point_minus_p0(1)-v_axis(1)*p(0) )/p(1);
grad(2) = dFdxbar*v_axis(2) + dFdybar * ( point_minus_p0(2)-v_axis(2)*p(0) )/p(1);
//(*testout) << "grad1("<<point<<") = " << grad << endl;
}
else
{
grad(0) = dFdxbar*v_axis(0);
grad(1) = dFdxbar*v_axis(1);
grad(2) = dFdxbar*v_axis(2);
//(*testout) << "grad2("<<point<<") = " << grad << endl;
}
}
void RevolutionFace :: CalcHesse (const Point<3> & point, Mat<3> & hesse) const
{
if(spline_coefficient.Size() == 0)
spline->GetCoeff(spline_coefficient);
Vec<3> point_minus_p0 = point-p0;
Point<2> p;
CalcProj0(point_minus_p0,p);
if(fabs(p(1)) > 1e-10)
{
const double dFdybar = 2.*spline_coefficient(1)*p(1) + spline_coefficient(2)*p(0) + spline_coefficient(4);
const double aux = -pow(p(1),-3);
const double aux0 = point_minus_p0(0) - v_axis(0)*p(0);
const double aux1 = point_minus_p0(1) - v_axis(1)*p(0);
const double aux2 = point_minus_p0(2) - v_axis(2)*p(0);
const double dybardx = aux0/p(1);
const double dybardy = aux1/p(1);
const double dybardz = aux2/p(1);
const double dybardxx = aux*aux0*aux0 + (1.-v_axis(0)*v_axis(0))/p(1);
const double dybardyy = aux*aux1*aux1 + (1.-v_axis(1)*v_axis(1))/p(1);
const double dybardzz = aux*aux2*aux2 + (1.-v_axis(2)*v_axis(2))/p(1);
const double dybardxy = aux*aux0*aux1 - v_axis(0)*v_axis(1)/p(1);
const double dybardxz = aux*aux0*aux2 - v_axis(0)*v_axis(2)/p(1);
const double dybardyz = aux*aux1*aux2 - v_axis(1)*v_axis(2)/p(1);
hesse(0,0) = 2.*spline_coefficient(0)*v_axis(0)*v_axis(0) + 2.*spline_coefficient(2)*v_axis(0)*dybardx + 2.*spline_coefficient(1)*dybardx*dybardx
+ dFdybar*dybardxx;
hesse(1,1) = 2.*spline_coefficient(0)*v_axis(1)*v_axis(1) + 2.*spline_coefficient(2)*v_axis(1)*dybardy + 2.*spline_coefficient(1)*dybardy*dybardy
+ dFdybar*dybardyy;
hesse(2,2) = 2.*spline_coefficient(0)*v_axis(2)*v_axis(2) + 2.*spline_coefficient(2)*v_axis(2)*dybardz + 2.*spline_coefficient(1)*dybardz*dybardz
+ dFdybar*dybardzz;
hesse(0,1) = hesse(1,0) = 2.*spline_coefficient(0)*v_axis(0)*v_axis(1) + spline_coefficient(2)*v_axis(0)*dybardy + spline_coefficient(2)*dybardx*v_axis(1)
+ 2.*spline_coefficient(2)*dybardx*dybardy + dFdybar*dybardxy;
hesse(0,2) = hesse(2,0) = 2.*spline_coefficient(0)*v_axis(0)*v_axis(2) + spline_coefficient(2)*v_axis(0)*dybardz + spline_coefficient(2)*dybardx*v_axis(2)
+ 2.*spline_coefficient(2)*dybardx*dybardz + dFdybar*dybardxz;
hesse(1,2) = hesse(2,1) = 2.*spline_coefficient(0)*v_axis(1)*v_axis(2) + spline_coefficient(2)*v_axis(1)*dybardz + spline_coefficient(2)*dybardy*v_axis(2)
+ 2.*spline_coefficient(2)*dybardy*dybardz + dFdybar*dybardyz;
//(*testout) << "hesse1: " << hesse <<endl;
}
else if (fabs(spline_coefficient(2)) + fabs(spline_coefficient(4)) < 1.e-9 &&
fabs(spline_coefficient(0)) > 1e-10)
{
double aux = spline_coefficient(0)-spline_coefficient(1);
hesse(0,0) = aux*v_axis(0)*v_axis(0) + spline_coefficient(1);
hesse(0,0) = aux*v_axis(1)*v_axis(1) + spline_coefficient(1);
hesse(0,0) = aux*v_axis(2)*v_axis(2) + spline_coefficient(1);
hesse(0,1) = hesse(1,0) = aux*v_axis(0)*v_axis(1);
hesse(0,2) = hesse(2,0) = aux*v_axis(0)*v_axis(2);
hesse(1,2) = hesse(2,1) = aux*v_axis(1)*v_axis(2);
//(*testout) << "hesse2: " << hesse <<endl;
}
else if (fabs(spline_coefficient(1)) + fabs(spline_coefficient(3)) + fabs(spline_coefficient(4)) + fabs(spline_coefficient(5)) < 1.e-9) // line
{
hesse = 0;
//(*testout) << "hesse3: " << hesse <<endl;
}
else
{
(*testout) << "hesse4: " << hesse <<endl;
}
}
double RevolutionFace ::HesseNorm () const
{
if (fabs(spline_coefficient(1)) + fabs(spline_coefficient(3)) + fabs(spline_coefficient(4)) + fabs(spline_coefficient(5)) < 1.e-9) // line
return 0;
if (fabs(spline_coefficient(2)) + fabs(spline_coefficient(4)) < 1.e-9 &&
fabs(spline_coefficient(0)) > 1e-10)
return 2.*max2(fabs(spline_coefficient(0)),fabs(spline_coefficient(1)));
double alpha = fabs(spline_coefficient(2)*(spline->StartPI()(0)-spline->EndPI()(0))) /
max2(fabs(spline->StartPI()(1)),fabs(spline->EndPI()(1)));
return max2(2.*fabs(spline_coefficient(0))+sqrt(2.)*fabs(spline_coefficient(2)),
2.*fabs(spline_coefficient(1))+spline_coefficient(2)+1.5*alpha);
}
double RevolutionFace :: MaxCurvature() const
{
double retval = spline->MaxCurvature();
ARRAY < Point<2> > checkpoints;
const SplineSeg3<2> * ss3 = dynamic_cast<const SplineSeg3<2> *>(spline);
const LineSeg<2> * ls = dynamic_cast<const LineSeg<2> *>(spline);
if(ss3)
{
checkpoints.Append(ss3->StartPI());
checkpoints.Append(ss3->TangentPoint());
checkpoints.Append(ss3->TangentPoint());
checkpoints.Append(ss3->EndPI());
}
else if(ls)
{
checkpoints.Append(ls->StartPI());
checkpoints.Append(ls->EndPI());
}
for(int i=0; i<checkpoints.Size(); i+=2)
{
Vec<2> v = checkpoints[i+1]-checkpoints[i];
Vec<2> n(v(1),-v(0)); n.Normalize();
//if(ss3)
// (*testout) << "n " << n << endl;
if(fabs(n(1)) < 1e-15)
continue;
double t1 = -checkpoints[i](1)/n(1);
double t2 = -checkpoints[i+1](1)/n(1);
double c1 = (t1 > 0) ? (1./t1) : -1;
double c2 = (t2 > 0) ? (1./t2) : -1;
//if(ss3)
// (*testout) << "t1 " << t1 << " t2 " << t2 << " c1 " << c1 << " c2 " << c2 << endl;
if(c1 > retval)
retval = c1;
if(c2 > retval)
retval = c2;
}
//if(ss3)
// (*testout) << "curvature " << retval << endl;
return retval;
/*
// find smallest y value of spline:
ARRAY<double> testt;
if(!isfirst)
testt.Append(0);
if(!islast)
testt.Append(1);
const SplineSegment3 * s3 = dynamic_cast<const SplineSegment3 *>(&spline);
if(s3)
{
double denom = (2.-sqrt(2.))*(s3->EndPI()(1) - s3->StartPI()(1));
if(fabs(denom) < 1e-20)
testt.Append(0.5);
else
{
double sD = sqrt(pow(s3->TangentPoint()(1) - s3->StartPI()(1),2)+
pow(s3->TangentPoint()(1) - s3->EndPI()(1),2));
testt.Append((s3->StartPI()(1)*(sqrt(2.)-1.) - sqrt(2.)*s3->TangentPoint()(1) + s3->EndPI()(1) + sD)/denom);
testt.Append((s3->StartPI()(1)*(sqrt(2.)-1.) - sqrt(2.)*s3->TangentPoint()(1) + s3->EndPI()(1) - sD)/denom);
}
}
double miny = fabs(spline.GetPoint(testt[0])(1));
for(int i=1; i<testt.Size(); i++)
{
double thisy = fabs(spline.GetPoint(testt[i])(1));
if(thisy < miny)
miny = thisy;
}
return max2(splinecurvature,1./miny);
*/
}
void RevolutionFace :: Project (Point<3> & p) const
{
Point<2> p2d;
CalcProj(p,p2d);
const Vec<3> y = (p-p0)-p2d(0)*v_axis;
const double yl = y.Length();
double dummy;
spline->Project(p2d,p2d,dummy);
p = p0 + p2d(0)*v_axis;
if(yl > 1e-20*Dist(spline->StartPI(),spline->EndPI()))
p+= (p2d(1)/yl)*y;
}
Point<3> RevolutionFace :: GetSurfacePoint () const
{
Vec<3> random_vec(0.760320,-0.241175,0.60311534);
Vec<3> n = Cross(v_axis,random_vec); n.Normalize();
Point<2> sp = spline->GetPoint(0.5);
Point<3> retval = p0 + sp(0)*v_axis + sp(1)*n;
return retval;
}
void RevolutionFace :: Print (ostream & str) const
{
if(spline_coefficient.Size() == 0)
spline->GetCoeff(spline_coefficient);
str << p0(0) << " " << p0(1) << " " << p0(2) << " "
<< v_axis(0) << " " << v_axis(1) << " " << v_axis(2) << " ";
for(int i=0; i<6; i++) str << spline_coefficient(i) << " ";
str << endl;
}
void RevolutionFace :: GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & boundingbox,
double facets) const
{
Vec<3> random_vec(0.760320,-0.241175,0.60311534);
Vec<3> v1 = Cross(v_axis,random_vec); v1.Normalize();
Vec<3> v2 = Cross(v1,v_axis); v2.Normalize();
int n = int(2.*facets) + 1;
int i,j;
double phi;
Point<3> p;
for(i=0; i<=n; i++)
{
Point<2> sp = spline->GetPoint(double(i)/double(n));
for(j=0; j<=n; j++)
{
phi = 2.*M_PI*double(j)/double(n);
p = p0 + sp(0)*v_axis + sp(1)*cos(phi)*v1 + sp(1)*sin(phi)*v2;
tas.AddPoint(p);
}
}
for(i=0; i<n; i++)
for(j=0; j<n; j++)
{
int pi = (n+1)*i+j;
tas.AddTriangle( TATriangle (id, pi,pi+1,pi+n+1));
tas.AddTriangle( TATriangle (id, pi+1,pi+n+1,pi+n+2));
}
}
bool RevolutionFace :: BoxIntersectsFace(const Box<3> & box) const
{
Point<3> center = box.Center();
Project(center);
return (Dist(box.Center(),center) < 0.5*box.Diam());
}
/*
bool RevolutionFace :: BoxIntersectsFace (const BoxSphere<3> & box, bool & uncertain) const
{
Point<2> c,pmin,pmax;
CalcProj(box.Center(),c);
double aux = box.Diam()/sqrt(8.);
pmin(0) = c(0)-aux; pmin(1) = c(1)-aux;
pmax(0) = c(0)+aux; pmax(1) = c(1)+aux;
BoxSphere<2> box2d(pmin,pmax);
return BoxIntersectsFace(box2d, uncertain);
}
bool RevolutionFace :: BoxIntersectsFace (const BoxSphere<2> & box, bool & uncertain) const
{
const LineSegment * line = dynamic_cast<const LineSegment*>(&spline);
const SplineSegment3 * spline3 = dynamic_cast<const SplineSegment3*>(&spline);
bool always_right = true, always_left = true;
bool retval = false;
bool thisint;
bool intdirect = false;
bool inttangent = false;
uncertain = false;
if(line) inttangent = true;
for(int i=0; i<checklines_start.Size(); i++)
{
Vec<2> b = box.Center()- (*checklines_start[i]);
double d;
double checkdist = b * (*checklines_vec[i]);
double ncomp = b * (*checklines_normal[i]);
if(checkdist < 0)
d = b.Length();
else if (checkdist > 1)
{
if(spline3)
d = Dist(box.Center(),*checklines_start[(i+1)%3]);
else
d = Dist(box.Center(),(*checklines_start[i])
+ pow(checklines_vec[i]->Length(),2)*(*checklines_vec[i]));
}
else
d = fabs(ncomp);
thisint = (box.Diam() >= 2.*d);
retval = retval || thisint;
if(thisint)
{
if(i==0)
intdirect = true;
else
inttangent = true;
}
if(ncomp > 0) always_right = false;
else if(ncomp < 0) always_left = false;
}
if(retval && !(intdirect && inttangent))
uncertain = true;
if(!retval && spline3 && (always_right || always_left))
{
retval = true;
uncertain = true;
}
return retval;
}
*/
INSOLID_TYPE RevolutionFace :: PointInFace (const Point<3> & p, const double eps) const
{
Point<2> p2d;
CalcProj(p,p2d);
double val = spline_coefficient(0)*p2d(0)*p2d(0) + spline_coefficient(1)*p2d(1)*p2d(1) + spline_coefficient(2)*p2d(0)*p2d(1) +
spline_coefficient(3)*p2d(0) + spline_coefficient(4)*p2d(1) + spline_coefficient(5);
if(val > eps)
return IS_OUTSIDE;
if(val < -eps)
return IS_INSIDE;
return DOES_INTERSECT;
}
void RevolutionFace :: GetRawData(ARRAY<double> & data) const
{
data.DeleteAll();
spline->GetRawData(data);
for(int i=0; i<3; i++)
data.Append(p0(i));
for(int i=0; i<3; i++)
data.Append(v_axis(i));
data.Append((isfirst) ? 1. : 0.);
data.Append((islast) ? 1. : 0.);
}
Revolution :: Revolution(const Point<3> & p0_in,
const Point<3> & p1_in,
const SplineGeometry2d & spline_in) :
p0(p0_in), p1(p1_in), splinecurve(spline_in),
nsplines(spline_in.GetNSplines())
{
surfaceactive.SetSize(0);
surfaceids.SetSize(0);
v_axis = p1-p0;
v_axis.Normalize();
if(splinecurve.GetSpline(0).StartPI()(1) <= 0. &&
splinecurve.GetSpline(nsplines-1).EndPI()(1) <= 0.)
type = 2;
else if (Dist(splinecurve.GetSpline(0).StartPI(),
splinecurve.GetSpline(nsplines-1).EndPI()) < 1e-7)
type = 1;
else
cerr << "Surface of revolution cannot be constructed" << endl;
for(int i=0; i<splinecurve.GetNSplines(); i++)
{
RevolutionFace * face = new RevolutionFace(splinecurve.GetSpline(i),
p0,v_axis,
type==2 && i==0,
type==2 && i==splinecurve.GetNSplines()-1);
faces.Append(face);
surfaceactive.Append(1);
surfaceids.Append(0);
}
}
Revolution::~Revolution()
{
for(int i=0; i<faces.Size(); i++)
delete faces[i];
}
INSOLID_TYPE Revolution :: BoxInSolid (const BoxSphere<3> & box) const
{
for(int i=0; i<faces.Size(); i++)
if(faces[i]->BoxIntersectsFace(box))
return DOES_INTERSECT;
return PointInSolid(box.Center(),0);
/*
Point<2> c,pmin,pmax;
faces[0]->CalcProj(box.Center(),c);
double aux = box.Diam()/sqrt(8.);
pmin(0) = c(0)-aux; pmin(1) = c(1)-aux;
pmax(0) = c(0)+aux; pmax(1) = c(1)+aux;
BoxSphere<2> box2d(pmin,pmax);
bool intersection = false;
bool uncertain = true;
for(int i=0; !(intersection && !uncertain) && i<faces.Size(); i++)
{
bool thisintersects;
bool thisuncertain;
thisintersects = faces[i]->BoxIntersectsFace(box2d,thisuncertain);
intersection = intersection || thisintersects;
if(thisintersects && !thisuncertain)
uncertain = false;
}
if(intersection)
{
if(!uncertain)
return DOES_INTERSECT;
else
{
ARRAY < Point<3> > pext(2);
Point<3> p;
pext[0] = box.PMin();
pext[1] = box.PMax();
INSOLID_TYPE position;
bool firsttime = true;
for(int i=0; i<2; i++)
for(int j=0; j<2; j++)
for(int k=0; k<2; k++)
{
p(0) = pext[i](0);
p(1) = pext[j](1);
p(2) = pext[k](2);
INSOLID_TYPE ppos = PointInSolid(p,0);
if(ppos == DOES_INTERSECT)
return DOES_INTERSECT;
if(firsttime)
{
firsttime = false;
position = ppos;
}
if(position != ppos)
return DOES_INTERSECT;
}
return position;
}
}
return PointInSolid(box.Center(),0);
*/
}
INSOLID_TYPE Revolution :: PointInSolid (const Point<3> & p,
double eps) const
{
Point<2> p2d;
faces[0]->CalcProj(p,p2d);
int intersections_before(0), intersections_after(0);
double randomx = 7.42357;
double randomy = 1.814756;
randomx *= 1./sqrt(randomx*randomx+randomy*randomy);
randomy *= 1./sqrt(randomx*randomx+randomy*randomy);
const double a = randomy;
const double b = -randomx;
const double c = -a*p2d(0)-b*p2d(1);
ARRAY < Point<2> > points;
//(*testout) << "face intersections at: " << endl;
for(int i=0; i<faces.Size(); i++)
{
faces[i]->GetSpline().LineIntersections(a,b,c,points,eps);
for(int j=0; j<points.Size(); j++)
{
double t = (points[j](0)-p2d(0))/randomx;
//(*testout) << t << endl;
if ( t < -eps )
intersections_before++;
else if ( t > eps )
intersections_after++;
else
{
intersecting_face = i;
return DOES_INTERSECT;
}
}
}
if(intersections_before % 2 == 0)
return IS_OUTSIDE;
else
return IS_INSIDE;
}
INSOLID_TYPE Revolution :: VecInSolid (const Point<3> & p,
const Vec<3> & v,
double eps) const
{
INSOLID_TYPE pInSolid = PointInSolid(p,eps);
if(pInSolid != DOES_INTERSECT)
{
//(*testout) << "pInSolid" << endl;
return pInSolid;
}
ARRAY<int> intersecting_faces;
for(int i=0; i<faces.Size(); i++)
if(faces[i]->PointInFace(p,eps) == DOES_INTERSECT)
intersecting_faces.Append(i);
Vec<3> hv;
if(intersecting_faces.Size() == 1)
{
faces[intersecting_faces[0]]->CalcGradient(p,hv);
double hv1;
hv1 = v * hv;
if (hv1 <= -eps)
return IS_INSIDE;
if (hv1 >= eps)
return IS_OUTSIDE;
return DOES_INTERSECT;
}
else if(intersecting_faces.Size() == 2)
{
Point<2> p2d;
Vec<2> v2d;
faces[intersecting_faces[0]]->CalcProj(p,p2d,v,v2d);
if(Dist(faces[intersecting_faces[0]]->GetSpline().StartPI(),p2d) <
Dist(faces[intersecting_faces[0]]->GetSpline().EndPI(),p2d))
{
int aux = intersecting_faces[0];
intersecting_faces[0] = intersecting_faces[1];
intersecting_faces[1] = aux;
}
const SplineSeg3<2> * splinesegment3 =
dynamic_cast<const SplineSeg3<2> *>(&faces[intersecting_faces[0]]->GetSpline());
const LineSeg<2> * linesegment =
dynamic_cast<const LineSeg<2> *>(&faces[intersecting_faces[0]]->GetSpline());
Vec<2> t1,t2;
if(linesegment)
t1 = linesegment->StartPI() - linesegment->EndPI();
else if(splinesegment3)
t1 = splinesegment3->TangentPoint() - splinesegment3->EndPI();
linesegment =
dynamic_cast<const LineSeg<2> *>(&faces[intersecting_faces[1]]->GetSpline());
splinesegment3 =
dynamic_cast<const SplineSeg3<2> *>(&faces[intersecting_faces[1]]->GetSpline());
if(linesegment)
t2 = linesegment->EndPI() - linesegment->StartPI();
else if(splinesegment3)
t2 = splinesegment3->TangentPoint() - splinesegment3->StartPI();
t1.Normalize();
t2.Normalize();
double d1 = v2d*t1;
double d2 = v2d*t2;
Vec<2> n;
if(d1 > d2)
{
n(0) = t1(1);
n(1) = -t1(0);
}
else
{
n(0) = -t2(1);
n(1) = t2(0);
}
double d = v2d*n;
if(d > eps)
return IS_OUTSIDE;
else if (d < -eps)
return IS_INSIDE;
else
return DOES_INTERSECT;
}
else
{
cerr << "Jo gibt's denn des?" << endl;
}
return DOES_INTERSECT;
}
INSOLID_TYPE Revolution :: VecInSolid2 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const
{
INSOLID_TYPE ret1 = VecInSolid(p,v1,eps);
if(ret1 != DOES_INTERSECT)
return ret1;
return VecInSolid(p,v2,eps);
}
int Revolution :: GetNSurfaces() const
{
return faces.Size();
}
Surface & Revolution :: GetSurface (int i)
{
return *faces[i];
}
const Surface & Revolution :: GetSurface (int i) const
{
return *faces[i];
}
void Revolution :: Reduce (const BoxSphere<3> & box)
{
//bool dummy;
for(int i=0; i<faces.Size(); i++)
surfaceactive[i] = (faces[i]->BoxIntersectsFace(box));
//surfaceactive[i] = (faces[i]->BoxIntersectsFace(box,dummy));
}
void Revolution :: UnReduce ()
{
for(int i=0; i<faces.Size(); i++)
surfaceactive[i] = true;
}
}

149
libsrc/csg/revolution.hpp Normal file
View File

@ -0,0 +1,149 @@
#ifndef _REVOLUTION_HPP
#define _REVOLUTION_HPP
class Revolution;
class RevolutionFace : public Surface
{
private:
bool isfirst, islast;
const SplineSeg<2> * spline;
bool deletable;
Point<3> p0;
Vec<3> v_axis;
int id;
mutable Vector spline_coefficient;
ARRAY < Vec<2>* > checklines_vec;
ARRAY < Point<2>* > checklines_start;
ARRAY < Vec<2>* > checklines_normal;
private:
void Init (void);
public:
void CalcProj(const Point<3> & point3d, Point<2> & point2d) const;
void CalcProj(const Point<3> & point3d, Point<2> & point2d,
const Vec<3> & vector3d, Vec<2> & vector2d) const;
void CalcProj0(const Vec<3> & point3d_minus_p0, Point<2> & point2d) const;
public:
RevolutionFace(const SplineSeg<2> & spline_in,
const Point<3> & p,
const Vec<3> & vec,
bool first = false,
bool last = false,
const int id_in = 0);
RevolutionFace(const ARRAY<double> & raw_data);
~RevolutionFace();
virtual int IsIdentic (const Surface & s2, int & inv, double eps) const;
virtual double CalcFunctionValue (const Point<3> & point) const;
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const;
virtual double HesseNorm () const;
virtual double MaxCurvature () const;
//virtual double MaxCurvatureLoc (const Point<3> & /* c */ ,
// double /* rad */) const;
virtual void Project (Point<3> & p) const;
virtual Point<3> GetSurfacePoint () const;
virtual void Print (ostream & str) const;
virtual void GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & boundingbox,
double facets) const;
bool BoxIntersectsFace (const Box<3> & box) const;
/*
bool BoxIntersectsFace (const BoxSphere<2> & box, bool & uncertain) const;
bool BoxIntersectsFace (const BoxSphere<3> & box, bool & uncertain) const;
*/
const SplineSeg<2> & GetSpline(void) const {return *spline;}
INSOLID_TYPE PointInFace (const Point<3> & p, const double eps) const;
void GetRawData(ARRAY<double> & data) const;
};
/*
Primitive of revolution
*/
class Revolution : public Primitive
{
private:
Point<3> p0,p1;
Vec<3> v_axis;
const SplineGeometry2d & splinecurve;
const int nsplines;
// 1 ... torus-like
// 2 ... sphere-like
int type;
ARRAY<RevolutionFace*> faces;
mutable int intersecting_face;
public:
Revolution(const Point<3> & p0_in,
const Point<3> & p1_in,
const SplineGeometry2d & spline_in);
~Revolution();
/*
Check, whether box intersects solid defined by surface.
return values:
0 .. box outside solid \\
1 .. box in solid \\
2 .. can't decide (allowed, iff box is close to solid)
*/
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
virtual INSOLID_TYPE PointInSolid (const Point<3> & p,
double eps) const;
virtual INSOLID_TYPE VecInSolid (const Point<3> & p,
const Vec<3> & v,
double eps) const;
// checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid
virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const;
virtual int GetNSurfaces() const;
virtual Surface & GetSurface (int i = 0);
virtual const Surface & GetSurface (int i = 0) const;
virtual void Reduce (const BoxSphere<3> & box);
virtual void UnReduce ();
};
#endif

217
libsrc/csg/singularref.cpp Normal file
View File

@ -0,0 +1,217 @@
#include <mystdlib.h>
#include <myadt.hpp>
#include <linalg.hpp>
#include <csg.hpp>
#include <meshing.hpp>
namespace netgen
{
SingularEdge :: SingularEdge (double abeta, int adomnr,
const CSGeometry & ageom,
const Solid * asol1,
const Solid * asol2, double sf,
const double maxh_at_initialization)
: geom(ageom), domnr(adomnr)
{
beta = abeta;
maxhinit = maxh_at_initialization;
if (beta > 1)
{
beta = 1;
cout << "Warning: beta set to 1" << endl;
}
if (beta <= 1e-3)
{
beta = 1e-3;
cout << "Warning: beta set to minimal value 0.001" << endl;
}
sol1 = asol1;
sol2 = asol2;
factor = sf;
}
void SingularEdge :: FindPointsOnEdge (class Mesh & mesh)
{
(*testout) << "find points on edge" << endl;
points.SetSize(0);
segms.SetSize(0);
ARRAY<int> si1, si2;
sol1->GetSurfaceIndices (si1);
sol2->GetSurfaceIndices (si2);
for (int i = 0; i < si1.Size(); i++)
si1[i] = geom.GetSurfaceClassRepresentant(si1[i]);
for (int i = 0; i < si2.Size(); i++)
si2[i] = geom.GetSurfaceClassRepresentant(si2[i]);
for (SegmentIndex si = 0; si < mesh.GetNSeg(); si++)
{
INDEX_2 i2 (mesh[si].p1, mesh[si].p2);
/*
bool onedge = 1;
for (j = 1; j <= 2; j++)
{
const Point<3> p = mesh[ PointIndex (i2.I(j)) ];
if (sol1->IsIn (p, 1e-3) && sol2->IsIn(p, 1e-3) &&
!sol1->IsStrictIn (p, 1e-3) && !sol2->IsStrictIn(p, 1e-3))
{
;
}
else
onedge = 0;
}
*/
if (domnr != -1 && domnr != mesh[si].domin && domnr != mesh[si].domout)
continue;
/*
bool onedge = 1;
for (int j = 0; j < 2; j++)
{
int surfi = (j == 0) ? mesh[si].surfnr1 : mesh[si].surfnr2;
surfi = geom.GetSurfaceClassRepresentant(surfi);
if (!si1.Contains(surfi) && !si2.Contains(surfi))
onedge = 0;
}
*/
int surfi1 = geom.GetSurfaceClassRepresentant(mesh[si].surfnr1);
int surfi2 = geom.GetSurfaceClassRepresentant(mesh[si].surfnr2);
if (si1.Contains(surfi1) && si2.Contains(surfi2) ||
si1.Contains(surfi2) && si2.Contains(surfi1))
// if (onedge)
{
segms.Append (i2);
// PrintMessage (5, "sing segment ", i2.I1(), " - ", i2.I2());
points.Append (mesh[ PointIndex (i2.I1())]);
points.Append (mesh[ PointIndex (i2.I2())]);
mesh[si].singedge_left = factor;
mesh[si].singedge_right = factor;
}
}
/*
(*testout) << "Singular edge points:" << endl;
for (int i = 0; i < points.Size(); i++)
(*testout) << points[i] << endl;
*/
}
void SingularEdge :: SetMeshSize (class Mesh & mesh, double globalh)
{
double hloc = pow (globalh, 1/beta);
if(maxhinit > 0 && maxhinit < hloc)
{
hloc = maxhinit;
if(points.Size() > 1)
{
for (int i = 0; i < points.Size()-1; i++)
mesh.RestrictLocalHLine(points[i],points[i+1],hloc);
}
else
{
for (int i = 0; i < points.Size(); i++)
mesh.RestrictLocalH (points[i], hloc);
}
}
else
{
for (int i = 0; i < points.Size(); i++)
mesh.RestrictLocalH (points[i], hloc);
}
}
SingularPoint :: SingularPoint (double abeta,
const Solid * asol1,
const Solid * asol2,
const Solid * asol3, double sf)
{
beta = abeta;
sol1 = asol1;
sol2 = asol2;
sol3 = asol3;
factor = sf;
}
void SingularPoint :: FindPoints (class Mesh & mesh)
{
points.SetSize(0);
ARRAY<int> surfk, surf;
for (PointIndex pi = PointIndex::BASE;
pi < mesh.GetNP()+PointIndex::BASE; pi++)
{
if (mesh[pi].Type() != FIXEDPOINT) continue;
const Point<3> p = mesh[pi];
(*testout) << "check singular point" << p << endl;
if (sol1->IsIn (p) && sol2->IsIn(p) && sol3->IsIn(p) &&
!sol1->IsStrictIn (p) && !sol2->IsStrictIn(p) && !sol3->IsStrictIn(p))
{
surf.SetSize (0);
for (int k = 1; k <= 3; k++)
{
const Solid * solk(NULL);
Solid *tansol;
switch (k)
{
case 1: solk = sol1; break;
case 2: solk = sol2; break;
case 3: solk = sol3; break;
}
solk -> TangentialSolid (p, tansol, surfk, 1e-3);
(*testout) << "Tansol = " << *tansol << endl;
if (!tansol) continue;
ReducePrimitiveIterator rpi(Box<3> (p-Vec<3> (1e-3,1e-3,1e-3),
p+Vec<3> (1e-3,1e-3,1e-3)));
UnReducePrimitiveIterator urpi;
tansol -> IterateSolid (rpi);
tansol->GetSurfaceIndices (surfk);
tansol -> IterateSolid (urpi);
(*testout) << "surfinds = " << surfk << endl;
for (int i = 0; i < surfk.Size(); i++)
if (!surf.Contains (surfk[i]))
surf.Append (surfk[i]);
delete tansol;
}
if (surf.Size() < 3) continue;
points.Append (p);
PrintMessage (5, "Point (", p(0), ", ", p(1), ", ", p(2), ") is singular");
mesh[pi].Singularity(factor);
}
}
}
void SingularPoint :: SetMeshSize (class Mesh & mesh, double globalh)
{
double hloc = pow (globalh, 1/beta);
for (int i = 1; i <= points.Size(); i++)
mesh.RestrictLocalH (points.Get(i), hloc);
}
}

View File

@ -0,0 +1,78 @@
#ifndef FILE_SINGULARREF
#define FILE_SINGULARREF
/**************************************************************************/
/* File: singularref.hh */
/* Author: Joachim Schoeberl */
/* Date: 25. Sep. 99 */
/**************************************************************************/
/**
Control for local refinement
*/
/**
Singular Face.
Causes a bounday layer mesh refinement.
All elements in subdomain domnr will get a boundary layer
on faces sharing the solid sol
*/
class SingularFace
{
public:
int domnr;
const Solid *sol;
double factor;
// ARRAY<Point<3> > points;
// ARRAY<INDEX_2> segms;
public:
SingularFace (int adomnr, const Solid * asol, double sf)
: domnr(adomnr), sol(asol), factor(sf) { ; }
const Solid * GetSolid() const { return sol; }
int GetDomainNr () const { return domnr; }
};
///
class SingularEdge
{
public:
double beta;
int domnr;
const CSGeometry& geom;
const Solid *sol1, *sol2;
ARRAY<Point<3> > points;
ARRAY<INDEX_2> segms;
double factor;
double maxhinit;
public:
SingularEdge (double abeta, int adomnr,
const CSGeometry & ageom,
const Solid * asol1, const Solid * asol2, double sf,
const double maxh_at_initialization = -1);
void FindPointsOnEdge (class Mesh & mesh);
void SetMeshSize (class Mesh & mesh, double globalh);
};
///
class SingularPoint
{
public:
double beta;
const Solid *sol1, *sol2, *sol3;
ARRAY<Point<3> > points;
double factor;
public:
SingularPoint (double abeta, const Solid * asol1, const Solid * asol2,
const Solid * asol3, double sf);
void FindPoints (class Mesh & mesh);
void SetMeshSize (class Mesh & mesh, double globalh);
};
#endif

1716
libsrc/csg/solid.cpp Normal file

File diff suppressed because it is too large Load Diff

241
libsrc/csg/solid.hpp Normal file
View File

@ -0,0 +1,241 @@
#ifndef FILE_SOLID
#define FILE_SOLID
/**************************************************************************/
/* File: solid.hh */
/* Author: Joachim Schoeberl */
/* Date: 1. Dez. 95 */
/**************************************************************************/
/*
Constructive Solid Model (csg)
*/
class Solid;
class SolidIterator
{
public:
SolidIterator () { ; }
virtual ~SolidIterator () { ; }
virtual void Do (Solid * sol) = 0;
};
class Solid
{
public:
typedef enum optyp1 { TERM, TERM_REF, SECTION, UNION, SUB, ROOT, DUMMY } optyp;
private:
char * name;
Primitive * prim;
Solid * s1, * s2;
optyp op;
bool visited;
double maxh;
// static int cntnames;
public:
Solid (Primitive * aprim);
Solid (optyp aop, Solid * as1, Solid * as2 = NULL);
~Solid ();
const char * Name () const { return name; }
void SetName (const char * aname);
Solid * Copy (class CSGeometry & geom) const;
void Transform (Transformation<3> & trans);
void IterateSolid (SolidIterator & it, bool only_once = 0);
void Boundaries (const Point<3> & p, ARRAY<int> & bounds) const;
int NumPrimitives () const;
void GetSurfaceIndices (ARRAY<int> & surfind) const;
void GetSurfaceIndices (IndexSet & iset) const;
void GetTangentialSurfaceIndices (const Point<3> & p, ARRAY<int> & surfids, double eps) const;
void GetTangentialSurfaceIndices2 (const Point<3> & p, const Vec<3> & v, ARRAY<int> & surfids, double eps) const;
void GetTangentialSurfaceIndices3 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, ARRAY<int> & surfids, double eps) const;
Primitive * GetPrimitive ()
{ return (op == TERM || op == TERM_REF) ? prim : NULL; }
const Primitive * GetPrimitive () const
{ return (op == TERM || op == TERM_REF) ? prim : NULL; }
Solid * S1() { return s1; }
Solid * S2() { return s2; }
// geometric tests
bool IsIn (const Point<3> & p, double eps = 1e-6) const;
bool IsStrictIn (const Point<3> & p, double eps = 1e-6) const;
bool VectorIn (const Point<3> & p, const Vec<3> & v, double eps = 1e-6) const;
bool VectorStrictIn (const Point<3> & p, const Vec<3> & v, double eps = 1e-6) const;
bool VectorIn2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,
double eps) const;
bool VectorIn2Rec (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,
double eps) const;
/// compute localization in point p
void TangentialSolid (const Point<3> & p, Solid *& tansol, ARRAY<int> & surfids, double eps) const;
/// compute localization in point p tangential to vector t
void TangentialSolid2 (const Point<3> & p, const Vec<3> & t,
Solid *& tansol, ARRAY<int> & surfids, double eps) const;
/** compute localization in point p, with second order approximation to edge
p + s t + s*s/2 t2 **/
void TangentialSolid3 (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2,
Solid *& tansol, ARRAY<int> & surfids, double eps) const;
/** tangential solid, which follows the edge
p + s t + s*s/2 t2
with second order, and the neighbouring face
p + s t + s*s/2 t2 + r m
with first order
**/
void TangentialEdgeSolid (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2,
const Vec<3> & m,
Solid *& tansol, ARRAY<int> & surfids, double eps) const;
void CalcOnePrimitiveSpecialPoints (const Box<3> & box, ARRAY<Point<3> > & pts) const;
///
int Edge (const Point<3> & p, const Vec<3> & v, double eps) const;
///
int OnFace (const Point<3> & p, const Vec<3> & v, double eps) const;
///
void Print (ostream & str) const;
///
void CalcSurfaceInverse ();
///
Solid * GetReducedSolid (const BoxSphere<3> & box) const;
void SetMaxH (double amaxh)
{ maxh = amaxh; }
double GetMaxH () const
{ return maxh; }
void GetSolidData (ostream & ost, int first = 1) const;
static Solid * CreateSolid (istream & ist, const SYMBOLTABLE<Solid*> & solids);
static BlockAllocator ball;
void * operator new(size_t /* s */)
{
return ball.Alloc();
}
void operator delete (void * p)
{
ball.Free (p);
}
protected:
///
void RecBoundaries (const Point<3> & p, ARRAY<int> & bounds,
int & in, int & strin) const;
///
void RecTangentialSolid (const Point<3> & p, Solid *& tansol, ARRAY<int> & surfids,
int & in, int & strin, double eps) const;
void RecTangentialSolid2 (const Point<3> & p, const Vec<3> & vec,
Solid *& tansol, ARRAY<int> & surfids,
int & in, int & strin, double eps) const;
///
void RecTangentialSolid3 (const Point<3> & p, const Vec<3> & vec,const Vec<3> & vec2,
Solid *& tansol, ARRAY<int> & surfids,
int & in, int & strin, double eps) const;
///
void RecTangentialEdgeSolid (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2,
const Vec<3> & m,
Solid *& tansol, ARRAY<int> & surfids,
int & in, int & strin, double eps) const;
///
void RecEdge (const Point<3> & p, const Vec<3> & v,
int & in, int & strin, int & faces, double eps) const;
///
void CalcSurfaceInverseRec (int inv);
///
Solid * RecGetReducedSolid (const BoxSphere<3> & box, INSOLID_TYPE & in) const;
///
void RecGetSurfaceIndices (ARRAY<int> & surfind) const;
void RecGetTangentialSurfaceIndices (const Point<3> & p, ARRAY<int> & surfids, double eps) const;
void RecGetTangentialSurfaceIndices2 (const Point<3> & p, const Vec<3> & v, ARRAY<int> & surfids, double eps) const;
void RecGetTangentialSurfaceIndices3 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2,
ARRAY<int> & surfids, double eps) const;
void RecGetTangentialEdgeSurfaceIndices (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, const Vec<3> & m,
ARRAY<int> & surfids, double eps) const;
void RecGetSurfaceIndices (IndexSet & iset) const;
void RecCalcOnePrimitiveSpecialPoints (ARRAY<Point<3> > & pts) const;
friend class SolidIterator;
friend class ClearVisitedIt;
friend class RemoveDummyIterator;
friend class CSGeometry;
};
inline ostream & operator<< (ostream & ost, const Solid & sol)
{
sol.Print (ost);
return ost;
}
class ReducePrimitiveIterator : public SolidIterator
{
const BoxSphere<3> & box;
public:
ReducePrimitiveIterator (const BoxSphere<3> & abox)
: SolidIterator(), box(abox) { ; }
virtual ~ReducePrimitiveIterator () { ; }
virtual void Do (Solid * sol)
{
if (sol -> GetPrimitive())
sol -> GetPrimitive() -> Reduce (box);
}
};
class UnReducePrimitiveIterator : public SolidIterator
{
public:
UnReducePrimitiveIterator () { ; }
virtual ~UnReducePrimitiveIterator () { ; }
virtual void Do (Solid * sol)
{
if (sol -> GetPrimitive())
sol -> GetPrimitive() -> UnReduce ();
}
};
#endif

1794
libsrc/csg/specpoin.cpp Normal file

File diff suppressed because it is too large Load Diff

174
libsrc/csg/specpoin.hpp Normal file
View File

@ -0,0 +1,174 @@
#ifndef FILE_SPECPOIN
#define FILE_SPECPOIN
/**************************************************************************/
/* File: specpoin.hpp */
/* Author: Joachim Schoeberl */
/* Date: 01. Okt. 95 */
/**************************************************************************/
/*
Special Point Calculation
*/
class Surface;
class Solid;
/// Special point.
class SpecialPoint
{
public:
/// coordinates
Point<3> p;
/// tangential to edge
Vec<3> v;
///
int layer;
/// point must be used in mesh
bool unconditional;
/// surfaces defining edge
int s1, s2;
/// if s1 and s2 are only representatives, then these are the original indices
int s1_orig, s2_orig;
int nr;
///
SpecialPoint () : p(0,0,0), v(0,0,0), layer(0), unconditional(0), s1(0), s2(0), s1_orig(0), s2_orig(0)
{ ; }
///
SpecialPoint (const SpecialPoint & sp2);
///
SpecialPoint & operator= (const SpecialPoint & sp2);
///
void Print (ostream & str) const;
int GetLayer() const { return layer; }
///
bool HasSurfaces (int as1, int as2) const
{
return ( (s1 == as1 && s2 == as2) || (s1 == as2 && s2 == as1) );
}
};
inline ostream & operator<< (ostream & ost, const SpecialPoint & sp)
{
sp.Print (ost);
return ost;
}
///
class SpecialPointCalculation
{
private:
///
const CSGeometry * geometry;
///
ARRAY<MeshPoint> * points;
///
ARRAY<long int> boxesinlevel;
///
double size;
///
double relydegtest; // maximal dimension of bisection intervall for
/// test of degeneration parameters
double cpeps1, epeps1, epeps2, epspointdist2;
double ideps;
public:
///
SpecialPointCalculation ();
///
void SetIdEps(const double epsin) {ideps = epsin;}
///
void CalcSpecialPoints (const CSGeometry & ageometry,
ARRAY<MeshPoint> & points);
///
void AnalyzeSpecialPoints (const CSGeometry & geometry,
ARRAY<MeshPoint> & points,
ARRAY<SpecialPoint> & specpoints);
protected:
///
void CalcSpecialPointsRec (const Solid * sol, int layer,
const BoxSphere<3> & box,
int level,
bool calccp, bool calcep);
///
bool CrossPointNewtonConvergence (const Surface * f1, const Surface * f2,
const Surface * f3, const BoxSphere<3> & box);
///
bool CrossPointDegenerated (const Surface * f1, const Surface * f2,
const Surface * f3, const BoxSphere<3> & box) const;
///
void CrossPointNewton (const Surface * f1, const Surface * f2,
const Surface * f3, Point<3> & p);
bool EdgeNewtonConvergence (const Surface * f1, const Surface * f2,
const Point<3> & p);
///
bool EdgeDegenerated (const Surface * f1, const Surface * f2,
const BoxSphere<3> & box) const;
///
void EdgeNewton (const Surface * f1, const Surface * f2,
Point<3> & p);
///
bool IsEdgeExtremalPoint (const Surface * f1, const Surface * f2,
const Point<3> & p, Point<3> & pp, double rad);
/*
///
bool ExtremalPointPossible (const Surface * f1, const Surface * f2,
int dir, const BoxSphere<3> & box);
///
bool ExtremalPointDegenerated (const Surface * f1, const Surface * f2,
int dir, const BoxSphere<3> & box);
///
bool ExtremalPointNewtonConvergence (const Surface * f1, const Surface * f2,
int dir, const BoxSphere<3> & box);
*/
///
void ExtremalPointNewton (const Surface * f1, const Surface * f2,
int dir, Point<3> & p);
///
bool AddPoint (const Point<3> & p, int layer);
void ComputeExtremalPoints (const Plane * plane,
const QuadraticSurface * quadric,
ARRAY<Point<3> > & pts);
void ComputeCrossPoints (const Plane * plane1,
const Plane * plane2,
const Plane * plane3,
ARRAY<Point<3> > & pts);
void ComputeCrossPoints (const Plane * plane1,
const Plane * plane2,
const QuadraticSurface * quadratic,
ARRAY<Point<3> > & pts);
};
#endif

355
libsrc/csg/spline3d.cpp Normal file
View File

@ -0,0 +1,355 @@
#include <mystdlib.h>
#include <myadt.hpp>
#include <linalg.hpp>
#include <csg.hpp>
namespace netgen
{
splinesegment3d :: splinesegment3d (const Point<3> & ap1, const Point<3> & ap2,
const Point<3> & ap3)
{
p1 = ap1;
p2 = ap2;
p3 = ap3;
}
/*
todo
Tip von Joerg Stiller:
setzt Du in
void splinesegment3d :: Evaluate
Zeilen 54 und 56
b2 = 2 * t * (1-t);
b2 /= sqrt(2);
Das heisst, Du wichtest das zweite Bersteinpolynom mit
w2 = 1 / sqrt(2);
Das ist aber nur fuer 45-Grad-Segmente korrekt. Fuer den
allgemeinen Fall funktioniert
w2 = ( e(p3 - p1), e(p2 - p1) ); // also cos(winkel(p3-p1, p2-p1))
bzw. schoen symmetrisch
w2 = ( e(p3 - p1), e(p2 - p1) )/2 + ( e(p1 - p3), e(p2 - p3) )/2;
Das ist natuerlich kein C++ Code sondern symbolisch, wobei
e(p3 - p1) ist der von p1 zu p3 zeigende Einheitsvektor und
(a, b) steht fuer das Skalarprodukt zweier Vektoren etc.
Eine vergleichbare Information steht auch irgendwo im Hoscheck & Lasser.
Ich habe das Buch aber eben nicht zur Hand.
*/
void splinesegment3d :: Evaluate (double t, Point<3> & p) const
{
double x, y, z, w;
double b1, b2, b3;
b1 = (1-t)*(1-t);
b2 = 2 * t * (1-t);
b3 = t * t;
b2 /= sqrt(double(2));
x = p1(0) * b1 + p2(0) * b2 + p3(0) * b3;
y = p1(1) * b1 + p2(1) * b2 + p3(1) * b3;
z = p1(2) * b1 + p2(2) * b2 + p3(2) * b3;
w = b1 + b2 + b3;
p(0) = x / w;
p(1) = y / w;
p(2) = z / w;
}
void splinesegment3d :: EvaluateTangent (double t, Vec<3> & tang) const
{
double x, y, z, w, xprime, yprime, zprime, wprime;
double b1, b2, b3, b1prime, b2prime, b3prime;
b1 = (1-t)*(1-t);
b2 = 2 * t * (1-t);
b3 = t * t;
b2 /= sqrt(double(2));
b1prime = 2 * t - 2;
b2prime = - 4 * t + 2;
b3prime = 2 * t;
b2prime /= sqrt(double(2));
x = p1(0) * b1 + p2(0) * b2 + p3(0) * b3;
y = p1(1) * b1 + p2(1) * b2 + p3(1) * b3;
z = p1(2) * b1 + p2(2) * b2 + p3(2) * b3;
w = b1 + b2 + b3;
xprime = p1(0) * b1prime + p2(0) * b2prime + p3(0) * b3prime;
yprime = p1(1) * b1prime + p2(1) * b2prime + p3(1) * b3prime;
zprime = p1(2) * b1prime + p2(2) * b2prime + p3(2) * b3prime;
wprime = b1prime + b2prime + b3prime;
tang(0) = (w * xprime - x * wprime) / (w * w);
tang(1) = (w * yprime - y * wprime) / (w * w);
tang(2) = (w * zprime - z * wprime) / (w * w);
}
void spline3d :: AddSegment (const Point<3> & ap1, const Point<3> & ap2,
const Point<3> & ap3)
{
segments.Append (new splinesegment3d (ap1, ap2, ap3));
}
void spline3d :: Evaluate (double t, Point<3> & p) const
{
int nr;
double loct;
static int cnt = 0;
cnt++;
if (cnt % 10000 == 0) (*mycout) << "Evaluate calls: " << cnt << endl;
while (t < 0) t += GetNumSegments();
while (t >= GetNumSegments()) t -= GetNumSegments();
nr = 1 + int (t);
loct = t - nr + 1;
segments.Get(nr)->Evaluate (loct, p);
}
void spline3d :: EvaluateTangent (double t, Vec<3> & tang) const
{
int nr;
double loct;
while (t < 0) t += GetNumSegments();
while (t >= GetNumSegments()) t -= GetNumSegments();
nr = 1 + int (t);
loct = t - nr + 1;
segments.Get(nr)->EvaluateTangent (loct, tang);
}
double spline3d :: ProjectToSpline (Point<3> & p) const
{
double t, tl, tu, dt, dist, mindist, optt(0);
Point<3> hp;
Vec<3> tanx, px;
dt = 0.01;
mindist = 0;
for (t = 0; t <= GetNumSegments() + dt/2; t += dt)
{
Evaluate (t, hp);
dist = Dist (hp, p);
if (t == 0 || dist < mindist)
{
optt = t;
mindist = dist;
}
}
tu = optt + dt;
tl = optt - dt;
while (tu - tl > 1e-2)
{
optt = 0.5 * (tu + tl);
Evaluate (optt, hp);
EvaluateTangent (optt, tanx);
if (tanx * (hp - p) > 0)
tu = optt;
else
tl = optt;
}
optt = 0.5 * (tu + tl);
optt = ProjectToSpline (p, optt);
return optt;
}
double spline3d :: ProjectToSpline (Point<3> & p, double optt) const
{
double tl, tu, dt, val, dval, valu, vall;
Point<3> hp;
Vec<3> tanx, px;
int its = 0;
int cnt = 1000;
do
{
dt = 1e-8;
tl = optt - dt;
tu = optt + dt;
EvaluateTangent (optt, tanx);
Evaluate (optt, hp);
px = hp - p;
val = px * tanx;
EvaluateTangent (tl, tanx);
Evaluate (tl, hp);
px = hp - p;
vall = px * tanx;
EvaluateTangent (tu, tanx);
Evaluate (tu, hp);
px = hp - p;
valu = px * tanx;
dval = (valu - vall) / (2 * dt);
if (its % 100 == 99)
(*testout) << "optt = " << optt
<< " val = " << val
<< " dval = " << dval << endl;
optt -= val / dval;
its++;
if (fabs(val) < 1e-8 && cnt > 5) cnt = 5;
cnt--;
}
while (cnt > 0);
Evaluate (optt, p);
return optt;
}
splinetube :: splinetube (const spline3d & amiddlecurve, double ar)
: Surface(), middlecurve (amiddlecurve), r(ar)
{
(*mycout) << "Splinetube Allocated, r = " << r << endl;
}
void splinetube :: DefineTangentialPlane (const Point<3> & ap1,
const Point<3> & ap2)
{
double t;
double phi, z;
p1 = ap1;
p2 = ap2;
cp = p1;
t = middlecurve.ProjectToSpline (cp);
ex = p1 - cp;
middlecurve.EvaluateTangent (t, ez);
ex.Normalize();
ez.Normalize();
ey = Cross (ez, ex);
phi = r * atan2 (ey * (p2-cp), ex * (p2-cp));
z = ez * (p2 - cp);
e2x(0) = phi;
e2x(1) = z;
e2x.Normalize();
e2y(1) = e2x(0);
e2y(0) = -e2x(1);
// (*testout) << "Defineplane: " << endl
// << "p1 = " << p1 << " p2 = " << p2 << endl
// << "pc = " << cp << endl
// << "ex = " << ex << " ey = " << ey << " ez = " << ez << endl
// << "phi = " << phi << " z = " << z << endl
// << "e2x = " << e2x << " e2y = " << e2y << endl;
}
void splinetube :: ToPlane (const Point<3> & p3d, Point<2> & pplain, double h,
int & zone) const
{
Vec<2> v;
v(0) = r * atan2 (ey * (p3d-cp), ex * (p3d-cp));
v(1) = ez * (p3d - cp);
zone = 0;
if (v(0) > r * 2) zone = 1;
if (v(0) < r * 2) zone = 2;
pplain(0) = (v * e2x) / h;
pplain(1) = (v * e2y) / h;
}
void splinetube :: FromPlane (const Point<2> & pplain, Point<3> & p3d, double h) const
{
Vec<2> v;
v(0) = pplain(0) * h * e2x(0) + pplain(1) * h * e2y(0);
v(1) = pplain(0) * h * e2x(1) + pplain(1) * h * e2y(1);
p3d = p1 + v(0) * ey + v(1) * ez;
Project (p3d);
}
void splinetube :: Project (Point<3> & p3d) const
{
Point<3> hp;
hp = p3d;
middlecurve.ProjectToSpline (hp);
p3d = hp + (r / Dist(p3d, hp)) * (p3d - hp);
}
double splinetube :: CalcFunctionValue (const Point<3> & point) const
{
Point<3> hcp;
double rad;
hcp = point;
middlecurve.ProjectToSpline (hcp);
rad = Dist (hcp, point);
return 0.5 * (rad * rad / r - r);
}
void splinetube :: CalcGradient (const Point<3> & point, Vec<3> & grad) const
{
Point<3> hcp;
hcp = point;
middlecurve.ProjectToSpline (hcp);
grad = point - hcp;
grad /= r;
}
Point<3> splinetube :: GetSurfacePoint () const
{
Point<3> p;
Vec<3> t, n;
middlecurve.Evaluate (0, p);
middlecurve.EvaluateTangent (0, t);
n = t.GetNormal ();
n *= r;
(*mycout) << "p = " << p << " t = " << t << " n = " << n << endl;
return p + n;
}
void splinetube :: Print (ostream & str) const
{
int i;
str << "SplineTube, "
<< middlecurve.GetNumSegments () << " segments, r = " << r << endl;
for (i = 1; i <= middlecurve.GetNumSegments(); i++)
str << middlecurve.P1(i) << " - "
<< middlecurve.P2(i) << " - "
<< middlecurve.P3(i) << endl;
}
int splinetube :: BoxInSolid (const BoxSphere<3> & box) const
// 0 .. no, 1 .. yes, 2 .. maybe
{
Point<3> pc = box.Center();
middlecurve.ProjectToSpline (pc);
double d = Dist (pc, box.Center());
if (d < r - box.Diam()/2) return 1;
if (d > r + box.Diam()/2) return 0;
return 2;
}
}

92
libsrc/csg/spline3d.hpp Normal file
View File

@ -0,0 +1,92 @@
///
class splinesegment3d
{
///
Point<3> p1, p2, p3;
public:
///
splinesegment3d (const Point<3> & ap1, const Point<3> & ap2,
const Point<3> & ap3);
///
void Evaluate (double t, Point<3> & p) const;
///
void EvaluateTangent (double t, Vec<3> & tang) const;
///
const Point<3> & P1() const { return p1; }
///
const Point<3> & P2() const { return p2; }
///
const Point<3> & P3() const { return p3; }
};
///
class spline3d
{
///
ARRAY<splinesegment3d *> segments;
public:
///
spline3d () { };
///
void AddSegment (const Point<3> & ap1, const Point<3> & ap2, const Point<3> & ap3);
///
int GetNumSegments () const { return segments.Size(); }
///
double ProjectToSpline (Point<3> & p) const;
///
double ProjectToSpline (Point<3> & p, double t) const;
///
void Evaluate (double t, Point<3> & p) const;
///
void EvaluateTangent (double t, Vec<3> & tang) const;
///
const Point<3> & P1(int i) const { return segments.Get(i)->P1(); }
///
const Point<3> & P2(int i) const { return segments.Get(i)->P2(); }
///
const Point<3> & P3(int i) const { return segments.Get(i)->P3(); }
};
///
class splinetube : public Surface
{
///
const spline3d & middlecurve;
///
double r;
/// Vec<3> ex, ey, ez;
Vec<2> e2x, e2y;
///
Point<3> cp;
public:
///
splinetube (const spline3d & amiddlecurve, double ar);
///
virtual void DefineTangentialPlane (const Point<3> & ap1, const Point<3> & ap2);
///
virtual void ToPlane (const Point<3> & p, Point<2> & pplain, double h, int & zone) const;
///
virtual void FromPlane (const Point<2> & pplain, Point<3> & p, double h) const;
///
virtual void Project (Point<3> & p) const;
// virtual int RootInBox (const box3d & box) const { return 0; }
/// 0 .. no, 1 .. yes, 2 .. maybe
virtual int BoxInSolid (const BoxSphere<3> & box) const;
/// 0 .. no, 1 .. yes, 2 .. maybe
virtual double CalcFunctionValue (const Point<3> & point) const;
///
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
///
virtual double HesseNorm () const { return 0.5 / r; }
///
virtual Point<3> GetSurfacePoint () const;
///
virtual void Print (ostream & str) const;
};

568
libsrc/csg/surface.cpp Normal file
View File

@ -0,0 +1,568 @@
#include <mystdlib.h>
#include <myadt.hpp>
#include <csg.hpp>
#include <linalg.hpp>
#include <meshing.hpp>
namespace netgen
{
Surface :: Surface ()
{
maxh = 1e10;
name = new char[7];
strcpy (name, "noname");
bcprop = -1;
bcname = "default";
}
Surface :: ~Surface()
{
delete [] name;
}
void Surface :: SetName (const char * aname)
{
delete [] name;
name = new char[strlen (aname)+1];
strcpy (name, aname);
}
int Surface :: PointOnSurface (const Point<3> & p,
double eps) const
{
double val = CalcFunctionValue (p);
return fabs (val) < eps;
}
void Surface :: CalcHesse (const Point<3> & point, Mat<3> & hesse) const
{
double dx = 1e-5;
Point<3> hp1, hp2;
Vec<3> g1, g2;
for (int i = 0; i < 3; i++)
{
hp1 = point;
hp2 = point;
hp1(i) += dx;
hp2(i) -= dx;
CalcGradient (hp1, g1);
CalcGradient (hp2, g2);
for (int j = 0; j < 3; j++)
hesse(i, j) = (g1(j) - g2(j)) / (2 * dx);
}
}
/*
void Surface :: GetNormalVector (const Point<3> & p, Vec<3> & n) const
{
CalcGradient (p, n);
n.Normalize();
}
*/
Vec<3> Surface :: GetNormalVector (const Point<3> & p) const
{
Vec<3> n;
CalcGradient (p, n);
n.Normalize();
return n;
}
void Surface :: DefineTangentialPlane (const Point<3> & ap1,
const Point<3> & ap2)
{
p1 = ap1;
p2 = ap2;
ez = GetNormalVector (p1);
ex = p2 - p1;
ex -= (ex * ez) * ez;
ex.Normalize();
ey = Cross (ez, ex);
}
void Surface :: ToPlane (const Point<3> & p3d, Point<2> & pplane,
double h, int & zone) const
{
Vec<3> p1p, n;
n = GetNormalVector (p3d);
if (n * ez < 0)
{
zone = -1;
pplane(0) = 1e8;
pplane(1) = 1e9;
return;
}
p1p = p3d - p1;
pplane(0) = (p1p * ex) / h;
pplane(1) = (p1p * ey) / h;
zone = 0;
}
void Surface :: FromPlane (const Point<2> & pplane,
Point<3> & p3d, double h) const
{
p3d = p1
+ (h * pplane(0)) * ex
+ (h * pplane(1)) * ey;
Project (p3d);
}
void Surface :: Project (Point<3> & p) const
{
Vec<3> n;
double val;
for (int i = 1; i <= 10; i++)
{
val = CalcFunctionValue (p);
if (fabs (val) < 1e-12) return;
CalcGradient (p, n);
p -= (val / Abs2 (n)) * n;
}
}
void Surface :: SkewProject (Point<3> & p, const Vec<3> & direction) const
{
Point<3> startp(p);
double t_old(0),t_new(1);
Vec<3> grad;
for(int i=0; fabs(t_old-t_new) > 1e-20 && i<15; i++)
{
t_old = t_new;
CalcGradient(p,grad);
t_new = t_old - CalcFunctionValue(p)/(grad*direction);
p = startp + t_new*direction;
}
}
double Surface :: MaxCurvature () const
{
return 0.5 * HesseNorm ();
}
double Surface ::
MaxCurvatureLoc (const Point<3> & /* c */ , double /* rad */) const
{
return MaxCurvature ();
}
double Surface :: LocH (const Point<3> & p, double x,
double c, double hmax) const
// finds h <= hmax, s.t. h * \kappa_x*h < c
{
/*
double h, hmin, kappa;
hmin = 0;
while (hmin < 0.9 * hmax)
{
h = 0.5 * (hmin + hmax);
kappa = 2 * MaxCurvatureLoc (p, x * h);
if (kappa * h >= c)
hmax = h;
else
hmin = h;
}
return h;
*/
double hret;
double kappa = MaxCurvatureLoc (p, x*hmax);
kappa *= c * mparam.curvaturesafety;
if (hmax * kappa < 1)
hret = hmax;
else
hret = 1 / kappa;
if (maxh < hret)
hret = maxh;
return hret;
}
Primitive :: Primitive ()
{
surfaceids.SetSize (1);
surfaceactive.SetSize (1);
surfaceactive[0] = 1;
}
Primitive :: ~Primitive()
{
;
}
int Primitive :: GetSurfaceId (int i) const
{
return surfaceids[i];
}
void Primitive :: SetSurfaceId (int i, int id)
{
surfaceids[i] = id;
}
void Primitive :: GetPrimitiveData (const char *& classname,
ARRAY<double> & coeffs) const
{
classname = "undef";
coeffs.SetSize (0);
}
void Primitive :: SetPrimitiveData (ARRAY<double> & coeffs)
{
;
}
Primitive * Primitive :: CreatePrimitive (const char * classname)
{
if (strcmp (classname, "sphere") == 0)
return Sphere::CreateDefault();
if (strcmp (classname, "plane") == 0)
return Plane::CreateDefault();
if (strcmp (classname, "cylinder") == 0)
return Cylinder::CreateDefault();
if (strcmp (classname, "cone") == 0)
return Cone::CreateDefault();
if (strcmp (classname, "brick") == 0)
return Brick::CreateDefault();
stringstream ost;
ost << "Primitve::CreatePrimitive not implemented for " << classname << endl;
throw NgException (ost.str());
}
Primitive * Primitive :: Copy () const
{
stringstream ost;
ost << "Primitve::Copy not implemented for " << typeid(*this).name() << endl;
throw NgException (ost.str());
}
void Primitive :: Transform (Transformation<3> & trans)
{
stringstream ost;
ost << "Primitve::Transform not implemented for " << typeid(*this).name() << endl;
throw NgException (ost.str());
}
void Primitive :: GetTangentialSurfaceIndices (const Point<3> & p,
ARRAY<int> & surfind, double eps) const
{
for (int j = 0; j < GetNSurfaces(); j++)
if (fabs (GetSurface(j).CalcFunctionValue (p)) < eps)
if (!surfind.Contains (GetSurfaceId(j)))
surfind.Append (GetSurfaceId(j));
}
void Primitive ::
GetTangentialVecSurfaceIndices (const Point<3> & p, const Vec<3> & v,
ARRAY<int> & surfind, double eps) const
{
cout << "get tangvecsurfind not implemented" << endl;
surfind.SetSize (0);
}
void Primitive ::
GetTangentialVecSurfaceIndices2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,
ARRAY<int> & surfind, double eps) const
{
for (int j = 0; j < GetNSurfaces(); j++)
{
if (fabs (GetSurface(j).CalcFunctionValue (p)) < eps)
{
Vec<3> grad;
GetSurface(j).CalcGradient (p, grad);
if (sqr (grad * v1) < 1e-6 * v1.Length2() * grad.Length2() &&
sqr (grad * v2) < 1e-6 * v2.Length2() * grad.Length2() ) // new, 18032006 JS
{
if (!surfind.Contains (GetSurfaceId(j)))
surfind.Append (GetSurfaceId(j));
}
}
}
}
INSOLID_TYPE Primitive ::
VecInSolid2 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const
{
//(*testout) << "Primitive::VecInSolid2" << endl;
Point<3> hp = p + 1e-3 * v1 + 1e-5 * v2;
INSOLID_TYPE res = PointInSolid (hp, eps);
// (*testout) << "vectorin2, type = " << typeid(*this).name() << ", res = " << res << endl;
return res;
}
INSOLID_TYPE Primitive ::
VecInSolid3 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const
{
//(*testout) << "Primitive::VecInSolid3" << endl;
return VecInSolid (p, v1, eps);
}
INSOLID_TYPE Primitive ::
VecInSolid4 (const Point<3> & p,
const Vec<3> & v,
const Vec<3> & v2,
const Vec<3> & m,
double eps) const
{
return VecInSolid2 (p, v, m, eps);
}
OneSurfacePrimitive :: OneSurfacePrimitive()
{
;
}
OneSurfacePrimitive :: ~OneSurfacePrimitive()
{
;
}
INSOLID_TYPE OneSurfacePrimitive ::
PointInSolid (const Point<3> & p,
double eps) const
{
double hv1 = (GetSurface(0).CalcFunctionValue(p));
if (hv1 <= -eps)
return IS_INSIDE;
if (hv1 >= eps)
return IS_OUTSIDE;
return DOES_INTERSECT;
}
INSOLID_TYPE OneSurfacePrimitive ::
VecInSolid (const Point<3> & p, const Vec<3> & v,
double eps) const
{
double hv1 = (GetSurface(0).CalcFunctionValue(p));
if (hv1 <= -eps)
return IS_INSIDE;
if (hv1 >= eps)
return IS_OUTSIDE;
Vec<3> hv;
GetSurface(0).CalcGradient (p, hv);
hv1 = v * hv;
if (hv1 <= -eps)
return IS_INSIDE;
if (hv1 >= eps)
return IS_OUTSIDE;
return DOES_INTERSECT;
}
INSOLID_TYPE OneSurfacePrimitive ::
VecInSolid2 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const
{
double hv1 = (GetSurface(0).CalcFunctionValue(p));
if (hv1 <= -eps)
return IS_INSIDE;
if (hv1 >= eps)
return IS_OUTSIDE;
Vec<3> hv;
GetSurface(0).CalcGradient (p, hv);
hv1 = v1 * hv;
if (hv1 <= -eps)
return IS_INSIDE;
if (hv1 >= eps)
return IS_OUTSIDE;
double hv2 = v2 * hv;
if (hv2 <= 0)
return IS_INSIDE;
else
return IS_OUTSIDE;
}
INSOLID_TYPE OneSurfacePrimitive ::
VecInSolid3 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2,
double eps) const
{
//(*testout) << "OneSurfacePrimitive::VecInSolid3" << endl;
double hv1 = (GetSurface(0).CalcFunctionValue(p));
if (hv1 <= -eps)
return IS_INSIDE;
if (hv1 >= eps)
return IS_OUTSIDE;
Vec<3> grad;
GetSurface(0).CalcGradient (p, grad);
hv1 = v * grad;
if (hv1 <= -eps) return IS_INSIDE;
if (hv1 >= eps) return IS_OUTSIDE;
Mat<3> hesse;
GetSurface(0).CalcHesse (p, hesse);
double hv2 = v2 * grad + v * (hesse * v);
if (hv2 <= -eps) return IS_INSIDE;
if (hv2 >= eps) return IS_OUTSIDE;
return DOES_INTERSECT;
}
INSOLID_TYPE OneSurfacePrimitive ::
VecInSolid4 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2,
const Vec<3> & m,
double eps) const
{
double hv1 = (GetSurface(0).CalcFunctionValue(p));
if (hv1 <= -eps)
return IS_INSIDE;
if (hv1 >= eps)
return IS_OUTSIDE;
Vec<3> grad;
GetSurface(0).CalcGradient (p, grad);
hv1 = v * grad;
if (hv1 <= -eps) return IS_INSIDE;
if (hv1 >= eps) return IS_OUTSIDE;
Mat<3> hesse;
GetSurface(0).CalcHesse (p, hesse);
double hv2 = v2 * grad + v * (hesse * v);
if (hv2 <= -eps) return IS_INSIDE;
if (hv2 >= eps) return IS_OUTSIDE;
double hv3 = m * grad;
if (hv3 <= -eps) return IS_INSIDE;
if (hv3 >= eps) return IS_OUTSIDE;
return DOES_INTERSECT;
}
int OneSurfacePrimitive :: GetNSurfaces() const
{
return 1;
}
Surface & OneSurfacePrimitive :: GetSurface (int i)
{
return *this;
}
const Surface & OneSurfacePrimitive :: GetSurface (int i) const
{
return *this;
}
void ProjectToEdge (const Surface * f1, const Surface * f2, Point<3> & hp)
{
Vec<2> rs, lam;
Vec<3> a1, a2;
Mat<2> a;
int i = 10;
while (i > 0)
{
i--;
rs(0) = f1 -> CalcFunctionValue (hp);
rs(1) = f2 -> CalcFunctionValue (hp);
f1->CalcGradient (hp, a1);
f2->CalcGradient (hp, a2);
double alpha = fabs(a1*a2)/sqrt(a1.Length2()*a2.Length2());
if(fabs(1.-alpha) < 1e-6)
{
if(fabs(rs(0)) >= fabs(rs(1)))
f1 -> Project(hp);
else
f2 -> Project(hp);
}
else
{
a(0,0) = a1 * a1;
a(0,1) = a(1,0) = a1 * a2;
a(1,1) = a2 * a2;
a.Solve (rs, lam);
hp -= lam(0) * a1 + lam(1) * a2;
}
if (Abs2 (rs) < 1e-24 && i > 1) i = 1;
}
}
}

357
libsrc/csg/surface.hpp Normal file
View File

@ -0,0 +1,357 @@
#ifndef FILE_SURFACE
#define FILE_SURFACE
/**************************************************************************/
/* File: surface.hh */
/* Author: Joachim Schoeberl */
/* Date: 1. Dez. 95 */
/**************************************************************************/
// class DenseMatrix;
// class Box3dSphere;
class TriangleApproximation;
/**
Basis class for implicit surface geometry.
This class is used for generation of surface meshes
in NETGEN as well as for mesh refinement in FEPP.
*/
class Surface
{
protected:
/// invert normal vector
bool inverse;
/// maximal h in surface
double maxh;
/// name of surface
char * name;
/// boundary condition nr
int bcprop;
///
string bcname;
public:
Surface ();
/** @name Tangential plane.
The tangential plane is used for surface mesh generation.
*/
virtual ~Surface();
protected:
/** @name Points in the surface defining tangential plane.
Tangential plane is taken in p1, the local x-axis
is directed to p2.
*/
//@{
///
Point<3> p1;
///
Point<3> p2;
//@}
/** @name Base-vectos for local coordinate system. */
//@{
/// in plane, directed p1->p2
Vec<3> ex;
/// in plane
Vec<3> ey;
/// outer normal direction
Vec<3> ez;
//@}
public:
void SetName (const char * aname);
const char * Name () const { return name; }
//@{
/**
Defines tangential plane in ap1.
The local x-coordinate axis point to the direction of ap2 */
virtual void DefineTangentialPlane (const Point<3> & ap1,
const Point<3> & ap2);
/// Transforms 3d point p3d to local coordinates pplane
virtual void ToPlane (const Point<3> & p3d, Point<2> & pplane,
double h, int & zone) const;
/// Transforms point pplane in local coordinates to 3d point
virtual void FromPlane (const Point<2> & pplane,
Point<3> & p3d, double h) const;
//@}
/// Move Point p to closes point in surface
virtual void Project (Point<3> & p) const;
///
virtual void SkewProject(Point<3> & p, const Vec<3> & direction) const;
virtual int IsIdentic (const Surface & /* s2 */, int & /* inv */,
double /* eps */) const
{ return 0; }
///
virtual int PointOnSurface (const Point<3> & p,
double eps = 1e-6) const;
/** @name Implicit function.
Calculate function value and derivatives.
*/
//@{
/// Calculate implicit function value in point point
virtual double CalcFunctionValue (const Point<3> & point) const = 0;
/**
Calc gradient of implicit function.
gradient should be O(1) at surface
*/
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const = 0;
/**
Calculate second derivatives of implicit function.
*/
virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const;
/**
Returns outer normal vector.
*/
// virtual void GetNormalVector (const Point<3> & p, Vec<3> & n) const;
virtual Vec<3> GetNormalVector (const Point<3> & p) const;
/**
Upper bound for spectral norm of Hesse-matrix
*/
virtual double HesseNorm () const = 0;
/**
Upper bound for spectral norm of Hesse-matrix in the
rad - environment of point c.
*/
virtual double HesseNormLoc (const Point<3> & /* c */,
double /* rad */) const
{ return HesseNorm (); }
//@}
///
virtual double MaxCurvature () const;
///
virtual double MaxCurvatureLoc (const Point<3> & /* c */ ,
double /* rad */) const;
/** Returns any point in the surface.
Needed to start surface mesh generation e.g. on sphere */
virtual Point<3> GetSurfacePoint () const = 0;
///
bool Inverse () const { return inverse; }
///
void SetInverse (bool ainverse) { inverse = ainverse; }
///
virtual void Print (ostream & str) const = 0;
///
virtual void Reduce (const BoxSphere<3> & /* box */) { };
///
virtual void UnReduce () { };
/// set max h in surface
void SetMaxH (double amaxh) { maxh = amaxh; }
///
double GetMaxH () const { return maxh; }
///
int GetBCProperty () const { return bcprop; }
///
void SetBCProperty (int abc) { bcprop = abc; }
/** Determine local mesh-size.
Find
\[ h \leq hmax, \]
such that
\[ h \times \kappa (x) \leq c \qquad \mbox{in} B(x, h), \]
where kappa(x) is the curvature in x. */
virtual double LocH (const Point<3> & p, double x,
double c, double hmax) const;
/**
Gets Approximation by triangles,
where qual is about the number of triangles per radius
*/
virtual void GetTriangleApproximation (TriangleApproximation & /* tas */,
const Box<3> & /* boundingbox */,
double /* facets */ ) const { };
#ifdef MYGRAPH
///
virtual void Plot (const class ROT3D & /* rot */) const { };
#endif
string GetBCName() const { return bcname; }
void SetBCName( string abc ) { bcname = abc; }
};
inline ostream & operator<< (ostream & ost, const Surface & surf)
{
surf.Print(ost);
return ost;
}
typedef enum { IS_OUTSIDE = 0, IS_INSIDE = 1, DOES_INTERSECT = 2}
INSOLID_TYPE;
class Primitive
{
public:
Primitive ();
virtual ~Primitive();
/*
Check, whether box intersects solid defined by surface.
return values:
0 .. box outside solid \\
1 .. box in solid \\
2 .. can't decide (allowed, iff box is close to solid)
*/
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const = 0;
virtual INSOLID_TYPE PointInSolid (const Point<3> & p,
double eps) const = 0;
virtual void GetTangentialSurfaceIndices (const Point<3> & p,
ARRAY<int> & surfind, double eps) const;
virtual INSOLID_TYPE VecInSolid (const Point<3> & p,
const Vec<3> & v,
double eps) const = 0;
// checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid
virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const;
// checks if p + s v1 + s*s/2 v2 is inside
virtual INSOLID_TYPE VecInSolid3 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const;
// like VecInSolid2, but second order approximation
virtual INSOLID_TYPE VecInSolid4 (const Point<3> & p,
const Vec<3> & v,
const Vec<3> & v2,
const Vec<3> & m,
double eps) const;
virtual void GetTangentialVecSurfaceIndices (const Point<3> & p, const Vec<3> & v,
ARRAY<int> & surfind, double eps) const;
virtual void GetTangentialVecSurfaceIndices2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,
ARRAY<int> & surfind, double eps) const;
virtual void CalcSpecialPoints (ARRAY<Point<3> > & /* pts */) const { ; }
virtual void AnalyzeSpecialPoint (const Point<3> & /* pt */,
ARRAY<Point<3> > & /* specpts */) const { ; }
virtual Vec<3> SpecialPointTangentialVector (const Point<3> & /* p */,
int /* s1 */, int /* s2 */) const
{ return Vec<3> (0,0,0); }
virtual int GetNSurfaces() const = 0;
virtual Surface & GetSurface (int i = 0) = 0;
virtual const Surface & GetSurface (int i = 0) const = 0;
ARRAY<int> surfaceids;
ARRAY<int> surfaceactive;
int GetSurfaceId (int i = 0) const;
void SetSurfaceId (int i, int id);
int SurfaceActive (int i) const { return surfaceactive[i]; }
virtual int SurfaceInverted (int /* i */ = 0) const { return 0; }
virtual void GetPrimitiveData (const char *& classname,
ARRAY<double> & coeffs) const;
virtual void SetPrimitiveData (ARRAY<double> & coeffs);
static Primitive * CreatePrimitive (const char * classname);
virtual void Reduce (const BoxSphere<3> & /* box */) { };
virtual void UnReduce () { };
virtual Primitive * Copy () const;
virtual void Transform (Transformation<3> & trans);
};
class OneSurfacePrimitive : public Surface, public Primitive
{
public:
OneSurfacePrimitive();
~OneSurfacePrimitive();
virtual INSOLID_TYPE PointInSolid (const Point<3> & p,
double eps) const;
virtual INSOLID_TYPE VecInSolid (const Point<3> & p,
const Vec<3> & v,
double eps) const;
virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const;
virtual INSOLID_TYPE VecInSolid3 (const Point<3> & p,
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const;
virtual INSOLID_TYPE VecInSolid4 (const Point<3> & p,
const Vec<3> & v,
const Vec<3> & v2,
const Vec<3> & m,
double eps) const;
virtual int GetNSurfaces() const;
virtual Surface & GetSurface (int i = 0);
virtual const Surface & GetSurface (int i = 0) const;
};
/**
Projects point to edge.
The point hp is projected to the edge descibed by f1 and f2.
It is assumed that the edge is non-degenerated, and the
(generalized) Newton method converges.
*/
extern void ProjectToEdge (const Surface * f1,
const Surface * f2,
Point<3> & hp);
#endif

59
libsrc/csg/triapprox.cpp Normal file
View File

@ -0,0 +1,59 @@
#include <mystdlib.h>
#include <myadt.hpp>
#include <linalg.hpp>
#include <csg.hpp>
namespace netgen
{
TriangleApproximation :: TriangleApproximation ()
{
;
}
int TriangleApproximation ::
AddTriangle (const TATriangle & tri, bool invert)
{
trigs.Append (tri);
if (invert)
{
trigs.Last()[1] = tri[2];
trigs.Last()[2] = tri[1];
}
return trigs.Size()-1;
}
void TriangleApproximation :: RemoveUnusedPoints ()
{
BitArray used(GetNP());
ARRAY<int> map (GetNP());
int i, j;
int cnt = 0;
used.Clear();
for (i = 0; i < GetNT(); i++)
for (j = 0; j < 3; j++)
used.Set (GetTriangle (i)[j]);
for (i = 0; i < GetNP(); i++)
if (used.Test(i))
map[i] = cnt++;
for (i = 0; i < GetNT(); i++)
for (j = 0; j < 3; j++)
trigs[i][j] = map[trigs[i][j]];
for (i = 0; i < GetNP(); i++)
if (used.Test(i))
{
points[map[i]] = points[i];
normals[map[i]] = normals[i];
}
points.SetSize (cnt);
normals.SetSize (cnt);
}
}

57
libsrc/csg/triapprox.hpp Normal file
View File

@ -0,0 +1,57 @@
#ifndef FILE_TRIAPPROX
#define FILE_TRIAPPROX
/**************************************************************************/
/* File: triapprox.hh */
/* Author: Joachim Schoeberl */
/* Date: 2. Mar. 98 */
/**************************************************************************/
/**
Triangulated approxiamtion to true surface
*/
class TATriangle
{
int pi[3];
int surfind;
public:
TATriangle () { ; }
TATriangle (int si, int pi1, int pi2, int pi3)
{ surfind = si; pi[0] = pi1; pi[1] = pi2; pi[2] = pi3; }
int SurfaceIndex() const { return surfind; }
int & SurfaceIndex() { return surfind; }
int & operator[] (int i) { return pi[i]; }
const int & operator[] (int i) const { return pi[i]; }
};
class TriangleApproximation
{
ARRAY<Point<3> > points;
ARRAY<Vec<3> > normals;
ARRAY<TATriangle> trigs;
public:
TriangleApproximation();
int GetNP () const { return points.Size(); }
int GetNT () const { return trigs.Size(); }
int AddPoint (const Point<3> & p) { points.Append (p); return points.Size()-1; }
int AddNormal (const Vec<3> & n) { normals.Append (n); return normals.Size()-1; }
int AddTriangle (const TATriangle & tri, bool invert = 0);
const Point<3> & GetPoint (int i) const { return points[i]; }
const TATriangle & GetTriangle (int i) const { return trigs[i]; }
const Vec<3> & GetNormal (int i) const { return normals[i]; }
void RemoveUnusedPoints ();
friend class CSGeometry;
};
#endif

View File

@ -0,0 +1,6 @@
INCLUDES = -I$(top_srcdir)/libsrc/include
METASOURCES = AUTO
noinst_LIBRARIES = libgeneral.a
libgeneral_a_SOURCES = array.cpp bitarray.cpp dynamicmem.cpp flags.cpp \
hashtabl.cpp moveablemem.cpp mystring.cpp ngexception.cpp optmem.cpp parthreads.cpp \
profiler.cpp seti.cpp sort.cpp spbita2d.cpp symbolta.cpp table.cpp

462
libsrc/general/Makefile.in Normal file
View File

@ -0,0 +1,462 @@
# Makefile.in generated by automake 1.10.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = libsrc/general
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
LIBRARIES = $(noinst_LIBRARIES)
ARFLAGS = cru
libgeneral_a_AR = $(AR) $(ARFLAGS)
libgeneral_a_LIBADD =
am_libgeneral_a_OBJECTS = array.$(OBJEXT) bitarray.$(OBJEXT) \
dynamicmem.$(OBJEXT) flags.$(OBJEXT) hashtabl.$(OBJEXT) \
moveablemem.$(OBJEXT) mystring.$(OBJEXT) ngexception.$(OBJEXT) \
optmem.$(OBJEXT) parthreads.$(OBJEXT) profiler.$(OBJEXT) \
seti.$(OBJEXT) sort.$(OBJEXT) spbita2d.$(OBJEXT) \
symbolta.$(OBJEXT) table.$(OBJEXT)
libgeneral_a_OBJECTS = $(am_libgeneral_a_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(libgeneral_a_SOURCES)
DIST_SOURCES = $(libgeneral_a_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
INCLUDES = -I$(top_srcdir)/libsrc/include
METASOURCES = AUTO
noinst_LIBRARIES = libgeneral.a
libgeneral_a_SOURCES = array.cpp bitarray.cpp dynamicmem.cpp flags.cpp \
hashtabl.cpp moveablemem.cpp mystring.cpp ngexception.cpp optmem.cpp parthreads.cpp \
profiler.cpp seti.cpp sort.cpp spbita2d.cpp symbolta.cpp table.cpp
all: all-am
.SUFFIXES:
.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libsrc/general/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu libsrc/general/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
libgeneral.a: $(libgeneral_a_OBJECTS) $(libgeneral_a_DEPENDENCIES)
-rm -f libgeneral.a
$(libgeneral_a_AR) libgeneral.a $(libgeneral_a_OBJECTS) $(libgeneral_a_LIBADD)
$(RANLIB) libgeneral.a
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bitarray.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynamicmem.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flags.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hashtabl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/moveablemem.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mystring.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ngexception.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/optmem.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parthreads.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/profiler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/seti.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sort.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spbita2d.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symbolta.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table.Po@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cpp.lo:
@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LIBRARIES)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-exec-am:
install-html: install-html-am
install-info: install-info-am
install-man:
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstLIBRARIES ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

75
libsrc/general/array.cpp Normal file
View File

@ -0,0 +1,75 @@
#ifndef FILE_NGSTD_ARRAYCPP
#define FILE_NGSTD_ARRAYCPP
// necessary for SGI ????
/**************************************************************************/
/* File: array.cpp */
/* Author: Joachim Schoeberl */
/* Date: 01. Jun. 95 */
/**************************************************************************/
/*
Abstract data type ARRAY
*/
#include <mystdlib.h>
#include <myadt.hpp>
#include <assert.h>
namespace netgen
{
//using namespace netgen;
#ifdef NONE
void BASE_ARRAY :: ReSize (int minsize, int elementsize)
{
cout << "resize, minsize = " << minsize << endl;
if (inc == -1)
throw Exception ("Try to resize fixed size array");
void * p;
int nsize = (inc) ? allocsize + inc : 2 * allocsize;
if (nsize < minsize) nsize = minsize;
if (data)
{
p = new char [nsize * elementsize];
int mins = (nsize < actsize) ? nsize : actsize;
memcpy (p, data, mins * elementsize);
delete [] static_cast<char*> (data);
data = p;
}
else
{
data = new char[nsize * elementsize];
}
allocsize = nsize;
cout << "resize done" << endl;
}
void BASE_ARRAY :: RangeCheck (int i) const
{
if (i < 0 || i >= actsize)
throw ArrayRangeException ();
}
void BASE_ARRAY :: CheckNonEmpty () const
{
if (!actsize)
{
throw Exception ("Array should not be empty");
// cerr << "Array souldn't be empty";
}
}
#endif
}
#endif

638
libsrc/general/array.hpp Normal file
View File

@ -0,0 +1,638 @@
#ifndef FILE_ARRAY
#define FILE_ARRAY
/**************************************************************************/
/* File: array.hpp */
/* Author: Joachim Schoeberl */
/* Date: 01. Jun. 95 */
/**************************************************************************/
// template <class T, int B1, int B2> class IndirectArray;
/**
A simple array container.
Array represented by size and data-pointer.
No memory allocation and deallocation, must be provided by user.
Helper functions for printing.
Optional range check by macro RANGE_CHECK
*/
template <class T, int BASE = 0>
class FlatArray
{
protected:
/// the size
int size;
/// the data
T * data;
public:
/// provide size and memory
FlatArray (int asize, T * adata)
: size(asize), data(adata) { ; }
/// the size
int Size() const { return size; }
int Begin() const { return BASE; }
int End() const { return size+BASE; }
/*
/// access array.
T & operator[] (int i)
{
#ifdef DEBUG
if (i-BASE < 0 || i-BASE >= size)
cout << "array<" << typeid(T).name() << "> out of range, i = " << i << ", s = " << size << endl;
#endif
return data[i-BASE];
}
*/
/// Access array. BASE-based
T & operator[] (int i) const
{
#ifdef DEBUG
if (i-BASE < 0 || i-BASE >= size)
cout << "array<" << typeid(T).name() << "> out of range, i = " << i << ", s = " << size << endl;
#endif
return data[i-BASE];
}
/*
template <int B2>
IndirectArray<T, BASE, B2> operator[] (const FlatArray<int, B2> & ind)
{ return IndirectArray<T, BASE, B2> (*this, ind); }
*/
/// Access array, one-based (old fashioned)
T & Elem (int i)
{
#ifdef DEBUG
if (i < 1 || i > size)
cout << "ARRAY<" << typeid(T).name()
<< ">::Elem out of range, i = " << i
<< ", s = " << size << endl;
#endif
return ((T*)data)[i-1];
}
/// Access array, one-based (old fashioned)
const T & Get (int i) const
{
#ifdef DEBUG
if (i < 1 || i > size)
cout << "ARRAY<" << typeid(T).name() << ">::Get out of range, i = " << i
<< ", s = " << size << endl;
#endif
return ((const T*)data)[i-1];
}
/// Access array, one-based (old fashioned)
void Set (int i, const T & el)
{
#ifdef DEBUG
if (i < 1 || i > size)
cout << "ARRAY<" << typeid(T).name() << ">::Set out of range, i = " << i
<< ", s = " << size << endl;
#endif
((T*)data)[i-1] = el;
}
/// access first element
T & First () const
{
return data[0];
}
/// access last element. check by macro CHECK_RANGE
T & Last () const
{
return data[size-1];
}
/// Fill array with value val
FlatArray & operator= (const T & val)
{
for (int i = 0; i < size; i++)
data[i] = val;
return *this;
}
/// takes range starting from position start of end-start elements
const FlatArray<T> Range (int start, int end)
{
return FlatArray<T> (end-start, data+start);
}
/// first position of element elem, returns -1 if element not contained in array
int Pos(const T & elem) const
{
int pos = -1;
for(int i=0; pos==-1 && i < this->size; i++)
if(elem == data[i]) pos = i;
return pos;
}
/// does the array contain element elem ?
bool Contains(const T & elem) const
{
return ( Pos(elem) >= 0 );
}
};
// print array
template <class T, int BASE>
inline ostream & operator<< (ostream & s, const FlatArray<T,BASE> & a)
{
for (int i = a.Begin(); i < a.End(); i++)
s << i << ": " << a[i] << endl;
return s;
}
/**
Dynamic array container.
ARRAY<T> is an automatically increasing array container.
The allocated memory doubles on overflow.
Either the container takes care of memory allocation and deallocation,
or the user provides one block of data.
*/
template <class T, int BASE = 0>
class ARRAY : public FlatArray<T, BASE>
{
protected:
/// physical size of array
int allocsize;
/// memory is responsibility of container
bool ownmem;
public:
/// Generate array of logical and physical size asize
explicit ARRAY(int asize = 0)
: FlatArray<T, BASE> (asize, asize ? new T[asize] : 0)
{
allocsize = asize;
ownmem = 1;
}
/// Generate array in user data
ARRAY(int asize, T* adata)
: FlatArray<T, BASE> (asize, adata)
{
allocsize = asize;
ownmem = 0;
}
/// array copy
explicit ARRAY (const ARRAY<T> & a2)
: FlatArray<T, BASE> (a2.Size(), a2.Size() ? new T[a2.Size()] : 0)
{
allocsize = this->size;
ownmem = 1;
for (int i = BASE; i < this->size+BASE; i++)
(*this)[i] = a2[i];
}
/// if responsible, deletes memory
~ARRAY()
{
if (ownmem)
delete [] this->data;
}
/// Change logical size. If necessary, do reallocation. Keeps contents.
void SetSize(int nsize)
{
if (nsize > allocsize)
ReSize (nsize);
this->size = nsize;
}
/// Change physical size. Keeps logical size. Keeps contents.
void SetAllocSize (int nallocsize)
{
if (nallocsize > allocsize)
ReSize (nallocsize);
}
/// Add element at end of array. reallocation if necessary.
int Append (const T & el)
{
if (this->size == allocsize)
ReSize (this->size+1);
this->data[this->size] = el;
this->size++;
return this->size;
}
template <typename T2, int B2>
void Append (FlatArray<T2, B2> a2)
{
if (this->size+a2.Size() > allocsize)
ReSize (this->size+a2.Size());
for (int i = 0; i < a2.Size(); i++)
this->data[this->size+i] = a2[i+B2];
this->size += a2.Size();
}
/*
template <int B1, int B2>
void Append (const IndirectArray<T,B1,B2> & a2)
{
if (this->size+a2.Size() > allocsize)
ReSize (this->size+a2.Size());
for (int i = 0; i < a2.Size(); i++)
this->data[this->size+i] = a2[i+B2];
this->size += a2.Size();
}
*/
/// Delete element i (0-based). Move last element to position i.
void Delete (int i)
{
#ifdef CHECK_ARRAY_RANGE
RangeCheck (i+1);
#endif
this->data[i] = this->data[this->size-1];
this->size--;
// DeleteElement (i+1);
}
/// Delete element i (1-based). Move last element to position i.
void DeleteElement (int i)
{
#ifdef CHECK_ARRAY_RANGE
RangeCheck (i);
#endif
this->data[i-1] = this->data[this->size-1];
this->size--;
}
/// Delete last element.
void DeleteLast ()
{
this->size--;
}
/// Deallocate memory
void DeleteAll ()
{
if (ownmem)
delete [] this->data;
this->data = 0;
this->size = allocsize = 0;
}
/// Fill array with val
ARRAY & operator= (const T & val)
{
FlatArray<T, BASE>::operator= (val);
return *this;
}
/// array copy
ARRAY & operator= (const ARRAY & a2)
{
SetSize (a2.Size());
for (int i = BASE; i < this->size+BASE; i++)
(*this)[i] = a2[i];
return *this;
}
/// array copy
ARRAY & operator= (const FlatArray<T> & a2)
{
SetSize (a2.Size());
for (int i = BASE; i < this->size+BASE; i++)
(*this)[i] = a2[i];
return *this;
}
private:
/// resize array, at least to size minsize. copy contents
void ReSize (int minsize)
{
int nsize = 2 * allocsize;
if (nsize < minsize) nsize = minsize;
if (this->data)
{
T * p = new T[nsize];
int mins = (nsize < this->size) ? nsize : this->size;
memcpy (p, this->data, mins * sizeof(T));
if (ownmem)
delete [] this->data;
ownmem = 1;
this->data = p;
}
else
{
this->data = new T[nsize];
ownmem = 1;
}
allocsize = nsize;
}
};
template <class T, int S>
class ArrayMem : public ARRAY<T>
{
// T mem[S]; // Intel C++ calls dummy constructor
// char mem[S*sizeof(T)];
double mem[(S*sizeof(T)+7) / 8];
public:
/// Generate array of logical and physical size asize
explicit ArrayMem(int asize = 0)
: ARRAY<T> (S, static_cast<T*> (static_cast<void*>(&mem[0])))
{
this->size = asize;
if (asize > S)
{
this->data = new T[asize];
this->ownmem = 1;
}
// this->SetSize (asize);
}
ArrayMem & operator= (const T & val)
{
ARRAY<T>::operator= (val);
return *this;
}
};
/*
template <class T, int B1, int B2>
class IndirectArray
{
const FlatArray<T, B1> & array;
const FlatArray<int, B2> & ia;
public:
IndirectArray (const FlatArray<T,B1> & aa, const FlatArray<int, B2> & aia)
: array(aa), ia(aia) { ; }
int Size() const { return ia.Size(); }
const T & operator[] (int i) const { return array[ia[i]]; }
};
*/
///
template <class T, int BASE = 0>
class MoveableArray
{
int size;
int allocsize;
MoveableMem<T> data;
public:
MoveableArray()
{
size = allocsize = 0;
data.SetName ("MoveableArray");
}
MoveableArray(int asize)
: size(asize), allocsize(asize), data(asize)
{ ; }
~MoveableArray () { ; }
int Size() const { return size; }
void SetSize(int nsize)
{
if (nsize > allocsize)
{
data.ReAlloc (nsize);
allocsize = nsize;
}
size = nsize;
}
void SetAllocSize (int nallocsize)
{
data.ReAlloc (nallocsize);
allocsize = nallocsize;
}
///
T & operator[] (int i)
{ return ((T*)data)[i-BASE]; }
///
const T & operator[] (int i) const
{ return ((const T*)data)[i-BASE]; }
///
T & Elem (int i)
{ return ((T*)data)[i-1]; }
///
const T & Get (int i) const
{ return ((const T*)data)[i-1]; }
///
void Set (int i, const T & el)
{ ((T*)data)[i-1] = el; }
///
T & Last ()
{ return ((T*)data)[size-1]; }
///
const T & Last () const
{ return ((const T*)data)[size-1]; }
///
int Append (const T & el)
{
if (size == allocsize)
{
SetAllocSize (2*allocsize+1);
}
((T*)data)[size] = el;
size++;
return size;
}
///
void Delete (int i)
{
DeleteElement (i+1);
}
///
void DeleteElement (int i)
{
((T*)data)[i-1] = ((T*)data)[size-1];
size--;
}
///
void DeleteLast ()
{ size--; }
///
void DeleteAll ()
{
size = allocsize = 0;
data.Free();
}
///
void PrintMemInfo (ostream & ost) const
{
ost << Size() << " elements of size " << sizeof(T) << " = "
<< Size() * sizeof(T) << endl;
}
MoveableArray & operator= (const T & el)
{
for (int i = 0; i < size; i++)
((T*)data)[i] = el;
return *this;
}
MoveableArray & Copy (const MoveableArray & a2)
{
SetSize (a2.Size());
for (int i = 0; i < this->size; i++)
data[i] = a2.data[i];
return *this;
}
/// array copy
MoveableArray & operator= (const MoveableArray & a2)
{
return Copy(a2);
}
void SetName (const char * aname)
{
data.SetName(aname);
}
private:
///
//MoveableArray & operator= (MoveableArray &); //???
///
//MoveableArray (const MoveableArray &); //???
};
template <class T>
inline ostream & operator<< (ostream & ost, MoveableArray<T> & a)
{
for (int i = 0; i < a.Size(); i++)
ost << i << ": " << a[i] << endl;
return ost;
}
/// bubble sort array
template <class T>
inline void BubbleSort (const FlatArray<T> & data)
{
T hv;
for (int i = 0; i < data.Size(); i++)
for (int j = i+1; j < data.Size(); j++)
if (data[i] > data[j])
{
hv = data[i];
data[i] = data[j];
data[j] = hv;
}
}
/// bubble sort array
template <class T, class S>
inline void BubbleSort (FlatArray<T> & data, FlatArray<S> & slave)
{
T hv;
S hvs;
for (int i = 0; i < data.Size(); i++)
for (int j = i+1; j < data.Size(); j++)
if (data[i] > data[j])
{
hv = data[i];
data[i] = data[j];
data[j] = hv;
hvs = slave[i];
slave[i] = slave[j];
slave[j] = hvs;
}
}
template <class T>
void Intersection (const FlatArray<T> & in1, const FlatArray<T> & in2,
ARRAY<T> & out)
{
out.SetSize(0);
for(int i=0; i<in1.Size(); i++)
if(in2.Contains(in1[i]))
out.Append(in1[i]);
}
template <class T>
void Intersection (const FlatArray<T> & in1, const FlatArray<T> & in2, const FlatArray<T> & in3,
ARRAY<T> & out)
{
out.SetSize(0);
for(int i=0; i<in1.Size(); i++)
if(in2.Contains(in1[i]) && in3.Contains(in1[i]))
out.Append(in1[i]);
}
#endif

351
libsrc/general/autodiff.hpp Normal file
View File

@ -0,0 +1,351 @@
#ifndef FILE_AUTODIFF
#define FILE_AUTODIFF
/**************************************************************************/
/* File: autodiff.hpp */
/* Author: Joachim Schoeberl */
/* Date: 24. Oct. 02 */
/**************************************************************************/
// Automatic differentiation datatype
/**
Datatype for automatic differentiation.
Contains function value and D derivatives. Algebraic
operations are overloaded by using product-rule etc. etc.
**/
template <int D, typename SCAL = double>
class AutoDiff
{
SCAL val;
SCAL dval[D];
public:
typedef AutoDiff<D,SCAL> TELEM;
typedef SCAL TSCAL;
/// elements are undefined
AutoDiff () throw() { };
// { val = 0; for (int i = 0; i < D; i++) dval[i] = 0; } // !
/// copy constructor
AutoDiff (const AutoDiff & ad2) throw()
{
val = ad2.val;
for (int i = 0; i < D; i++)
dval[i] = ad2.dval[i];
}
/// initial object with constant value
AutoDiff (SCAL aval) throw()
{
val = aval;
for (int i = 0; i < D; i++)
dval[i] = 0;
}
/// init object with (val, e_diffindex)
AutoDiff (SCAL aval, int diffindex) throw()
{
val = aval;
for (int i = 0; i < D; i++)
dval[i] = 0;
dval[diffindex] = 1;
}
/// assign constant value
AutoDiff & operator= (SCAL aval) throw()
{
val = aval;
for (int i = 0; i < D; i++)
dval[i] = 0;
return *this;
}
/// returns value
SCAL Value() const throw() { return val; }
/// returns partial derivative
SCAL DValue (int i) const throw() { return dval[i]; }
/// access value
SCAL & Value() throw() { return val; }
/// accesses partial derivative
SCAL & DValue (int i) throw() { return dval[i]; }
///
AutoDiff<D,SCAL> & operator+= (const AutoDiff<D,SCAL> & y) throw()
{
val += y.val;
for (int i = 0; i < D; i++)
dval[i] += y.dval[i];
return *this;
}
///
AutoDiff<D,SCAL> & operator-= (const AutoDiff<D,SCAL> & y) throw()
{
val -= y.val;
for (int i = 0; i < D; i++)
dval[i] -= y.dval[i];
return *this;
}
///
AutoDiff<D,SCAL> & operator*= (const AutoDiff<D,SCAL> & y) throw()
{
for (int i = 0; i < D; i++)
{
// dval[i] *= y.val;
// dval[i] += val * y.dval[i];
dval[i] = dval[i] * y.val + val * y.dval[i];
}
val *= y.val;
return *this;
}
///
AutoDiff<D,SCAL> & operator*= (const SCAL & y) throw()
{
val *= y;
for (int i = 0; i < D; i++)
dval[i] *= y;
return *this;
}
///
AutoDiff<D,SCAL> & operator/= (const SCAL & y) throw()
{
SCAL iy = 1.0 / y;
val *= iy;
for (int i = 0; i < D; i++)
dval[i] *= iy;
return *this;
}
///
bool operator== (SCAL val2) throw()
{
return val == val2;
}
///
bool operator!= (SCAL val2) throw()
{
return val != val2;
}
///
bool operator< (SCAL val2) throw()
{
return val < val2;
}
///
bool operator> (SCAL val2) throw()
{
return val > val2;
}
};
//@{ AutoDiff helper functions.
/// prints AutoDiff
template<int D, typename SCAL>
inline ostream & operator<< (ostream & ost, const AutoDiff<D,SCAL> & x)
{
ost << x.Value() << ", D = ";
for (int i = 0; i < D; i++)
ost << x.DValue(i) << " ";
return ost;
}
/// AutoDiff plus AutoDiff
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> operator+ (const AutoDiff<D,SCAL> & x, const AutoDiff<D,SCAL> & y) throw()
{
AutoDiff<D,SCAL> res;
res.Value () = x.Value()+y.Value();
// AutoDiff<D,SCAL> res(x.Value()+y.Value());
for (int i = 0; i < D; i++)
res.DValue(i) = x.DValue(i) + y.DValue(i);
return res;
}
/// AutoDiff minus AutoDiff
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> operator- (const AutoDiff<D,SCAL> & x, const AutoDiff<D,SCAL> & y) throw()
{
AutoDiff<D,SCAL> res;
res.Value() = x.Value()-y.Value();
// AutoDiff<D,SCAL> res (x.Value()-y.Value());
for (int i = 0; i < D; i++)
res.DValue(i) = x.DValue(i) - y.DValue(i);
return res;
}
/// double plus AutoDiff
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> operator+ (double x, const AutoDiff<D,SCAL> & y) throw()
{
AutoDiff<D,SCAL> res;
res.Value() = x+y.Value();
for (int i = 0; i < D; i++)
res.DValue(i) = y.DValue(i);
return res;
}
/// AutoDiff plus double
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> operator+ (const AutoDiff<D,SCAL> & y, double x) throw()
{
AutoDiff<D,SCAL> res;
res.Value() = x+y.Value();
for (int i = 0; i < D; i++)
res.DValue(i) = y.DValue(i);
return res;
}
/// minus AutoDiff
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> operator- (const AutoDiff<D,SCAL> & x) throw()
{
AutoDiff<D,SCAL> res;
res.Value() = -x.Value();
for (int i = 0; i < D; i++)
res.DValue(i) = -x.DValue(i);
return res;
}
/// AutoDiff minus double
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> operator- (const AutoDiff<D,SCAL> & x, double y) throw()
{
AutoDiff<D,SCAL> res;
res.Value() = x.Value()-y;
for (int i = 0; i < D; i++)
res.DValue(i) = x.DValue(i);
return res;
}
///
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> operator- (double x, const AutoDiff<D,SCAL> & y) throw()
{
AutoDiff<D,SCAL> res;
res.Value() = x-y.Value();
for (int i = 0; i < D; i++)
res.DValue(i) = -y.DValue(i);
return res;
}
/// double times AutoDiff
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> operator* (double x, const AutoDiff<D,SCAL> & y) throw()
{
AutoDiff<D,SCAL> res;
res.Value() = x*y.Value();
for (int i = 0; i < D; i++)
res.DValue(i) = x*y.DValue(i);
return res;
}
/// AutoDiff times double
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> operator* (const AutoDiff<D,SCAL> & y, double x) throw()
{
AutoDiff<D,SCAL> res;
res.Value() = x*y.Value();
for (int i = 0; i < D; i++)
res.DValue(i) = x*y.DValue(i);
return res;
}
/// AutoDiff times AutoDiff
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> operator* (const AutoDiff<D,SCAL> & x, const AutoDiff<D,SCAL> & y) throw()
{
AutoDiff<D,SCAL> res;
SCAL hx = x.Value();
SCAL hy = y.Value();
res.Value() = hx*hy;
for (int i = 0; i < D; i++)
res.DValue(i) = hx*y.DValue(i) + hy*x.DValue(i);
return res;
}
/// AutoDiff times AutoDiff
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> sqr (const AutoDiff<D,SCAL> & x) throw()
{
AutoDiff<D,SCAL> res;
SCAL hx = x.Value();
res.Value() = hx*hx;
hx *= 2;
for (int i = 0; i < D; i++)
res.DValue(i) = hx*x.DValue(i);
return res;
}
/// Inverse of AutoDiff
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> Inv (const AutoDiff<D,SCAL> & x)
{
AutoDiff<D,SCAL> res(1.0 / x.Value());
for (int i = 0; i < D; i++)
res.DValue(i) = -x.DValue(i) / (x.Value() * x.Value());
return res;
}
/// AutoDiff div AutoDiff
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> operator/ (const AutoDiff<D,SCAL> & x, const AutoDiff<D,SCAL> & y)
{
return x * Inv (y);
}
/// AutoDiff div double
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> operator/ (const AutoDiff<D,SCAL> & x, double y)
{
return (1/y) * x;
}
/// double div AutoDiff
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> operator/ (double x, const AutoDiff<D,SCAL> & y)
{
return x * Inv(y);
}
template<int D, typename SCAL>
inline AutoDiff<D,SCAL> fabs (const AutoDiff<D,SCAL> & x)
{
double abs = fabs (x.Value());
AutoDiff<D,SCAL> res( abs );
if (abs != 0.0)
for (int i = 0; i < D; i++)
res.DValue(i) = x.DValue(i) / abs;
else
for (int i = 0; i < D; i++)
res.DValue(i) = 0.0;
return res;
}
//@}
#endif

View File

@ -0,0 +1,31 @@
#ifndef FILE_AUTOPTR
#define FILE_AUTOPTR
/**************************************************************************/
/* File: autoptr.hpp */
/* Author: STL, Joachim Schoeberl */
/* Date: 29. Dec. 02 */
/**************************************************************************/
template <typename T>
class AutoPtr
{
private:
T * ptr;
public:
typedef T* pT;
explicit AutoPtr (T * p = 0) { ptr = p; }
~AutoPtr () { delete ptr; }
T & operator*() const { return *ptr; }
T* operator->() const { return ptr; }
T *& Ptr() { return ptr; }
T * Ptr() const { return ptr; }
void Reset(T * p = 0) { if (p != ptr) { delete ptr; ptr = p; } }
operator bool () { return ptr != 0; }
private:
AutoPtr (AutoPtr &) { ; }
AutoPtr & operator= (AutoPtr &) { ; }
};
#endif

132
libsrc/general/bitarray.cpp Normal file
View File

@ -0,0 +1,132 @@
/**************************************************************************/
/* File: bitarray.cc */
/* Autho: Joachim Schoeberl */
/* Date: 01. Jun. 95 */
/**************************************************************************/
/*
data type BitArray
*/
#include <mystdlib.h>
#include <myadt.hpp>
namespace netgen
{
//using namespace netgen;
BitArray :: BitArray ()
{
size = 0;
data = NULL;
}
BitArray :: BitArray (int asize)
{
size = 0;
data = NULL;
SetSize (asize);
}
BitArray :: ~BitArray ()
{
delete [] data;
}
void BitArray :: SetSize (int asize)
{
if (size == asize) return;
delete [] data;
size = asize;
data = new unsigned char [Addr (size)+1];
}
void BitArray :: Set ()
{
if (!size) return;
for (int i = 0; i <= Addr (size); i++)
data[i] = UCHAR_MAX;
}
void BitArray :: Clear ()
{
if (!size) return;
for (int i = 0; i <= Addr (size); i++)
data[i] = 0;
}
void BitArray :: Invert ()
{
if (!size) return;
for (int i = 0; i <= Addr (size); i++)
data[i] ^= 255;
}
void BitArray :: And (const BitArray & ba2)
{
if (!size) return;
for (int i = 0; i <= Addr (size); i++)
data[i] &= ba2.data[i];
}
void BitArray :: Or (const BitArray & ba2)
{
if (!size) return;
for (int i = 0; i <= Addr (size); i++)
data[i] |= ba2.data[i];
}
template <int BASE>
void BitArrayChar<BASE> :: Set ()
{
data = 1;
}
template <int BASE>
void BitArrayChar<BASE> :: Clear ()
{
data = 0;
}
template <int BASE>
void BitArrayChar<BASE> :: Invert ()
{
for (int i = BASE; i < data.Size()+BASE; i++)
data[i] = 1 - data[i];
}
template <int BASE>
void BitArrayChar<BASE> :: And (const BitArrayChar & ba2)
{
for (int i = BASE; i < data.Size()+BASE; i++)
data[i] &= ba2.data[i];
}
template <int BASE>
void BitArrayChar<BASE> :: Or (const BitArrayChar & ba2)
{
for (int i = BASE; i < data.Size()+BASE; i++)
data[i] |= ba2.data[i];
}
template class BitArrayChar<0>;
template class BitArrayChar<1>;
}

222
libsrc/general/bitarray.hpp Normal file
View File

@ -0,0 +1,222 @@
#ifndef FILE_BitArray
#define FILE_BitArray
/**************************************************************************/
/* File: bitarray.hpp */
/* Author: Joachim Schoeberl */
/* Date: 01. Jun. 95 */
/**************************************************************************/
#include <limits.h>
/**
data type BitArray
BitArray is a compressed array of Boolean information. By Set and Clear
the whole array or one bit can be set or reset, respectively.
Test returns the state of the accoring bit.
No range checking is done.
index ranges from 0 to size-1
*/
class BitArray
{
INDEX size;
unsigned char * data;
public:
BitArray ();
///
BitArray (INDEX asize);
///
~BitArray ();
///
void SetSize (INDEX asize);
///
INDEX Size () const
{
return size;
}
///
void Set ();
///
void Set (INDEX i)
{
data[Addr(i)] |= Mask(i);
}
void Clear ();
void Clear (INDEX i)
{
data[Addr(i)] &= ~Mask(i);
}
bool Test (INDEX i) const
{
return (data[i / CHAR_BIT] & (char(1) << (i % CHAR_BIT) ) ) ? true : false;
}
///
void Invert ();
///
void And (const BitArray & ba2);
///
void Or (const BitArray & ba2);
private:
///
inline unsigned char Mask (INDEX i) const
{
return char(1) << (i % CHAR_BIT);
}
///
inline INDEX Addr (INDEX i) const
{
return (i / CHAR_BIT);
}
///
BitArray & operator= (BitArray &);
///
BitArray (const BitArray &);
};
// print bitarray
inline ostream & operator<< (ostream & s, const BitArray & a)
{
for (int i = 1; i <= a.Size(); i++)
{
s << int (a.Test(i));
if (i % 40 == 0) s << "\n";
}
if (a.Size() % 40 != 0) s << "\n";
return s;
}
/*
inline
INDEX BitArray :: Size () const
{
return size;
}
inline
unsigned char BitArray :: Mask (INDEX i) const
{
return char(1) << (i % CHAR_BIT);
}
inline
INDEX BitArray :: Addr (INDEX i) const
{
return (i / CHAR_BIT);
}
inline
void BitArray :: Set (INDEX i)
{
data[Addr(i)] |= Mask(i);
}
inline
void BitArray :: Clear (INDEX i)
{
data[Addr(i)] &= ~Mask(i);
}
inline
int BitArray :: Test (INDEX i) const
{
return (data[i / CHAR_BIT] & (char(1) << (i % CHAR_BIT) ) ) ? 1 : 0;
}
*/
/**
data type BitArrayChar
BitArray is an array of Boolean information. By Set and Clear
the whole array or one bit can be set or reset, respectively.
Test returns the state of the accoring bit.
No range checking is done.
*/
template <int BASE = 1>
class BitArrayChar
{
///
ARRAY<char,BASE> data;
public:
///
BitArrayChar ()
{ ; }
///
BitArrayChar (int asize)
: data(asize)
{ ; }
///
~BitArrayChar ()
{ ; }
///
void SetSize (int asize)
{ data.SetSize(asize); }
///
inline int Size () const
{ return data.Size(); }
///
void Set ();
///
inline void Set (int i)
{ data[i] = 1; }
///
void Clear ();
///
inline void Clear (int i)
{ data[i] = 0; }
///
inline int Test (int i) const
{ return data[i]; }
///
void Invert ();
///
void And (const BitArrayChar & ba2);
///
void Or (const BitArrayChar & ba2);
private:
/// copy bitarray is not supported
BitArrayChar & operator= (BitArrayChar &) { return *this; }
/// copy bitarray is not supported
BitArrayChar (const BitArrayChar &) { ; }
};
template <int BASE>
inline ostream & operator<< (ostream & s, const BitArrayChar<BASE> & a)
{
for (int i = BASE; i < a.Size()+BASE; i++)
{
s << a.Test(i);
if ( (i-BASE) % 40 == 39) s << "\n";
}
if (a.Size() % 40 != 0) s << "\n";
return s;
}
#endif

View File

@ -0,0 +1,205 @@
#include <iostream>
#include <iomanip>
#ifdef SSE
#include <emmintrin.h>
#endif
#include <myadt.hpp>
using namespace std;
namespace netgen
{
BaseDynamicMem * BaseDynamicMem::first = 0;
BaseDynamicMem * BaseDynamicMem::last = 0;
BaseDynamicMem :: BaseDynamicMem ()
{
prev = last;
next = 0;
if (last) last->next = this;
last = this;
if (!first) first = this;
size = 0;
ptr = 0;
name = 0;
}
BaseDynamicMem :: ~BaseDynamicMem ()
{
Free();
if (next) next->prev = prev;
else last = prev;
if (prev) prev->next = next;
else first = next;
delete [] name;
}
void BaseDynamicMem :: SetName (const char * aname)
{
delete [] name;
if (aname)
{
name = new char[strlen(aname)+1];
strcpy (name, aname);
}
}
void BaseDynamicMem :: Alloc (size_t s)
{
size = s;
ptr = new char[s];
if (!ptr)
{
cerr << "BaseynamicMem, cannot allocate " << s << " bytes" << endl;
Print ();
throw ("BaseDynamicMem::Alloc: out of memory");
}
// ptr = (char*)malloc (s);
// ptr = (char*) _mm_malloc (s,16);
}
void BaseDynamicMem :: ReAlloc (size_t s)
{
if (size == s) return;
char * old = ptr;
ptr = new char[s];
if (!ptr)
{
cerr << "BaseynamicMem, cannot Reallocate " << s << " bytes" << endl;
Print ();
throw ("BaseDynamicMem::Alloc: out of memory");
}
// ptr = (char*)malloc(s);
// ptr = (char*) _mm_malloc (s,16);
memmove (ptr, old, (s < size) ? s : size);
delete [] old;
// free (old);
// _mm_free (old);
size = s;
}
void BaseDynamicMem :: Free ()
{
delete [] ptr;
// free (ptr);
// _mm_free (ptr);
ptr = 0;
}
void BaseDynamicMem :: Swap (BaseDynamicMem & m2)
{
size_t hi;
char * cp;
hi = size; size = m2.size; m2.size = hi;
cp = ptr; ptr = m2.ptr; m2.ptr = cp;
cp = name; name = m2.name; m2.name = cp;
}
void BaseDynamicMem :: Print ()
{
cout << "****************** Dynamic Mem Report ****************" << endl;
BaseDynamicMem * p = first;
size_t mem = 0;
int cnt = 0;
while (p)
{
mem += p->size;
cnt++;
cout << setw(10) << p->size << " Bytes";
cout << ", addr = " << (void*)p->ptr;
if (p->name)
cout << " in block " << p->name;
cout << endl;
p = p->next;
}
if (mem > 100000000)
cout << "memory in dynamic memory: " << mem/1048576 << " MB" << endl;
else if (mem > 100000)
cout << "memory in dynamic memory: " << mem/1024 << " kB" << endl;
else
cout << "memory in dynamic memory: " << mem << " Bytes" << endl;
cout << "number of blocks: " << cnt << endl;
// cout << "******************************************************" << endl;
}
#ifdef __INTEL_COMPILER
#pragma warning(push)
#pragma warning(disable:1684)
#endif
void BaseDynamicMem :: GetUsed (int nr, char * ch)
{
BaseDynamicMem * p = first;
for (int i = 0; i < nr; i++)
ch[i] = '0';
while (p)
{
long unsigned hptr = (long unsigned) (p->ptr);
// uintptr_t hptr = reinterpret_cast<uintptr_t>(p->ptr); //??
hptr /= (1024*1024);
hptr /= (4096/nr);
size_t blocks = p->size / (1024*1024);
blocks /= (4096/nr);
// cout << "ptr = " << (void*)(p->ptr) << ", size = " << p->size << ", hptr = " << hptr << " blocks = " << blocks << endl;
for (size_t i = 0; i <= blocks; i++)
ch[hptr+i] = '1';
p = p->next;
}
{
BaseMoveableMem * pm = BaseMoveableMem::first;
while (pm)
{
long unsigned hptr = (long unsigned) p->ptr;
// uintptr_t hptr = reinterpret_cast<uintptr_t>(pm->ptr);
hptr /= (1024*1024);
hptr /= (4096/nr);
size_t blocks = pm->size / (1024*1024);
blocks /= (4096/nr);
// cout << "moveable, ptr = " << (void*)(pm->ptr) << ", size = " << pm->size << ", hptr = " << hptr << " blocks = " << blocks << endl;
for (size_t i = 0; i <= blocks; i++)
ch[hptr+i] = '1';
pm = pm->next;
}
}
}
#ifdef __INTEL_COMPILER
#pragma warning(pop)
#endif
}

View File

@ -0,0 +1,95 @@
#ifndef FILE_DYNAMICMEM
#define FILE_DYNAMICMEM
/**************************************************************************/
/* File: dynamicmem.hpp */
/* Author: Joachim Schoeberl */
/* Date: 12. Feb. 2003 */
/**************************************************************************/
class BaseDynamicMem
{
private:
static BaseDynamicMem *first, *last;
BaseDynamicMem *prev, *next;
size_t size;
char * ptr;
char * name;
protected:
BaseDynamicMem ();
~BaseDynamicMem ();
void Alloc (size_t s);
void ReAlloc (size_t s);
void Free ();
char * Ptr() { return ptr; }
const char * Ptr() const { return ptr; }
void Swap (BaseDynamicMem & m2);
public:
void SetName (const char * aname);
static void Print ();
static void GetUsed (int nr, char * ch);
};
template <typename T>
class DynamicMem : public BaseDynamicMem
{
public:
DynamicMem ()
: BaseDynamicMem ()
{
;
}
DynamicMem (size_t s)
: BaseDynamicMem ()
{
Alloc (s);
}
void Alloc (size_t s)
{
BaseDynamicMem::Alloc (sizeof(T) * s);
}
void ReAlloc (size_t s)
{
BaseDynamicMem::ReAlloc (sizeof(T) * s);
}
void Free ()
{
BaseDynamicMem::Free ();
}
const T * Ptr() const
{
return reinterpret_cast<const T*> (BaseDynamicMem::Ptr());
}
T * Ptr()
{
return reinterpret_cast<T*> (BaseDynamicMem::Ptr());
}
operator const T* () const
{
return reinterpret_cast<const T*> (BaseDynamicMem::Ptr());
}
operator T* ()
{
return reinterpret_cast<T*> (BaseDynamicMem::Ptr());
}
void Swap (DynamicMem<T> & m2)
{
BaseDynamicMem::Swap (m2);
}
protected:
DynamicMem (const DynamicMem & m);
DynamicMem & operator= (const DynamicMem & m);
};
#endif

330
libsrc/general/flags.cpp Normal file
View File

@ -0,0 +1,330 @@
/**************************************************************************/
/* File: flags.cc */
/* Author: Joachim Schoeberl */
/* Date: 10. Oct. 96 */
/**************************************************************************/
/*
Datatype Flags
*/
#include <mystdlib.h>
#include <myadt.hpp>
namespace netgen
{
//using namespace netgen;
Flags :: Flags ()
{
;
}
Flags :: ~Flags ()
{
DeleteFlags ();
}
void Flags :: DeleteFlags ()
{
for (int i = 0; i < strflags.Size(); i++)
delete [] strflags[i];
for (int i = 0; i < numlistflags.Size(); i++)
delete numlistflags[i];
strflags.DeleteAll();
numflags.DeleteAll();
defflags.DeleteAll();
strlistflags.DeleteAll();
numlistflags.DeleteAll();
}
void Flags :: SetFlag (const char * name, const char * val)
{
char * hval = new char[strlen (val) + 1];
strcpy (hval, val);
strflags.Set (name, hval);
}
void Flags :: SetFlag (const char * name, double val)
{
numflags.Set (name, val);
}
void Flags :: SetFlag (const char * name)
{
defflags.Set (name, 1);
}
void Flags :: SetFlag (const char * name, const ARRAY<char*> & val)
{
ARRAY<char*> * strarray = new ARRAY<char*>;
for (int i = 1; i <= val.Size(); i++)
{
strarray->Append (new char[strlen(val.Get(i))+1]);
strcpy (strarray->Last(), val.Get(i));
}
strlistflags.Set (name, strarray);
}
void Flags :: SetFlag (const char * name, const ARRAY<double> & val)
{
ARRAY<double> * numarray = new ARRAY<double>;
for (int i = 1; i <= val.Size(); i++)
numarray->Append (val.Get(i));
numlistflags.Set (name, numarray);
}
const char *
Flags :: GetStringFlag (const char * name, const char * def) const
{
if (strflags.Used (name))
return strflags.Get(name);
else
return def;
}
double Flags :: GetNumFlag (const char * name, double def) const
{
if (numflags.Used (name))
return numflags.Get(name);
else
return def;
}
const double * Flags :: GetNumFlagPtr (const char * name) const
{
if (numflags.Used (name))
return & ((SYMBOLTABLE<double>&)numflags).Elem(name);
else
return NULL;
}
double * Flags :: GetNumFlagPtr (const char * name)
{
if (numflags.Used (name))
return & ((SYMBOLTABLE<double>&)numflags).Elem(name);
else
return NULL;
}
bool Flags :: GetDefineFlag (const char * name) const
{
return defflags.Used (name);
}
const ARRAY<char*> &
Flags :: GetStringListFlag (const char * name) const
{
if (strlistflags.Used (name))
return *strlistflags.Get(name);
else
{
static ARRAY<char*> hstra(0);
return hstra;
}
}
const ARRAY<double> &
Flags ::GetNumListFlag (const char * name) const
{
if (numlistflags.Used (name))
return *numlistflags.Get(name);
else
{
static ARRAY<double> hnuma(0);
return hnuma;
}
}
bool Flags :: StringFlagDefined (const char * name) const
{
return strflags.Used (name);
}
bool Flags :: NumFlagDefined (const char * name) const
{
return numflags.Used (name);
}
bool Flags :: StringListFlagDefined (const char * name) const
{
return strlistflags.Used (name);
}
bool Flags :: NumListFlagDefined (const char * name) const
{
return numlistflags.Used (name);
}
void Flags :: SaveFlags (const char * filename) const
{
int i;
ofstream outfile (filename);
for (i = 1; i <= strflags.Size(); i++)
outfile << strflags.GetName(i) << " = " << strflags.Get(i) << endl;
for (i = 1; i <= numflags.Size(); i++)
outfile << numflags.GetName(i) << " = " << numflags.Get(i) << endl;
for (i = 1; i <= defflags.Size(); i++)
outfile << defflags.GetName(i) << endl;
}
void Flags :: PrintFlags (ostream & ost) const
{
int i;
for (i = 1; i <= strflags.Size(); i++)
ost << strflags.GetName(i) << " = " << strflags.Get(i) << endl;
for (i = 1; i <= numflags.Size(); i++)
ost << numflags.GetName(i) << " = " << numflags.Get(i) << endl;
for (i = 1; i <= defflags.Size(); i++)
ost << defflags.GetName(i) << endl;
}
void Flags :: LoadFlags (const char * filename)
{
char name[100], str[100];
char ch;
double val;
ifstream infile(filename);
// (*logout) << "Load flags from " << filename << endl << endl;
while (infile.good())
{
infile >> name;
if (strlen (name) == 0) break;
if (name[0] == '/' && name[1] == '/')
{
// (*logout) << "comment: ";
ch = 0;
while (ch != '\n' && infile.good())
{
ch = infile.get();
// (*logout) << ch;
}
continue;
}
// (*logout) << name;
ch = 0;
infile >> ch;
if (ch != '=')
{
// (*logout) << endl;
infile.putback (ch);
SetFlag (name);
}
else
{
infile >> val;
if (!infile.good())
{
infile.clear();
infile >> str;
SetFlag (name, str);
// (*logout) << " = " << str << endl;
}
else
{
SetFlag (name, val);
// (*logout) << " = " << val << endl;
}
}
}
// (*logout) << endl;
}
void Flags :: SetCommandLineFlag (const char * st)
{
// cout << "clflag = " << st << endl;
istringstream inst( (char *)st);
// istrstream defined with char * (not const char * ?????)
char name[100];
double val;
if (st[0] != '-')
{
cerr << "flag must start with '-'" << endl;
return;
}
const char * pos = strchr (st, '=');
if (!pos)
{
// (cout) << "Add def flag: " << st+1 << endl;
SetFlag (st+1);
}
else
{
// cout << "pos = " << pos << endl;
strncpy (name, st+1, (pos-st)-1);
name[pos-st-1] = 0;
// cout << "name = " << name << endl;
pos++;
char * endptr = NULL;
val = strtod (pos, &endptr);
// cout << "val = " << val << endl;
if (endptr == pos)
{
// (cout) << "Add String Flag: " << name << " = " << pos << endl;
SetFlag (name, pos);
}
else
{
// (cout) << "Add Num Flag: " << name << " = " << val << endl;
SetFlag (name, val);
}
}
/*
inst >> name;
(*mycout) << "name = " << name << endl;
ch = 0;
inst >> ch;
if (ch != '=')
{
SetFlag (name);
}
else
{
inst >> val;
if (!inst.good())
{
inst.clear();
inst >> str;
SetFlag (name, str);
(*mycout) << "str = " << str << endl;
}
else
{
SetFlag (name, val);
(*mycout) << "val = " << val << endl;
}
}
*/
}
}

83
libsrc/general/flags.hpp Normal file
View File

@ -0,0 +1,83 @@
#ifndef FILE_FLAGS
#define FILE_FLAGS
/**************************************************************************/
/* File: flags.hh */
/* Author: Joachim Schoeberl */
/* Date: 10. Oct. 96 */
/**************************************************************************/
/**
Flag - Table.
A flag table maintains string variables, numerical
variables and boolean flags.
*/
class Flags
{
///
SYMBOLTABLE<char *> strflags;
///
SYMBOLTABLE<double> numflags;
///
SYMBOLTABLE<int> defflags;
///
SYMBOLTABLE<ARRAY<char*>*> strlistflags;
///
SYMBOLTABLE<ARRAY<double>*> numlistflags;
public:
///
Flags ();
///
~Flags ();
/// Deletes all flags
void DeleteFlags ();
/// Sets string flag, overwrite if exists
void SetFlag (const char * name, const char * val);
/// Sets numerical flag, overwrite if exists
void SetFlag (const char * name, double val);
/// Sets boolean flag
void SetFlag (const char * name);
/// Sets string arary falg
void SetFlag (const char * name, const ARRAY<char*> & val);
/// Sets double array flag
void SetFlag (const char * name, const ARRAY<double> & val);
/// Save flags to file
void SaveFlags (const char * filename) const;
/// write flags to stream
void PrintFlags (ostream & ost) const;
/// Load flags from file
void LoadFlags (const char * filename);
/// set flag of form -name=hello -val=0.5 -defined
void SetCommandLineFlag (const char * st);
/// Returns string flag, default value if not exists
const char * GetStringFlag (const char * name, const char * def) const;
/// Returns numerical flag, default value if not exists
double GetNumFlag (const char * name, double def) const;
/// Returns address of numerical flag, null if not exists
const double * GetNumFlagPtr (const char * name) const;
/// Returns address of numerical flag, null if not exists
double * GetNumFlagPtr (const char * name);
/// Returns boolean flag
bool GetDefineFlag (const char * name) const;
/// Returns string list flag, empty array if not exist
const ARRAY<char*> & GetStringListFlag (const char * name) const;
/// Returns num list flag, empty array if not exist
const ARRAY<double> & GetNumListFlag (const char * name) const;
/// Test, if string flag is defined
bool StringFlagDefined (const char * name) const;
/// Test, if num flag is defined
bool NumFlagDefined (const char * name) const;
/// Test, if string list flag is defined
bool StringListFlagDefined (const char * name) const;
/// Test, if num list flag is defined
bool NumListFlagDefined (const char * name) const;
};
#endif

327
libsrc/general/hashtabl.cpp Normal file
View File

@ -0,0 +1,327 @@
/**************************************************************************/
/* File: hashtabl.cpp */
/* Author: Joachim Schoeberl */
/* Date: 01. Jun. 95 */
/**************************************************************************/
/*
Abstract data type HASHTABLE
*/
#include <algorithm>
#include <mystdlib.h>
#include <myadt.hpp>
namespace netgen
{
//using namespace netgen;
void INDEX_4 :: Sort ()
{
if (i[0] > i[1]) Swap (i[0], i[1]);
if (i[2] > i[3]) Swap (i[2], i[3]);
if (i[0] > i[2]) Swap (i[0], i[2]);
if (i[1] > i[3]) Swap (i[1], i[3]);
if (i[1] > i[2]) Swap (i[1], i[2]);
}
void INDEX_4Q :: Sort ()
{
if (min2 (i[1], i[2]) < min2 (i[0], i[3]))
{ Swap (i[0], i[1]); Swap (i[2], i[3]);}
if (i[3] < i[0])
{ Swap (i[0], i[3]); Swap (i[1], i[2]);}
if (i[3] < i[1])
{ Swap (i[1], i[3]); }
}
ostream & operator<<(ostream & s, const INDEX_2 & i2)
{
return s << i2.I1() << ", " << i2.I2();
}
ostream & operator<<(ostream & s, const INDEX_3 & i3)
{
return s << i3.I1() << ", " << i3.I2() << ", " << i3.I3();
}
ostream & operator<<(ostream & s, const INDEX_4 & i4)
{
return s << i4.I1() << ", " << i4.I2() << ", " << i4.I3() << ", " << i4.I4();
}
ostream & operator<<(ostream & s, const INDEX_4Q & i4)
{
return s << i4.I1() << ", " << i4.I2() << ", " << i4.I3() << ", " << i4.I4();
}
int BASE_INDEX_HASHTABLE :: Position (int bnr, const INDEX & ind) const
{
int i;
for (i = 1; i <= hash.EntrySize (bnr); i++)
if (hash.Get(bnr, i) == ind)
return i;
return 0;
}
/*
int BASE_INDEX_2_HASHTABLE :: Position (int bnr, const INDEX_2 & ind) const
{
int i;
for (i = 1; i <= hash.EntrySize (bnr); i++)
if (hash.Get(bnr, i) == ind)
return i;
return 0;
}
*/
void BASE_INDEX_2_HASHTABLE :: PrintStat (ostream & ost) const
{
int n = hash.Size();
int i;
int sumn = 0, sumnn = 0;
for (i = 1; i <= n; i++)
{
sumn += hash.EntrySize(i);
sumnn += sqr (hash.EntrySize(i));
}
ost << "Hashtable: " << endl
<< "size : " << n << endl
<< "elements per row : " << (double(sumn) / double(n)) << endl
<< "av. acces time : "
<< (sumn ? (double (sumnn) / double(sumn)) : 0) << endl;
}
/*
int BASE_INDEX_3_HASHTABLE :: Position (int bnr, const INDEX_3 & ind) const
{
int i;
const INDEX_3 * pi = &hash.Get(bnr, 1);
int n = hash.EntrySize(bnr);
for (i = 1; i <= n; ++i, ++pi)
{
if (*pi == ind)
return i;
}
return 0;
}
*/
BASE_INDEX_CLOSED_HASHTABLE ::
BASE_INDEX_CLOSED_HASHTABLE (int size)
: hash(size)
{
hash.SetName ("index-hashtable, hash");
invalid = -1;
for (int i = 1; i <= size; i++)
hash.Elem(i) = invalid;
}
void BASE_INDEX_CLOSED_HASHTABLE ::
BaseSetSize (int size)
{
hash.SetSize(size);
for (int i = 1; i <= size; i++)
hash.Elem(i) = invalid;
}
int BASE_INDEX_CLOSED_HASHTABLE ::
Position2 (const INDEX & ind) const
{
int i = HashValue(ind);
while (1)
{
i++;
if (i > hash.Size()) i = 1;
if (hash.Get(i) == ind) return i;
if (hash.Get(i) == invalid) return 0;
}
}
int BASE_INDEX_CLOSED_HASHTABLE ::
PositionCreate2 (const INDEX & ind, int & apos)
{
int i = HashValue(ind);
int startpos = i;
while (1)
{
i++;
if (i > hash.Size()) i = 1;
if (hash.Get(i) == ind)
{
apos = i;
return 0;
}
if (hash.Get(i) == invalid)
{
hash.Elem(i) = ind;
apos = i;
return 1;
}
if (i == startpos)
throw NgException ("Try to set new element in full closed hashtable");
}
}
int BASE_INDEX_CLOSED_HASHTABLE :: UsedElements () const
{
int n = hash.Size();
int cnt = 0;
for (int i = 1; i <= n; i++)
if (hash.Get(i) != invalid)
cnt++;
return cnt;
}
BASE_INDEX_2_CLOSED_HASHTABLE ::
BASE_INDEX_2_CLOSED_HASHTABLE (int size)
: hash(size)
{
hash.SetName ("i2-hashtable, hash");
invalid = -1;
for (int i = 1; i <= size; i++)
hash.Elem(i).I1() = invalid;
}
void BASE_INDEX_2_CLOSED_HASHTABLE ::
BaseSetSize (int size)
{
hash.SetSize(size);
for (int i = 1; i <= size; i++)
hash.Elem(i).I1() = invalid;
}
int BASE_INDEX_2_CLOSED_HASHTABLE ::
Position2 (const INDEX_2 & ind) const
{
int i = HashValue(ind);
while (1)
{
i++;
if (i > hash.Size()) i = 1;
if (hash.Get(i) == ind) return i;
if (hash.Get(i).I1() == invalid) return 0;
}
}
int BASE_INDEX_2_CLOSED_HASHTABLE ::
PositionCreate2 (const INDEX_2 & ind, int & apos)
{
int i = HashValue(ind);
int startpos = i;
while (1)
{
i++;
if (i > hash.Size()) i = 1;
if (hash.Get(i) == ind)
{
apos = i;
return 0;
}
if (hash.Get(i).I1() == invalid)
{
hash.Elem(i) = ind;
apos = i;
return 1;
}
if (i == startpos)
throw NgException ("Try to set new element in full closed hashtable");
}
}
int BASE_INDEX_2_CLOSED_HASHTABLE :: UsedElements () const
{
int n = hash.Size();
int cnt = 0;
for (int i = 1; i <= n; i++)
if (hash.Get(i).I1() != invalid)
cnt++;
return cnt;
}
void BASE_INDEX_3_CLOSED_HASHTABLE ::
BaseSetSize (int size)
{
hash.SetSize(size);
for (int i = 0; i < size; i++)
hash[i].I1() = invalid;
}
bool BASE_INDEX_3_CLOSED_HASHTABLE ::
PositionCreate2 (const INDEX_3 & ind, int & apos)
{
int i = HashValue(ind);
int startpos = i;
while (1)
{
/*
i++;
if (i >= hash.Size()) i = 0;
*/
i = (i+1) % hash.Size();
if (hash[i] == ind)
{
apos = i;
return false;
}
if (hash[i].I1() == invalid)
{
hash[i] = ind;
apos = i;
return true;
}
if (i == startpos)
throw NgException ("Try to set new element in full closed hashtable");
}
}
}

1322
libsrc/general/hashtabl.hpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,271 @@
#include <iostream>
#include <iomanip>
#include <myadt.hpp>
using namespace std;
namespace netgen
{
NgMutex mem_mutex;
size_t BaseMoveableMem::totalsize = 0; // 500000000;
size_t BaseMoveableMem::used = 0;
char * BaseMoveableMem::largeblock = 0;
BaseMoveableMem * BaseMoveableMem::first = 0;
BaseMoveableMem * BaseMoveableMem::last = 0;
BaseMoveableMem :: BaseMoveableMem (size_t s)
{
// cout << "Construct object begin" << endl;
// Print ();
prev = last;
next = 0;
if (last) last->next = this;
last = this;
if (!first) first = this;
size = 0;
if (prev)
pos = prev->pos + prev->size;
else
pos = 0;
ptr = 0;
name = NULL;
if (s) Alloc(s);
}
BaseMoveableMem :: ~BaseMoveableMem () throw()
{
Free();
if (next) next->prev = prev;
else last = prev;
if (prev) prev->next = next;
else first = next;
if(name != NULL)
{
delete [] name;
name = NULL;
}
}
void BaseMoveableMem :: SetName (const char * aname)
{
if(name != NULL)
{
delete [] name;
name = NULL;
}
if (aname)
{
name = new char[strlen(aname)+1];
strcpy (name, aname);
}
}
void BaseMoveableMem :: Alloc (size_t s)
{
if (totalsize == 0)
{
size = s;
//ptr = (char*) malloc(s);
ptr = new char[s];
if (!ptr)
{
cerr << "BaseynamicMem, cannot allocate " << s << " bytes" << endl;
Print ();
throw ("BaseDynamicMem::Alloc: out of memory");
}
return;
}
used += s - size;
size_t r = s % 8;
if (r) s += 8-r;
if (prev)
pos = prev->pos + prev->size;
else
pos = 0;
size = s;
if (next)
{
NgLock lock(mem_mutex);
lock.Lock();
try
{
next->MoveTo (pos+size);
}
catch (NgException e)
{
lock.UnLock();
throw NgException ("MoveableMem overflow");
}
lock.UnLock();
}
if (size)
{
if (!largeblock)
{
cout << "moveable memory: allocate large block of "
<< totalsize / 1048576 << " MB" << endl;
// largeblock = new char[totalsize];
// largeblock = (char*)malloc (totalsize);
largeblock = new char[totalsize];
}
ptr = largeblock+pos;
if (pos + size > totalsize)
throw NgException ("MoveableMem overflow");
}
else
ptr = 0;
}
void BaseMoveableMem :: ReAlloc (size_t s)
{
if (totalsize == 0)
{
if (size == s) return;
char * old = ptr;
ptr = new char[s];
if (!ptr)
{
cerr << "BaseynamicMem, cannot Reallocate " << s << " bytes" << endl;
Print ();
throw ("BaseDynamicMem::Alloc: out of memory");
}
memmove (ptr, old, (s < size) ? s : size);
//free (old);
delete [] old;
size = s;
return;
}
Alloc (s);
}
void BaseMoveableMem :: MoveTo (size_t newpos)
{
// cout << "move block, oldpos = " << pos << "; newpos = " << newpos
// << ", size = " << size << endl;
static size_t move = 0;
if (newpos + size > totalsize)
throw NgException ("MoveableMem overflow");
if (newpos > pos)
{
if (next) next->MoveTo (newpos+size);
memmove (largeblock+newpos, largeblock+pos, size);
move += size;
}
else if (newpos < pos)
{
// cout << "move down: " << size << endl;
memmove (largeblock+newpos, largeblock+pos, size);
if (next) next->MoveTo (newpos+size);
move += size;
}
pos = newpos;
ptr = largeblock+pos;
// cout << "total move: " << move << endl;
}
void BaseMoveableMem :: Free () throw()
{
if (totalsize == 0)
{
//free (ptr);
delete [] ptr;
ptr = 0;
return;
}
/*
cout << "free block, pos = " << pos << "size = " << size << endl;
cout << "before: " << endl;
Print();
*/
used -= size;
if (next)
{
NgLock lock(mem_mutex);
lock.Lock();
next->MoveTo (pos);
lock.UnLock();
}
size = 0;
ptr = 0;
// pos = 0;
}
void BaseMoveableMem :: Swap (BaseMoveableMem & m2) throw()
{
size_t hi;
// BaseMoveableMem * hp;
char * cp;
hi = size; size = m2.size; m2.size = hi;
hi = pos; pos = m2.pos; m2.pos = hi;
/*
hp = prev; prev = m2.prev; m2.prev = hp;
hp = next; next = m2.next; m2.next = hp;
*/
cp = ptr; ptr = m2.ptr; m2.ptr = cp;
cp = name; name = m2.name; m2.name = cp;
}
void BaseMoveableMem :: Print ()
{
cout << "****************** Moveable Mem Report ****************" << endl;
BaseMoveableMem * p = first;
long int mem = 0;
int cnt = 0;
while (p)
{
mem += long(p->size);
cnt++;
cout << setw(10) << p->size << " Bytes";
cout << ", pos = " << p->pos;
cout << ", addr = " << (void*)p->ptr;
if (p->name)
cout << " in block " << p->name;
cout << endl;
p = p->next;
}
if (mem > 100000000)
cout << "memory in moveable arena: " << mem/1048576 << " MB" << endl;
else if (mem > 100000)
cout << "memory in moveable arena: " << mem/1024 << " kB" << endl;
else
cout << "memory in moveable arena: " << mem << " Bytes" << endl;
cout << "number of blocks: " << cnt << endl;
cout << " used = " << used << endl;
// cout << "******************************************************" << endl;
}
}

View File

@ -0,0 +1,99 @@
#ifndef FILE_MOVEABLEMEM
#define FILE_MOVEABLEMEM
/**************************************************************************/
/* File: moveablemem.hpp */
/* Author: Joachim Schoeberl */
/* Date: 12. Feb. 2003 */
/**************************************************************************/
extern NgMutex mem_mutex;
class BaseMoveableMem
{
public:
static size_t totalsize;
static size_t used;
private:
static char * largeblock;
static BaseMoveableMem *first, *last;
BaseMoveableMem *prev, *next;
size_t size, pos;
char * ptr;
char * name;
protected:
BaseMoveableMem (size_t s = 0);
~BaseMoveableMem () throw();
void Alloc (size_t s);
void ReAlloc (size_t s);
void MoveTo (size_t newpos);
void Free () throw();
char * Ptr() { return ptr; }
char * Ptr() const { return ptr; }
void Swap (BaseMoveableMem & m2) throw();
public:
void SetName (const char * aname);
static void Print ();
friend class BaseDynamicMem;
};
template <typename T>
class MoveableMem : public BaseMoveableMem
{
public:
MoveableMem (size_t s = 0)
: BaseMoveableMem (sizeof(T) * s)
{
;
}
void Alloc (size_t s)
{
BaseMoveableMem::Alloc (sizeof(T) * s);
}
void ReAlloc (size_t s)
{
BaseMoveableMem::ReAlloc (sizeof(T) * s);
}
void Free ()
{
BaseMoveableMem::Free ();
}
const T * Ptr() const
{
return reinterpret_cast<const T*> (BaseMoveableMem::Ptr());
}
T * Ptr()
{
return reinterpret_cast<T*> (BaseMoveableMem::Ptr());
}
operator T* () const
{
return reinterpret_cast<T*> (BaseMoveableMem::Ptr());
}
operator T* ()
{
return reinterpret_cast<T*> (BaseMoveableMem::Ptr());
}
void Swap (MoveableMem<T> & m2)
{
BaseMoveableMem::Swap (m2);
}
protected:
MoveableMem (const MoveableMem & m) { ; }
MoveableMem & operator= (const MoveableMem & m) { ; }
};
#endif

46
libsrc/general/myadt.hpp Normal file
View File

@ -0,0 +1,46 @@
#ifndef FILE_MYADT
#define FILE_MYADT
/**************************************************************************/
/* File: myadt.hpp */
/* Author: Joachim Schoeberl */
/* Date: 01. Jun. 95 */
/**************************************************************************/
/*
include for all abstract data types
*/
#include "../include/mystdlib.h"
#include "../include/mydefs.hpp"
namespace netgen
{
#include "ngexception.hpp"
#include "parthreads.hpp"
#include "moveablemem.hpp"
#include "dynamicmem.hpp"
#include "template.hpp"
#include "array.hpp"
#include "table.hpp"
#include "hashtabl.hpp"
#include "symbolta.hpp"
#include "bitarray.hpp"
#include "flags.hpp"
#include "spbita2d.hpp"
#include "seti.hpp"
#include "optmem.hpp"
#include "autoptr.hpp"
#include "sort.hpp"
#include "stack.hpp"
#include "mystring.hpp"
#include "profiler.hpp"
#include "netgenout.hpp"
}
#endif

426
libsrc/general/mystring.cpp Normal file
View File

@ -0,0 +1,426 @@
//**************************************************************
//
// filename: mystring.cpp
//
// project: doctoral thesis
//
// autor: Dipl.-Ing. Gerstmayr Johannes
//
// generated: 20.12.98
// last change: 20.12.98
// description: implementation for strings
// remarks:
//
//**************************************************************
// string class
#include <mystdlib.h>
#include <myadt.hpp>
#include <linalg.hpp>
#include <gprim.hpp>
namespace netgen
{
void ReadEnclString(istream & in, string & str, const char encl)
{
char currchar;
str = "";
in.get(currchar);
while(in && (currchar == ' ' || currchar == '\t' || currchar == '\n') )
in.get(currchar);
if(currchar == encl)
{
in.get(currchar);
while(in && currchar != encl)
{
str += currchar;
in.get(currchar);
}
}
else
{
in.putback(currchar);
in >> str;
}
}
void DefaultStringErrHandler()
{
cerr << "Error : string operation out of range\n" << flush;
}
void (*MyStr::ErrHandler)() = DefaultStringErrHandler;
/*
MyStr::MyStr()
{
length = 0;
str = shortstr;
str[0] = 0;
}
*/
MyStr::MyStr(const char *s)
{
length = unsigned(strlen(s));
if (length > SHORTLEN)
str = new char[length + 1];
else
str = shortstr;
strcpy(str, s);
}
/*
MyStr::MyStr(char s)
{
length = 1;
str = shortstr;
str[0] = s;
str[1] = (char)0;
}
*/
MyStr::MyStr(const MyStr& s)
{
length = s.length;
if (length > SHORTLEN)
str = new char[length + 1];
else
str = shortstr;
strcpy(str, s.str);
}
MyStr::MyStr(int i)
{
char buffer[32];
sprintf(buffer, "%d", i);
length = unsigned(strlen(buffer));
if (length > SHORTLEN)
str = new char[length + 1];
else
str = shortstr;
strcpy(str, buffer);
}
MyStr::MyStr(void * p)
{
char buffer[32];
sprintf(buffer, "%p", p);
length = unsigned(strlen(buffer));
if (length > SHORTLEN)
str = new char[length + 1];
else
str = shortstr;
strcpy(str, buffer);
}
MyStr::MyStr(long l)
{
char buffer[32];
sprintf(buffer, "%ld", l);
length = unsigned(strlen(buffer));
if (length > SHORTLEN)
str = new char[length + 1];
else
str = shortstr;
strcpy(str, buffer);
}
MyStr::MyStr(double d)
{
char buffer[32];
//if (fabs(d) < 1E-100) {d = 0;}
sprintf(buffer, "%g", d);
length = unsigned(strlen(buffer));
if (length > SHORTLEN)
str = new char[length + 1];
else
str = shortstr;
strcpy(str, buffer);
}
MyStr::MyStr(const Point3d& p)
{
char buffer[80];
//if (fabs(d) < 1E-100) {d = 0;}
sprintf(buffer, "[%g, %g, %g]", p.X(), p.Y(), p.Z());
length = unsigned(strlen(buffer));
if (length > SHORTLEN)
str = new char[length + 1];
else
str = shortstr;
strcpy(str, buffer);
}
MyStr::MyStr(const Vec3d& p)
{
char buffer[80];
//if (fabs(d) < 1E-100) {d = 0;}
sprintf(buffer, "[%g, %g, %g]", p.X(), p.Y(), p.Z());
length = unsigned(strlen(buffer));
if (length > SHORTLEN)
str = new char[length + 1];
else
str = shortstr;
strcpy(str, buffer);
}
MyStr::MyStr(unsigned n, int)
{
length = n;
if (length > SHORTLEN)
str = new char[length + 1];
else
str = shortstr;
str[n] = 0;
}
MyStr::MyStr(const string & st)
{
length = unsigned(st.length());
if (length > SHORTLEN)
str = new char[length + 1];
else
str = shortstr;
strcpy (str, st.c_str());
}
MyStr MyStr::Left(unsigned r)
{
if(r > length)
{
MyStr::ErrHandler();
MyStr s;
return s;
}
else
{
MyStr tmp(r, 0);
strncpy(tmp.str, str, r);
return tmp;
}
}
MyStr MyStr::Right(unsigned l)
{
if(l > length)
{
MyStr::ErrHandler();
MyStr s;
return s;
}
else
{
MyStr tmp(l, 0);
strncpy(tmp.str, str + length - l, l);
return tmp;
}
}
MyStr& MyStr::InsertAt(unsigned pos, const MyStr& s)
{
if(pos > length)
{
MyStr::ErrHandler();
return *this;
}
int newLength = length + s.length;
char *tmp = new char[newLength + 1];
strncpy(tmp, str, pos);
strcpy(tmp + pos, s.str);
strcpy(tmp + pos + s.length, str + pos);
if (length > SHORTLEN) delete [] str;
length = newLength;
if (length > SHORTLEN)
str = tmp;
else
{
strcpy (shortstr, tmp);
delete [] tmp;
str = shortstr;
}
return *this;
}
MyStr &MyStr::WriteAt(unsigned pos, const MyStr& s)
{
if(pos > length)
{
MyStr::ErrHandler();
return *this;
}
unsigned n = length - pos;
if(s.length < n)
n = s.length;
strncpy(str + pos, s.str, n);
return *this;
}
void MyStr::ConvertTextToExcel()
{
/*
for (int i = 0; i < Length(); i++)
{
if ((*this)[i]==',') {(*this)[i] = ';';}
else if ((*this)[i]=='.') {(*this)[i] = ',';}
}
*/
}
void MyStr::ConvertExcelToText()
{
/*
for (int i = 0; i < Length(); i++)
{
if ((*this)[i]==',') {(*this)[i] = '.';}
else if ((*this)[i]==';') {(*this)[i] = ',';}
}
*/
}
MyStr& MyStr::operator = (const MyStr& s)
{
if (length > SHORTLEN) delete [] str;
length = s.length;
if (length > SHORTLEN)
str = new char[length + 1];
else
str = shortstr;
strcpy(str, s.str);
return *this;
}
MyStr operator + (const MyStr& s1, const MyStr& s2)
{
MyStr tmp(s1.length + s2.length, 0);
if (s1.length != 0) strcpy(tmp.str, s1.str);
if (s2.length != 0) strcpy(tmp.str + s1.length, s2.str);
return tmp;
}
void MyStr::operator += (const MyStr& s)
{
if (length+s.length <= SHORTLEN)
{
if (s.length != 0) strcpy(shortstr + length, s.str);
}
else
{
char *tmp = new char[length + s.length + 1];
if (length != 0) strcpy(tmp, str);
if (s.length != 0) strcpy(tmp + length, s.str);
if (length > SHORTLEN) delete [] str;
length += s.length;
str = tmp;
}
}
char& MyStr::operator [] (unsigned n)
{
static char dummy;
if(n < length)
return str[n];
else
{
MyStr::ErrHandler();
return dummy;
}
}
char MyStr::operator [] (unsigned n) const
{
static char dummy;
if(n < length)
return str[n];
else
{
MyStr::ErrHandler();
return dummy;
}
}
MyStr MyStr::operator () (unsigned l, unsigned r)
{
if((l > r) || (r > length))
{
MyStr::ErrHandler();
MyStr s;
return s;
}
else
{
int n = r - l + 1;
MyStr tmp(n, 0);
strncpy(tmp.str, str + 1, n);
return tmp;
}
}
string MyStr::cpp_string(void) const
{
string aux(str,length);
return aux;
}
/*
istream& operator >> (istream& is, MyStr& s)
{
const int buflen = 1000;
char buffer[buflen+1];
int end = 0;
s = "";
MyStr str;
while (!end)
{
is.get(buffer, buflen);
str = MyStr(buffer);
s += str;
if (is.peek() == EOF) {end = 1;}
}
return is;
}
*/
/*
#ifdef __borland
::ifstream& operator >> (::ifstream& is, MyStr& s) // wb
{ // wb
const int buflen = 1000; // wb
char buffer[buflen+1]; // wb
// wb
int end = 0; // wb
s = ""; // wb
MyStr str; // wb
// wb
while (!end) // wb
{ // wb
is.get(buffer, buflen); // wb
str = MyStr(buffer); // wb
s += str; // wb
if (is.peek() == EOF) {end = 1;} // wb
} // wb
// wb
return is; // wb
}
#endif
*/
}

216
libsrc/general/mystring.hpp Normal file
View File

@ -0,0 +1,216 @@
//**************************************************************
//
// filename: mystring.h
//
// project: doctoral thesis, program smart
//
// autor: Dipl.-Ing. Gerstmayr Johannes
//
// generated: 20.12.98
// last change: 20.12.98
// description: base class for strings
// remarks: string with n characters has
// 0..n-1 characters and at pos n a 0
//
//**************************************************************
#ifndef MYSTRING__H
#define MYSTRING__H
class Point3d;
class Vec3d;
// extract string str which is enclosed by the given character encl from a given string in
void ReadEnclString(istream & in, string & str, const char encl);
class MyStr;
MyStr operator + (const MyStr &, const MyStr &);
int operator == (const MyStr &, const MyStr &);
int operator < (const MyStr &, const MyStr &);
int operator <= (const MyStr &, const MyStr &);
int operator > (const MyStr &, const MyStr &);
int operator >= (const MyStr &, const MyStr &);
int operator != (const MyStr &, const MyStr &);
ostream& operator << (ostream &, const MyStr &);
istream& operator >> (istream &, MyStr &);
class MyStr
{
public:
MyStr();
MyStr(const char *);
MyStr(char);
MyStr(const MyStr &);
MyStr(int);
MyStr(void *);
MyStr(long);
MyStr(double);
MyStr(const Point3d& p);
MyStr(const Vec3d& p);
MyStr(const string & st);
~MyStr();
MyStr Left(unsigned);
MyStr Right(unsigned);
MyStr& InsertAt(unsigned, const MyStr &);
MyStr& WriteAt(unsigned, const MyStr &);
unsigned Length() const;
int Find(const char);
int Find(const char *);
int Find(const MyStr &);
MyStr& operator = (const MyStr &);
friend MyStr operator + (const MyStr &, const MyStr &);
void operator += (const MyStr &);
char* c_str();
string cpp_string(void) const;
//change every ',' -> ';', '.' -> ','
void ConvertTextToExcel();
//change every ','->'.', ';'->','
void ConvertExcelToText();
MyStr operator () (unsigned, unsigned);
operator int();
operator double();
operator long();
operator char *();
char& operator [] (unsigned int);
char operator [] (unsigned int) const;
friend int operator == (const MyStr &, const MyStr &);
friend int operator < (const MyStr &, const MyStr &);
friend int operator <= (const MyStr &, const MyStr &);
friend int operator > (const MyStr &, const MyStr &);
friend int operator >= (const MyStr &, const MyStr &);
friend int operator != (const MyStr &, const MyStr &);
friend ostream& operator << (ostream &, const MyStr &);
friend istream& operator >> (istream &, MyStr &);
static void SetToErrHandler(void (*)());
private:
MyStr(unsigned, int);
char *str;
unsigned length;
enum { SHORTLEN = 24 };
char shortstr[SHORTLEN+1];
static void(*ErrHandler)();
};
inline MyStr::MyStr()
{
length = 0;
str = shortstr;
str[0] = 0;
}
inline MyStr::MyStr(char s)
{
length = 1;
str = shortstr;
str[0] = s;
str[1] = (char)0;
}
inline MyStr::~MyStr()
{
if (length > SHORTLEN)
delete [] str;
}
inline unsigned MyStr::Length() const
{
return length;
}
inline int MyStr::Find(const char c)
{
char *pos = strchr(str, int(c));
return pos ? int(pos - str) : -1;
}
inline int MyStr::Find(const MyStr &s)
{
char *pos = strstr(str, s.str);
return pos ? int(pos - str) : -1;
}
inline int MyStr::Find(const char *s)
{
char *pos = strstr(str, s);
return pos ? int(pos - str) : -1;
}
inline MyStr::operator int()
{
return atoi(str);
}
inline MyStr::operator double()
{
return atof(str);
}
inline MyStr::operator long()
{
return atol(str);
}
inline MyStr::operator char *()
{
return str;
}
inline char* MyStr::c_str()
{
return str;
}
inline int operator == (const MyStr &s1, const MyStr& s2)
{
return strcmp(s1.str, s2.str) == 0;
}
inline int operator < (const MyStr &s1, const MyStr& s2)
{
return strcmp(s1.str, s2.str) < 0;
}
inline int operator <= (const MyStr &s1, const MyStr& s2)
{
return strcmp(s1.str, s2.str) <= 0;
}
inline int operator > (const MyStr &s1, const MyStr& s2)
{
return strcmp(s1.str, s2.str) > 0;
}
inline int operator >= (const MyStr &s1, const MyStr& s2)
{
return strcmp(s1.str, s2.str) >= 0;
}
inline int operator != (const MyStr &s1, const MyStr& s2)
{
return !(s1 == s2);
}
inline ostream& operator << (ostream& os, const MyStr& s)
{
return os << s.str;
}
inline void MyStr::SetToErrHandler(void (*Handler)())
{
ErrHandler = Handler;
};
#endif

View File

@ -0,0 +1,184 @@
#ifndef NETGEN_OUT_STREAM_HPP__
#define NETGEN_OUT_STREAM_HPP__
// #include <ostream>
// #include <mystdlib.h>
// #include <meshing.hpp>
#ifdef PARALLEL
extern int id;
extern int ntasks;
#endif
extern int printmessage_importance;
class Imp
{
int importance;
public:
Imp () : importance(0) { ; }
Imp ( int aimportance ) : importance(aimportance) { ; }
int GetImp () const { return importance; }
};
class Proc
{
int proc;
public:
Proc () : proc(0) { ; }
Proc ( int aproc ) : proc(aproc) { ; }
int GetProc () const { return proc; }
};
class Procs
{
const netgen::FlatArray<int> procs;
public:
Procs ( const netgen::FlatArray<int> & aprocs ) : procs (aprocs) { ; }
const netgen::FlatArray<int> & GetProcs () const { return procs; }
};
class NetgenOutStream
{
ostream * out;
bool print;
bool printheader;
public:
NetgenOutStream() :
out(&std::cout),
print(1),
printheader(1)
{
;
}
NetgenOutStream(ostream * aout, Imp imp ) :
out(aout),
printheader(1)
{
if ( netgen::printmessage_importance >= imp.GetImp() )
print = true;
else
print = false;
}
NetgenOutStream(ostream * aout, Proc proc ) :
out(aout),
printheader(1)
{
#ifdef PARALLEL
if ( netgen::id == proc.GetProc() )
print = true;
else
print = false;
#else
if ( 0 == proc.GetProc() )
print = true;
else
print = false;
#endif
}
NetgenOutStream(ostream * aout, Procs & procs ) :
out(aout),
printheader(1)
{
#ifdef PARALLEL
if ( procs.GetProcs().Contains(netgen::id) )
print = true;
else
print = false;
#else
if ( procs.GetProcs().Contains(0) )
print = true;
else
print = false;
#endif
}
ostream & OStream ()
{
return *out;
}
template <typename T>
NetgenOutStream & operator<< (T & var)
{
if ( print )
{
#ifdef PARALLEL
if ( printheader )
{
*out << "proc " << netgen::id << ": ";
printheader = false;
}
#endif
*out << var;
}
return (*this);
}
NetgenOutStream& operator<< (ostream& ( *pf )(ostream&))
{
if ( print )
*out << (*pf) ;
return (*this);
}
NetgenOutStream& operator<< (ios& ( *pf )(ios&))
{
if ( print)
*out << (*pf) ;
printheader = 1;
return (*this);
}
NetgenOutStream& operator<< (ios_base& ( *pf )(ios_base&))
{
if (print )
*out << (*pf) ;
return (*this);
}
};
NetgenOutStream operator<< ( ostream & ost, Imp imp );
NetgenOutStream operator<< ( ostream & ost, Proc proc );
NetgenOutStream operator<< ( ostream & ost, Procs & procs );
// {
// return ( NetgenOutStream ( &ost, imp.GetImp() ) );
// }
// template <typename T>
// NetgenOutStream& operator<< (NetgenOutStream& out, T c )
// {
// out.OStream() << c << endl;
// return out;
// }
#endif

View File

@ -0,0 +1,33 @@
/**************************************************************************/
/* File: ngexception.cpp */
/* Author: Joachim Schoeberl */
/* Date: 16. Jan. 02 */
/**************************************************************************/
#include <myadt.hpp>
namespace netgen
{
//using namespace netgen;
NgException :: NgException (const string & s)
: what(s)
{
;
}
NgException :: ~NgException ()
{
;
}
/// append string to description
void NgException :: Append (const string & s)
{
what += s;
}
}

View File

@ -0,0 +1,30 @@
#ifndef FILE_NGEXCEPTION
#define FILE_NGEXCEPTION
/**************************************************************************/
/* File: ngexception.hpp */
/* Author: Joachim Schoeberl */
/* Date: 16. Jan. 2002 */
/**************************************************************************/
/// Base class for all ng exceptions
class NgException
{
/// verbal description of exception
string what;
public:
///
NgException (const string & s);
///
virtual ~NgException ();
/// append string to description
void Append (const string & s);
// void Append (const char * s);
/// verbal description of exception
const string & What() const { return what; }
};
#endif

64
libsrc/general/optmem.cpp Normal file
View File

@ -0,0 +1,64 @@
/**************************************************************************/
/* File: optmem.cc */
/* Author: Joachim Schoeberl */
/* Date: 04. Apr. 97 */
/**************************************************************************/
/*
Abstract data type ARRAY
*/
#include <mystdlib.h>
#include <myadt.hpp>
namespace netgen
{
//using namespace netgen;
BlockAllocator :: BlockAllocator (unsigned asize, unsigned ablocks)
: bablocks (0)
{
if (asize < sizeof(void*))
asize = sizeof(void*);
size = asize;
blocks = ablocks;
freelist = NULL;
}
BlockAllocator :: ~BlockAllocator ()
{
//for (unsigned i = 0; i < bablocks.Size(); i++)
for (int i = 0; i < bablocks.Size(); i++)
delete [] bablocks[i];
}
void * BlockAllocator :: Alloc ()
{
// return new char[size];
if (!freelist)
{
// cout << "freelist = " << freelist << endl;
// cout << "BlockAlloc: " << size*blocks << endl;
char * hcp = new char [size * blocks];
bablocks.Append (hcp);
bablocks.Last() = hcp;
for (unsigned i = 0; i < blocks-1; i++)
*(void**)&(hcp[i * size]) = &(hcp[ (i+1) * size]);
*(void**)&(hcp[(blocks-1)*size]) = NULL;
freelist = hcp;
}
void * p = freelist;
freelist = *(void**)freelist;
return p;
}
/*
void BlockAllocator :: Free (void * p)
{
*(void**)p = freelist;
freelist = p;
}
*/
}

59
libsrc/general/optmem.hpp Normal file
View File

@ -0,0 +1,59 @@
#ifndef FILE_OPTMEM
#define FILE_OPTMEM
/**************************************************************************/
/* File: optmem.hh */
/* Author: Joachim Schoeberl */
/* Date: 04. Apr. 97 */
/**************************************************************************/
/**
Optimized Memory allocation classes
*/
class BlockAllocator
{
private:
///
unsigned size, blocks;
///
void * freelist;
///
ARRAY<char*> bablocks;
public:
///
BlockAllocator (unsigned asize, unsigned ablocks = 100);
///
~BlockAllocator ();
///
void * Alloc ();
/*
{
if (!freelist)
Alloc2();
void * p = freelist;
// freelist = *(void**)freelist;
freelist = *static_cast<void**> (freelist);
return p;
}
*/
///
void Free (void * p)
{
*(void**)p = freelist;
freelist = p;
}
private:
// void Alloc2 ();
};
#endif

View File

@ -0,0 +1,40 @@
/**************************************************************************/
/* File: parthreads.cpp */
/* Author: Joachim Schoeberl */
/* Date: 01. Jun. 95 */
/**************************************************************************/
#include <mystdlib.h>
#include <myadt.hpp>
/*
namespace netgen
{
using namespace netgen;
#ifdef WIN32
NgLock :: NgLock (NgMutex & mut)
: sl(&mut.cs)
{
;
}
void NgLock :: Lock ()
{
sl.Lock();
}
void NgLock :: UnLock ()
{
sl.Unlock();
}
#else
#endif
}
*/

View File

@ -0,0 +1,129 @@
#ifndef FILE_PARTHREADS
#define FILE_PARTHREADS
/**************************************************************************/
/* File: parthreads.hh */
/* Author: Joachim Schoeberl */
/* Date: 22. Nov. 2000 */
/**************************************************************************/
/*
Parallel thread, Mutex,
*/
#ifdef NO_PARALLEL_THREADS
class NgMutex { };
class NgLock
{
public:
NgLock (NgMutex & mut, bool lock = 0) { ; }
void Lock () { ; }
void UnLock () { ; }
};
#else
#ifdef _MSC_VER
class NgMutex
{
CCriticalSection cs;
public:
NgMutex ()
{ ; }
friend class NgLock;
};
class NgLock
{
CSingleLock sl;
bool locked;
public:
NgLock (NgMutex & mut, bool lock = 0)
: sl(&mut.cs)
{
if (lock) sl.Lock();
locked = lock;
}
~NgLock ()
{
if (locked) sl.Unlock();
}
void Lock ()
{
sl.Lock();
locked = 1;
}
void UnLock ()
{
sl.Unlock();
locked = 0;
}
};
#else
// #include <pthread.h>
class NgMutex
{
pthread_mutex_t mut;
public:
NgMutex ()
{
pthread_mutex_init (&mut, NULL);
}
friend class NgLock;
};
class NgLock
{
pthread_mutex_t & mut;
bool locked;
public:
NgLock (NgMutex & ngmut, bool lock = false)
: mut (ngmut.mut)
{
if (lock)
pthread_mutex_lock (&mut);
locked = lock;
};
~NgLock()
{
if (locked)
pthread_mutex_unlock (&mut);
}
void Lock ()
{
pthread_mutex_lock (&mut);
locked = true;
}
void UnLock ()
{
pthread_mutex_unlock (&mut);
locked = false;
}
/*
int TryLock ()
{
return pthread_mutex_trylock (&mut);
}
*/
};
#endif
#endif
#endif

112
libsrc/general/profiler.cpp Normal file
View File

@ -0,0 +1,112 @@
/**************************************************************************/
/* File: profiler.cpp */
/* Author: Joachim Schoeberl */
/* Date: 19. Apr. 2002 */
/**************************************************************************/
#include <myadt.hpp>
namespace netgen
{
//using namespace netgen;
long int NgProfiler::tottimes[SIZE];
long int NgProfiler::starttimes[SIZE];
long int NgProfiler::counts[SIZE];
string NgProfiler::names[SIZE];
int NgProfiler::usedcounter[SIZE];
NgProfiler :: NgProfiler()
{
for (int i = 0; i < SIZE; i++)
{
tottimes[i] = 0;
usedcounter[i] = 0;
}
total_timer = CreateTimer ("total CPU time");
StartTimer (total_timer);
}
NgProfiler :: ~NgProfiler()
{
StopTimer (total_timer);
//ofstream prof;
//prof.open("ng.prof");
// ofstream-constructor may be called after STL-stuff is destructed,
// which leads to an "order of destruction"-problem,
// thus we use the C-variant:
char filename[100];
#ifdef PARALLEL
sprintf (filename, "netgen.prof.%d", id);
#else
sprintf (filename, "netgen.prof");
#endif
FILE *prof = fopen(filename,"w");
Print (prof);
fclose(prof);
}
// void NgProfiler :: Print (ostream & prof)
// {
// for (int i = 0; i < SIZE; i++)
// if (counts[i] != 0 || usedcounter[i] != 0)
// {
// prof.setf (ios::fixed, ios::floatfield);
// prof.setf (ios::showpoint);
// prof // << "job " << setw(3) << i
// << "calls " << setw(8) << counts[i]
// << ", time " << setprecision(2) << setw(6) << double(tottimes[i]) / CLOCKS_PER_SEC << " sec";
// if (usedcounter[i])
// prof << " " << names[i];
// else
// prof << " " << i;
// prof << endl;
// }
// }
void NgProfiler :: Print (FILE * prof)
{
for (int i = 0; i < SIZE; i++)
if (counts[i] != 0 || usedcounter[i] != 0)
{
//fprintf(prof,"job %3i calls %8i, time %6.2f sec",i,counts[i],double(tottimes[i]) / CLOCKS_PER_SEC);
fprintf(prof,"calls %8li, time %6.2f sec",counts[i],double(tottimes[i]) / CLOCKS_PER_SEC);
if(usedcounter[i])
fprintf(prof," %s",names[i].c_str());
else
fprintf(prof," %i",i);
fprintf(prof,"\n");
}
}
int NgProfiler :: CreateTimer (const string & name)
{
for (int i = SIZE-1; i > 0; i--)
if(names[i] == name)
return i;
for (int i = SIZE-1; i > 0; i--)
if (!usedcounter[i])
{
usedcounter[i] = 1;
names[i] = name;
return i;
}
return -1;
}
NgProfiler prof;
}

View File

@ -0,0 +1,62 @@
#ifndef FILE_NG_PROFILER
#define FILE_NG_PROFILER
/**************************************************************************/
/* File: profiler.hpp */
/* Author: Joachim Schoeberl */
/* Date: 5. Jan. 2005 */
/**************************************************************************/
#ifdef VTRACE
#include "vt_user.h"
#else
#define VT_USER_START(n)
#define VT_USER_END(n)
#define VT_TRACER(n)
#endif
class NgProfiler
{
enum { SIZE = 1000 };
static long int tottimes[SIZE];
static long int starttimes[SIZE];
static long int counts[SIZE];
static string names[SIZE];
static int usedcounter[SIZE];
int total_timer;
public:
NgProfiler();
~NgProfiler();
static int CreateTimer (const string & name);
static void StartTimer (int nr)
{
starttimes[nr] = clock(); counts[nr]++;
VT_USER_START (const_cast<char*> (names[nr].c_str()));
}
static void StopTimer (int nr)
{
tottimes[nr] += clock()-starttimes[nr];
VT_USER_END (const_cast<char*> (names[nr].c_str()));
}
//static void Print (ostream & ost);
static void Print (FILE * prof);
class RegionTimer
{
int nr;
public:
RegionTimer (int anr) : nr(anr)
{ StartTimer (nr); }
~RegionTimer () { StopTimer (nr); }
};
};
#endif

70
libsrc/general/seti.cpp Normal file
View File

@ -0,0 +1,70 @@
#include <mystdlib.h>
#include <myadt.hpp>
namespace netgen
{
//using namespace netgen;
IndexSet :: IndexSet (int maxind)
{
SetMaxIndex (maxind);
}
IndexSet :: ~IndexSet ()
{
Clear();
}
void IndexSet :: SetMaxIndex (int maxind)
{
if (maxind > flags.Size())
{
flags.SetSize (2 * maxind);
flags.Clear();
}
}
/*
int IndexSet :: IsIn (int ind) const
{
return flags.Test (ind);
}
*/
/*
void IndexSet :: Add (int ind)
{
if (ind > flags.Size())
{
cerr << "out of range" << endl;
exit (1);
}
if (!flags.Test(ind))
{
set.Append (ind);
flags.Set (ind);
}
}
*/
void IndexSet :: Del (int ind)
{
for (int i = 1; i <= set.Size(); i++)
if (set.Get(i) == ind)
{
set.DeleteElement (ind);
break;
}
flags.Clear (ind);
}
void IndexSet :: Clear ()
{
for (int i = 1; i <= set.Size(); i++)
flags.Clear (set.Get(i));
set.SetSize (0);
}
}

45
libsrc/general/seti.hpp Normal file
View File

@ -0,0 +1,45 @@
#ifndef FILE_SETI
#define FILE_SETI
/**************************************************************************/
/* File: seti.hh */
/* Author: Joachim Schoeberl */
/* Date: 20. Mar. 98 */
/**************************************************************************/
/**
Set of Integers
*/
class IndexSet
{
ARRAY<int> set;
BitArray flags;
public:
IndexSet (int maxind);
~IndexSet ();
/// increase range to maxind
void SetMaxIndex (int maxind);
int IsIn (int ind) const
{
return flags.Test (ind);
}
void Add (int ind)
{
if (!flags.Test(ind))
{
set.Append (ind);
flags.Set (ind);
}
}
void Del (int ind);
void Clear ();
const ARRAY<int> & Array() { return set; }
};
#endif

75
libsrc/general/sort.cpp Normal file
View File

@ -0,0 +1,75 @@
/**************************************************************************/
/* File: sort.cc */
/* Author: Joachim Schoeberl */
/* Date: 07. Jan. 00 */
/**************************************************************************/
/*
Sorting
*/
#include <algorithm>
#include <mystdlib.h>
#include <myadt.hpp>
namespace netgen
{
void Sort (const ARRAY<double> & values,
ARRAY<int> & order)
{
int n = values.Size();
int i, j;
order.SetSize (n);
for (i = 1; i <= n; i++)
order.Elem(i) = i;
for (i = 1; i <= n-1; i++)
for (j = 1; j <= n-1; j++)
if (values.Get(order.Elem(j)) > values.Get(order.Elem(j+1)))
{
Swap (order.Elem(j), order.Elem(j+1));
}
}
void QickSortRec (const ARRAY<double> & values,
ARRAY<int> & order,
int left, int right)
{
int i, j;
double midval;
i = left;
j = right;
midval = values.Get(order.Get((i+j)/2));
do
{
while (values.Get(order.Get(i)) < midval) i++;
while (midval < values.Get(order.Get(j))) j--;
if (i <= j)
{
Swap (order.Elem(i), order.Elem(j));
i++; j--;
}
}
while (i <= j);
if (left < j) QickSortRec (values, order, left, j);
if (i < right) QickSortRec (values, order, i, right);
}
void QickSort (const ARRAY<double> & values,
ARRAY<int> & order)
{
int i, n = values.Size();
order.SetSize (n);
for (i = 1; i <= n; i++)
order.Elem(i) = i;
QickSortRec (values, order, 1, order.Size());
}
}

42
libsrc/general/sort.hpp Normal file
View File

@ -0,0 +1,42 @@
#ifndef FILE_SORT
#define FILE_SORT
/**************************************************************************/
/* File: sort.hh */
/* Author: Joachim Schoeberl */
/* Date: 07. Jan. 00 */
/**************************************************************************/
// order(i) is sorted index of element i
extern void Sort (const ARRAY<double> & values,
ARRAY<int> & order);
extern void QickSort (const ARRAY<double> & values,
ARRAY<int> & order);
template <class T>
inline void BubbleSort (int size, T * data)
{
T hv;
for (int i = 0; i < size; i++)
for (int j = i+1; j < size; j++)
if (data[i] > data[j])
{
hv = data[i];
data[i] = data[j];
data[j] = hv;
}
}
template <class T>
inline void BubbleSort (ARRAY<T> & data)
{
if(data.Size() > 0)
BubbleSort (data.Size(), &data[data.Begin()]);
}
#endif

172
libsrc/general/spbita2d.cpp Normal file
View File

@ -0,0 +1,172 @@
/**************************************************************************/
/* File: spbita2d.cpp */
/* Author: Joachim Schoeberl */
/* Date: 01. Jun. 95 */
/**************************************************************************/
/*
Implementation of sparse 2 dimensional bitarray
*/
#include <mystdlib.h>
#include <myadt.hpp>
namespace netgen
{
//using namespace netgen;
SPARSE_BIT_ARRAY_2D :: SPARSE_BIT_ARRAY_2D (int ah, int aw)
{
lines = NULL;
SetSize (ah, aw);
}
SPARSE_BIT_ARRAY_2D :: ~SPARSE_BIT_ARRAY_2D ()
{
DeleteElements ();
delete lines;
}
void SPARSE_BIT_ARRAY_2D :: SetSize (int ah, int aw)
{
DeleteElements();
if (lines)
{
delete lines;
lines = NULL;
}
if (!aw) aw = ah;
height = ah;
width = aw;
if (!ah) return;
lines = new linestruct[ah];
if (lines)
{
for (int i = 0; i < ah; i++)
{
lines[i].size = 0;
lines[i].maxsize = 0;
lines[i].col = NULL;
}
}
else
{
height = width = 0;
MyError ("SPARSE_ARRAY::SetSize: Out of memory");
}
}
void SPARSE_BIT_ARRAY_2D :: DeleteElements ()
{
if (lines)
{
for (int i = 0; i < height; i++)
{
if (lines[i].col)
{
delete [] lines[i].col;
lines[i].col = NULL;
lines[i].size = 0;
lines[i].maxsize = 0;
}
}
}
}
int SPARSE_BIT_ARRAY_2D :: Test (int i, int j) const
{
int k, max, *col;
if (!lines) return 0;
if (i < 1 || i > height) return 0;
col = lines[i-1].col;
max = lines[i-1].size;
for (k = 0; k < max; k++, col++)
if (*col == j) return 1;
return 0;
}
void SPARSE_BIT_ARRAY_2D :: Set(int i, int j)
{
int k, max, *col;
i--;
col = lines[i].col;
max = lines[i].size;
for (k = 0; k < max; k++, col++)
if (*col == j)
return;
if (lines[i].size)
{
if (lines[i].size == lines[i].maxsize)
{
col = new int[lines[i].maxsize+2];
if (col)
{
lines[i].maxsize += 2;
memcpy (col, lines[i].col, sizeof (int) * lines[i].size);
delete [] lines[i].col;
lines[i].col = col;
}
else
{
MyError ("SPARSE_BIT_ARRAY::Set: Out of mem 1");
return;
}
}
else
col = lines[i].col;
if (col)
{
k = lines[i].size-1;
while (k >= 0 && col[k] > j)
{
col[k+1] = col[k];
k--;
}
k++;
lines[i].size++;
col[k] = j;
return;
}
else
{
MyError ("SPARSE_ARRAY::Set: Out of memory 2");
}
}
else
{
lines[i].col = new int[4];
if (lines[i].col)
{
lines[i].maxsize = 4;
lines[i].size = 1;
lines[i].col[0] = j;
return;
}
else
{
MyError ("SparseMatrix::Elem: Out of memory 3");
}
}
}
}

View File

@ -0,0 +1,56 @@
#ifndef FILE_SPBITA2D
#define FILE_SPBITA2D
/**************************************************************************/
/* File: spbita2d.hh */
/* Author: Joachim Schoeberl */
/* Date: 01. Jun. 95 */
/**************************************************************************/
/**
Implementation of sparse 2 dimensional bitarray
*/
class SPARSE_BIT_ARRAY_2D
{
class linestruct { public: INDEX size; INDEX maxsize; INDEX * col; };
///
linestruct * lines;
///
INDEX height, width;
public:
///
SPARSE_BIT_ARRAY_2D (INDEX ah = 0, INDEX aw = 0);
///
~SPARSE_BIT_ARRAY_2D ();
///
void SetSize (INDEX ah, INDEX aw = 0);
///
void DeleteElements ();
///
int Get (INDEX i, INDEX j) const;
///
INDEX Height () const { return height; }
///
INDEX Width () const { return width; }
///
void Set (INDEX i, INDEX j);
///
int Test (INDEX i, INDEX j) const;
///
INDEX BitsInLine (INDEX i) const { return lines[i-1].size; }
///
INDEX GetIndex (INDEX i, INDEX nr) const { return lines[i-1].col[nr-1]; }
};
#endif

112
libsrc/general/stack.hpp Normal file
View File

@ -0,0 +1,112 @@
#ifndef FILE_STACK
#define FILE_STACK
/*****************************************************************************/
/* File: stack.hh */
/* Author: Wolfram Muehlhuber */
/* Date: September 98 */
/*****************************************************************************/
/*
Stack class, based on a resizable array
*/
#include "array.hpp"
///
template <class T> class STACK
{
public:
///
inline STACK (INDEX asize = 0, INDEX ainc = 0);
///
inline ~STACK ();
///
inline void Push (const T & el);
///
inline T & Pop ();
///
const inline T & Top () const;
///
inline int IsEmpty () const;
///
inline void MakeEmpty ();
private:
///
ARRAY<T> elems;
///
INDEX size;
};
/*
Stack class, based on a resizable array
*/
template <class T>
inline STACK<T> :: STACK (INDEX asize, INDEX ainc)
: elems(asize, ainc)
{
size = 0;
}
template <class T>
inline STACK<T> :: ~STACK ()
{
;
}
template <class T>
inline void STACK<T> :: Push (const T & el)
{
if (size < elems.Size())
elems.Elem(++size) = el;
else
{
elems.Append(el);
size++;
}
}
template <class T>
inline T & STACK<T> :: Pop ()
{
return elems.Elem(size--);
}
template <class T>
const inline T & STACK<T> :: Top () const
{
return elems.Get(size);
}
template <class T>
inline int STACK<T> :: IsEmpty () const
{
return (size == 0);
}
template <class T>
inline void STACK<T> :: MakeEmpty ()
{
size = 0;
}
#endif

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