2 +++ netgen/CMakeLists.txt
4 +# Copyright (C) 2016 OPEN CASCADE
6 +# This library is free software; you can redistribute it and/or
7 +# modify it under the terms of the GNU Lesser General Public
8 +# License as published by the Free Software Foundation; either
9 +# version 2.1 of the License, or (at your option) any later version.
11 +# This library is distributed in the hope that it will be useful,
12 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
13 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 +# Lesser General Public License for more details.
16 +# You should have received a copy of the GNU Lesser General Public
17 +# License along with this library; if not, write to the Free Software
18 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
23 +INCLUDE(CMakeDependentOption)
25 +PROJECT(netgen C CXX)
27 +# Ensure a proper linker behavior:
28 +CMAKE_POLICY(SET CMP0003 NEW)
32 +# Project name, upper case
33 +STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
35 +SET(${PROJECT_NAME_UC}_MAJOR_VERSION 5)
36 +SET(${PROJECT_NAME_UC}_MINOR_VERSION 3)
37 +SET(${PROJECT_NAME_UC}_PATCH_VERSION 1)
38 +SET(${PROJECT_NAME_UC}_VERSION
39 + ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
41 +# Common CMake macros
42 +# ===================
43 +LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
45 +INCLUDE(FindPLATFORM)
49 +# Detect ZLIB on Windows
51 + SET(ZLIB_ROOT_DIR $ENV{ZLIB_ROOT_DIR})
52 + IF(EXISTS ${ZLIB_ROOT_DIR})
53 + SET(ZLIB_ROOT ${ZLIB_ROOT_DIR})
55 + IF (NOT ${ZLIB_FOUND})
56 + MESSAGE(FATAL_ERROR "We absolutely need the zlib library, please check zlib installation !")
59 + MESSAGE(FATAL_ERROR "We absolutely need the zlib library, please define ZLIB_ROOT_DIR !")
66 +ADD_DEFINITIONS(-DNO_PARALLEL_THREADS)
67 +ADD_DEFINITIONS(-DOCCGEOMETRY)
70 +SET(NETGEN_INSTALL_BINS "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Install path: netgen binaries")
71 +SET(NETGEN_INSTALL_LIBS "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Install path: netgen libs")
72 +SET(NETGEN_INSTALL_HEADERS "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Install path: netgen headers")
73 +SET(NETGEN_INSTALL_CMAKE "${CMAKE_INSTALL_PREFIX}/cmake" CACHE PATH "Install path: netgen cmake files")
76 +ADD_SUBDIRECTORY(nglib)
77 +ADD_SUBDIRECTORY(cmake)
79 --- netgen_ref/Makefile.am
80 +++ netgen/Makefile.am
85 -SUBDIRS = libsrc ng tutorials doc windows nglib
86 +SUBDIRS = libsrc nglib #tutorials doc windows nglib
88 # TESTS = ng/netgen -batchmode
90 --- netgen_ref/Makefile.in
91 +++ netgen/Makefile.in
93 top_srcdir = @top_srcdir@
94 ACLOCAL_AMFLAGS = -I m4
96 -SUBDIRS = libsrc ng tutorials doc windows nglib
97 +SUBDIRS = libsrc nglib #tutorials doc windows nglib
99 $(MAKE) $(AM_MAKEFLAGS) all-recursive
102 +++ netgen/cmake/CMakeLists.txt
104 +# Copyright (C) 2016 OPEN CASCADE
106 +# This library is free software; you can redistribute it and/or
107 +# modify it under the terms of the GNU Lesser General Public
108 +# License as published by the Free Software Foundation; either
109 +# version 2.1 of the License, or (at your option) any later version.
111 +# This library is distributed in the hope that it will be useful,
112 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
113 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
114 +# Lesser General Public License for more details.
116 +# You should have received a copy of the GNU Lesser General Public
117 +# License along with this library; if not, write to the Free Software
118 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
120 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
124 + INSTALL(FILES FindZLIB.cmake DESTINATION ${NETGEN_INSTALL_CMAKE})
126 \ No newline at end of file
128 +++ netgen/cmake/FindCAS.cmake
130 +# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
132 +# This library is free software; you can redistribute it and/or
133 +# modify it under the terms of the GNU Lesser General Public
134 +# License as published by the Free Software Foundation; either
135 +# version 2.1 of the License.
137 +# This library is distributed in the hope that it will be useful,
138 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
139 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
140 +# Lesser General Public License for more details.
142 +# You should have received a copy of the GNU Lesser General Public
143 +# License along with this library; if not, write to the Free Software
144 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
146 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
149 +SET(CASROOT $ENV{CASROOT})
150 +ADD_DEFINITIONS(-DLIN -DLINTEL -DCSFDB)
151 +ADD_DEFINITIONS(-DNo_exception)
152 +ADD_DEFINITIONS(-DHAVE_LIMITS_H)
154 +IF(CMAKE_SIZEOF_VOID_P STREQUAL 8)
155 + ADD_DEFINITIONS(-D_OCC64)
156 +ENDIF(CMAKE_SIZEOF_VOID_P STREQUAL 8)
159 + FIND_LIBRARY(Xmu Xmu)
161 + SET(CAS_LDPATH ${Xmu})
166 + IF(CMAKE_BUILD_TYPE STREQUAL Debug)
167 + SET(CASROOT_LIBDIR ${CASROOT}/win32/libd ${CASROOT}/win64/vc14/lib)
168 + ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
169 + SET(CASROOT_LIBDIR ${CASROOT}/win32/lib ${CASROOT}/win64/vc14/lib)
170 + ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
172 + SET(CASROOT_LIBDIR ${CASROOT}/lib)
175 +SET(_CAS_VERSION_FILE_NAME Standard_Version.hxx)
177 +# Include directories:
178 +FIND_PATH(CAS_INCLUDE_DIRS ${_CAS_VERSION_FILE_NAME} PATHS ${CASROOT} PATH_SUFFIXES include/opencascade)
179 +IF(CAS_INCLUDE_DIRS)
181 + FIND_PATH(CAS_INCLUDE_DIRS ${_CAS_VERSION_FILE_NAME} PATHS ${CASROOT} PATH_SUFFIXES include inc)
185 +FIND_LIBRARY(BinLPlugin BinLPlugin PATHS ${CASROOT_LIBDIR})
186 +FIND_LIBRARY(BinPlugin BinPlugin PATHS ${CASROOT_LIBDIR})
187 +FIND_LIBRARY(BinTObjPlugin BinTObjPlugin PATHS ${CASROOT_LIBDIR})
188 +FIND_LIBRARY(BinXCAFPlugin BinXCAFPlugin PATHS ${CASROOT_LIBDIR})
189 +FIND_LIBRARY(FWOSPlugin FWOSPlugin PATHS ${CASROOT_LIBDIR})
191 +FIND_LIBRARY(PTKernel PTKernel PATHS ${CASROOT_LIBDIR})
192 +FIND_LIBRARY(StdLPlugin StdLPlugin PATHS ${CASROOT_LIBDIR})
193 +FIND_LIBRARY(StdPlugin StdPlugin PATHS ${CASROOT_LIBDIR})
194 +FIND_LIBRARY(TKAdvTools TKAdvTools PATHS ${CASROOT_LIBDIR})
195 +FIND_LIBRARY(TKBin TKBin PATHS ${CASROOT_LIBDIR})
196 +FIND_LIBRARY(TKBinL TKBinL PATHS ${CASROOT_LIBDIR})
197 +FIND_LIBRARY(TKBinTObj TKBinTObj PATHS ${CASROOT_LIBDIR})
198 +FIND_LIBRARY(TKBinXCAF TKBinXCAF PATHS ${CASROOT_LIBDIR})
199 +FIND_LIBRARY(TKBO TKBO PATHS ${CASROOT_LIBDIR})
200 +FIND_LIBRARY(TKBool TKBool PATHS ${CASROOT_LIBDIR})
201 +FIND_LIBRARY(TKBRep TKBRep PATHS ${CASROOT_LIBDIR})
202 +FIND_LIBRARY(TKCAF TKCAF PATHS ${CASROOT_LIBDIR})
203 +FIND_LIBRARY(TKCDF TKCDF PATHS ${CASROOT_LIBDIR})
204 +FIND_LIBRARY(TKernel TKernel PATHS ${CASROOT_LIBDIR})
205 +FIND_LIBRARY(TKFeat TKFeat PATHS ${CASROOT_LIBDIR})
206 +FIND_LIBRARY(TKFillet TKFillet PATHS ${CASROOT_LIBDIR})
207 +FIND_LIBRARY(TKG2d TKG2d PATHS ${CASROOT_LIBDIR})
208 +FIND_LIBRARY(TKG3d TKG3d PATHS ${CASROOT_LIBDIR})
209 +FIND_LIBRARY(TKGeomAlgo TKGeomAlgo PATHS ${CASROOT_LIBDIR})
210 +FIND_LIBRARY(TKGeomBase TKGeomBase PATHS ${CASROOT_LIBDIR})
211 +FIND_LIBRARY(TKHLR TKHLR PATHS ${CASROOT_LIBDIR})
212 +FIND_LIBRARY(TKIGES TKIGES PATHS ${CASROOT_LIBDIR})
213 +FIND_LIBRARY(TKLCAF TKLCAF PATHS ${CASROOT_LIBDIR})
214 +FIND_LIBRARY(TKMath TKMath PATHS ${CASROOT_LIBDIR})
215 +FIND_LIBRARY(TKMesh TKMesh PATHS ${CASROOT_LIBDIR})
216 +FIND_LIBRARY(TKMeshVS TKMeshVS PATHS ${CASROOT_LIBDIR})
217 +FIND_LIBRARY(TKNIS TKNIS PATHS ${CASROOT_LIBDIR})
218 +FIND_LIBRARY(TKOffset TKOffset PATHS ${CASROOT_LIBDIR})
219 +FIND_LIBRARY(TKOpenGl TKOpenGl PATHS ${CASROOT_LIBDIR})
220 +FIND_LIBRARY(TKPCAF TKPCAF PATHS ${CASROOT_LIBDIR})
221 +FIND_LIBRARY(TKPLCAF TKPLCAF PATHS ${CASROOT_LIBDIR})
222 +FIND_LIBRARY(TKPrim TKPrim PATHS ${CASROOT_LIBDIR})
223 +FIND_LIBRARY(TKPShape TKPShape PATHS ${CASROOT_LIBDIR})
224 +FIND_LIBRARY(TKService TKService PATHS ${CASROOT_LIBDIR})
225 +FIND_LIBRARY(TKShapeSchema TKShapeSchema PATHS ${CASROOT_LIBDIR})
226 +FIND_LIBRARY(TKShHealing TKShHealing PATHS ${CASROOT_LIBDIR})
227 +FIND_LIBRARY(TKStdLSchema TKStdLSchema PATHS ${CASROOT_LIBDIR})
228 +FIND_LIBRARY(TKStdSchema TKStdSchema PATHS ${CASROOT_LIBDIR})
229 +FIND_LIBRARY(TKSTEP TKSTEP PATHS ${CASROOT_LIBDIR})
230 +FIND_LIBRARY(TKSTEP209 TKSTEP209 PATHS ${CASROOT_LIBDIR})
231 +FIND_LIBRARY(TKSTEPAttr TKSTEPAttr PATHS ${CASROOT_LIBDIR})
232 +FIND_LIBRARY(TKSTEPBase TKSTEPBase PATHS ${CASROOT_LIBDIR})
233 +FIND_LIBRARY(TKSTL TKSTL PATHS ${CASROOT_LIBDIR})
234 +FIND_LIBRARY(TKTObj TKTObj PATHS ${CASROOT_LIBDIR})
235 +FIND_LIBRARY(TKTopAlgo TKTopAlgo PATHS ${CASROOT_LIBDIR})
236 +FIND_LIBRARY(TKV2d TKV2d PATHS ${CASROOT_LIBDIR})
237 +FIND_LIBRARY(TKV3d TKV3d PATHS ${CASROOT_LIBDIR})
238 +FIND_LIBRARY(TKVRML TKVRML PATHS ${CASROOT_LIBDIR})
239 +FIND_LIBRARY(TKXCAF TKXCAF PATHS ${CASROOT_LIBDIR})
240 +FIND_LIBRARY(TKXCAFSchema TKXCAFSchema PATHS ${CASROOT_LIBDIR})
241 +FIND_LIBRARY(TKXDEIGES TKXDEIGES PATHS ${CASROOT_LIBDIR})
242 +FIND_LIBRARY(TKXDESTEP TKXDESTEP PATHS ${CASROOT_LIBDIR})
243 +FIND_LIBRARY(TKXMesh TKXMesh PATHS ${CASROOT_LIBDIR})
244 +FIND_LIBRARY(TKXml TKXml PATHS ${CASROOT_LIBDIR})
245 +FIND_LIBRARY(TKXmlL TKXmlL PATHS ${CASROOT_LIBDIR})
246 +FIND_LIBRARY(TKXmlTObj TKXmlTObj PATHS ${CASROOT_LIBDIR})
247 +FIND_LIBRARY(TKXmlXCAF TKXmlXCAF PATHS ${CASROOT_LIBDIR})
248 +FIND_LIBRARY(TKXSBase TKXSBase PATHS ${CASROOT_LIBDIR})
249 +FIND_LIBRARY(XCAFPlugin XCAFPlugin PATHS ${CASROOT_LIBDIR})
250 +FIND_LIBRARY(XmlLPlugin XmlLPlugin PATHS ${CASROOT_LIBDIR})
251 +FIND_LIBRARY(XmlPlugin XmlPlugin PATHS ${CASROOT_LIBDIR})
252 +FIND_LIBRARY(XmlTObjPlugin XmlTObjPlugin PATHS ${CASROOT_LIBDIR})
253 +FIND_LIBRARY(XmlXCAFPlugin XmlXCAFPlugin PATHS ${CASROOT_LIBDIR})
255 +SET(CAS_KERNEL ${TKernel} ${TKMath})
256 +SET(CAS_OCAF ${TKernel} ${TKMath} ${TKCDF} ${TKLCAF})
257 +SET(CAS_VIEWER ${TKService} ${TKV3d} ${TKG3d} ${TKGeomBase} ${TKBRep})
258 +SET(CAS_OCAFVIS ${TKCAF} ${TKBRep} ${TKG2d})
259 +SET(CAS_MODELER ${TKG3d} ${TKGeomBase} ${TKGeomAlgo} ${TKBRep} ${TKTopAlgo} ${TKG2d})
261 +SET(TKV3d_EA ${TKernel} ${TKMath} ${TKV3d})
262 +SET(TKBool_EA ${TKernel} ${TKMath} ${TKBRep} ${TKG2d} ${TKG3d} ${TKGeomBase} ${TKGeomAlgo} ${TKTopAlgo} ${TKBool})
263 +SET(TKBRep_EA ${TKernel} ${TKMath} ${TKBRep})
264 +SET(TKIGES_EA ${TKernel} ${TKMath} ${TKXSBase} ${TKBRep} ${TKIGES})
265 +SET(TKSTEP_EA ${TKernel} ${TKMath} ${TKXSBase} ${TKBRep} ${TKSTEP})
266 +SET(TKSTL_EA ${TKernel} ${TKMath} ${TKSTL})
267 +SET(TKCAF_EA ${TKPrim} ${TKCAF})
269 +SET(TKV3d ${TKV3d_EA})
270 +SET(TKBool ${TKBool_EA})
271 +SET(TKBRep ${TKBRep_EA})
272 +SET(TKIGES ${TKIGES_EA})
273 +SET(TKSTEP ${TKSTEP_EA})
274 +SET(TKSTL ${TKSTL_EA})
275 +SET(TKCAF ${TKCAF_EA})
278 +SET(OCCLIBS ${CAS_LDPATH})
279 +SET(OCCLIBS ${OCCLIBS} ${TKernel} ${TKGeomBase} ${TKMath} ${TKG2d} ${TKG3d} ${TKXSBase} ${TKOffset} ${TKFillet} ${TKShHealing})
280 +SET(OCCLIBS ${OCCLIBS} ${TKMesh} ${TKMeshVS} ${TKTopAlgo} ${TKGeomAlgo} ${TKBool} ${TKPrim} ${TKBO} ${TKIGES} ${TKBRep})
281 +SET(OCCLIBS ${OCCLIBS} ${TKSTEPBase} ${TKSTEP} ${TKSTL} ${TKSTEPAttr} ${TKSTEP209} ${TKXDESTEP} ${TKXDEIGES} ${TKXCAF} ${TKLCAF})
282 \ No newline at end of file
284 +++ netgen/cmake/FindPLATFORM.cmake
286 +# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
288 +# This library is free software; you can redistribute it and/or
289 +# modify it under the terms of the GNU Lesser General Public
290 +# License as published by the Free Software Foundation; either
291 +# version 2.1 of the License.
293 +# This library is distributed in the hope that it will be useful,
294 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
295 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
296 +# Lesser General Public License for more details.
298 +# You should have received a copy of the GNU Lesser General Public
299 +# License along with this library; if not, write to the Free Software
300 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
302 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
305 +MARK_AS_ADVANCED(ISSUE)
306 +FIND_FILE(ISSUE issue /etc)
314 + SET(MACHINE WINDOWS)
316 + SET(MACHINE PCLINUX)
319 +SET(CMAKE_INSTALL_PREFIX_ENV $ENV{CMAKE_INSTALL_PREFIX})
320 +IF(CMAKE_INSTALL_PREFIX_ENV)
321 + SET(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX_ENV} CACHE PATH "installation prefix" FORCE)
322 +ENDIF(CMAKE_INSTALL_PREFIX_ENV)
324 +IF(NOT CMAKE_BUILD_TYPE)
325 + SET(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE})
326 +ENDIF(NOT CMAKE_BUILD_TYPE)
328 +IF(NOT CMAKE_BUILD_TYPE)
329 + SET(CMAKE_BUILD_TYPE Release)
330 +ENDIF(NOT CMAKE_BUILD_TYPE)
335 + SET(NAMES ACCEPT_SALOME_WARNINGS ACCEPT_${MODULE}_WARNINGS I_AM_A_TROLL_I_DO_NOT_FIX_${MODULE}_WARNINGS)
336 + FOREACH(name ${NAMES})
337 + SET(VAL $ENV{${name}})
338 + IF(X${VAL} STREQUAL X0)
340 + ENDIF(X${VAL} STREQUAL X0)
341 + IF(X${VAL} STREQUAL X1)
342 + SET(ADD_WERROR OFF)
343 + ENDIF(X${VAL} STREQUAL X1)
344 + ENDFOREACH(name ${NAMES})
346 + SET(CMAKE_C_FLAGS "-Werror")
347 + SET(CMAKE_CXX_FLAGS "-Werror")
351 +IF(CMAKE_BUILD_TYPE)
353 + MARK_AS_ADVANCED(CLEAR CMAKE_CONFIGURATION_TYPES)
354 + SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE} CACHE STRING "compilation types" FORCE)
356 + IF(CMAKE_BUILD_TYPE STREQUAL Debug)
357 + SET(CMAKE_C_FLAGS_DEBUG "-g")
358 + SET(CMAKE_CXX_FLAGS_DEBUG "-g")
359 + ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
360 + IF(CMAKE_BUILD_TYPE STREQUAL Release)
361 + SET(CMAKE_C_FLAGS_RELEASE "-O1 -DNDEBUG")
362 + SET(CMAKE_CXX_FLAGS_RELEASE "-O1 -DNDEBUG")
363 + ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
365 +ENDIF(CMAKE_BUILD_TYPE)
367 +SET(PLATFORM_CPPFLAGS)
368 +SET(PLATFORM_LDFLAGS)
369 +SET(PLATFORM_LIBADD)
371 + ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) # To disable windows warnings for strcpy, fopen, ...
372 + ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS) # To disable windows warnings std::copy, std::transform, ...
373 + ADD_DEFINITIONS(-DWNT)
374 + ADD_DEFINITIONS(-DPPRO_NT) # For medfile
375 + ADD_DEFINITIONS(-D_USE_MATH_DEFINES) # At least for MEDMEM
376 + ADD_DEFINITIONS(-D_WIN32_WINNT=0x0500) # Windows 2000 or later API is required
377 + SET(PLATFORM_LIBADD ${PLATFORM_LIBADD} Ws2_32.lib)
378 + SET(PLATFORM_LIBADD ${PLATFORM_LIBADD} Userenv.lib) # At least for GEOM suit
380 + SET(PLATFORM_LIBADD ${PLATFORM_LIBADD} -ldl)
382 \ No newline at end of file
384 +++ netgen/cmake/FindZLIB.cmake
386 +# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
388 +# This library is free software; you can redistribute it and/or
389 +# modify it under the terms of the GNU Lesser General Public
390 +# License as published by the Free Software Foundation; either
391 +# version 2.1 of the License.
393 +# This library is distributed in the hope that it will be useful,
394 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
395 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
396 +# Lesser General Public License for more details.
398 +# You should have received a copy of the GNU Lesser General Public
399 +# License along with this library; if not, write to the Free Software
400 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
402 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
407 +# Search in ZLIB_ROOT_DIR first
409 + SET(_ZLIB_SEARCH_ROOT PATHS ${ZLIB_ROOT_DIR} NO_DEFAULT_PATH)
410 + list(APPEND _ZLIB_SDIRS _ZLIB_SEARCH_ROOT)
413 +SET(ZLIB_NAMES z zlib zdll zlib1 zlibd zlibd1 zlib1d)
415 +# Try each search configuration.
416 +FOREACH(search ${_ZLIB_SDIRS})
417 + FIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h ${${search}} PATH_SUFFIXES include)
418 + FIND_LIBRARY(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} ${search} PATH_SUFFIXES lib)
421 +MARK_AS_ADVANCED(ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
424 +INCLUDE(FindPackageHandleStandardArgs)
425 +FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
428 + SET(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR})
429 + SET(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
431 --- netgen_ref/configure.ac
432 +++ netgen/configure.ac
434 CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
435 # LDFLAGS="$LDFLAGS $OPENMP_CXXFLAGS"
438 +m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
444 if test a$occon = atrue ; then
446 - AC_SUBST([OCCFLAGS], ["-DOCCGEOMETRY -I$occdir/inc -I/usr/include/opencascade"])
447 - AC_SUBST([OCCLIBS], ["-L$occdir/lib -lTKernel -lTKGeomBase -lTKMath -lTKG2d -lTKG3d -lTKXSBase -lTKOffset -lTKFillet -lTKShHealing -lTKMesh -lTKMeshVS -lTKTopAlgo -lTKGeomAlgo -lTKBool -lTKPrim -lTKBO -lTKIGES -lTKBRep -lTKSTEPBase -lTKSTEP -lTKSTL -lTKSTEPAttr -lTKSTEP209 -lTKXDESTEP -lTKXDEIGES -lTKXCAF -lTKLCAF -lFWOSPlugin"])
448 + AC_SUBST([OCCFLAGS], ["-DOCCGEOMETRY -I$occdir/include/opencascade"])
449 + AC_SUBST([OCCLIBS], ["-L$occdir/lib -lTKernel -lTKGeomBase -lTKMath -lTKG2d -lTKG3d -lTKXSBase -lTKOffset -lTKFillet -lTKShHealing -lTKMesh -lTKMeshVS -lTKTopAlgo -lTKGeomAlgo -lTKBool -lTKPrim -lTKBO -lTKIGES -lTKBRep -lTKSTEPBase -lTKSTEP -lTKSTL -lTKSTEPAttr -lTKSTEP209 -lTKXDESTEP -lTKXDEIGES -lTKXCAF -lTKLCAF"])
453 --- netgen_ref/libsrc/csg/Makefile.am
454 +++ netgen/libsrc/csg/Makefile.am
456 AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include $(TCL_INCLUDES)
459 -lib_LTLIBRARIES = libcsg.la
460 +noinst_LTLIBRARIES = libcsg.la
463 libcsg_la_SOURCES = algprim.cpp brick.cpp \
465 manifold.cpp meshsurf.cpp polyhedra.cpp revolution.cpp singularref.cpp \
466 solid.cpp specpoin.cpp spline3d.cpp surface.cpp triapprox.cpp
468 -libcsg_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la
473 -lib_LTLIBRARIES += libcsgvis.la
474 +lib_LTLIBRARIES = libcsgvis.la
476 libcsgvis_la_SOURCES = vscsg.cpp csgpkg.cpp
477 libcsgvis_la_LIBADD = libcsg.la
478 --- netgen_ref/libsrc/csg/specpoin.hpp
479 +++ netgen/libsrc/csg/specpoin.hpp
481 /* Date: 01. Okt. 95 */
482 /**************************************************************************/
484 +#include <myadt.hpp>
489 - extern DLL_HEADER MeshingParameters mparam;
490 + DLL_HEADER extern MeshingParameters mparam;
494 --- netgen_ref/libsrc/general/array.hpp
495 +++ netgen/libsrc/general/array.hpp
499 if (i-BASE < 0 || i-BASE >= size)
500 - cout << "array<" << typeid(T).name() << "> out of range, i = " << i << ", s = " << size << endl;
501 + std::cout << "array<" << typeid(T).name() << "> out of range, i = " << i << ", s = " << size << std::endl;
508 if (i < 1 || i > size)
509 - cout << "Array<" << typeid(T).name()
510 + std::cout << "Array<" << typeid(T).name()
511 << ">::Elem out of range, i = " << i
512 - << ", s = " << size << endl;
513 + << ", s = " << size << std::endl;
516 return ((T*)data)[i-1];
520 if (i < 1 || i > size)
521 - cout << "Array<" << typeid(T).name() << ">::Get out of range, i = " << i
522 - << ", s = " << size << endl;
523 + std::cout << "Array<" << typeid(T).name() << ">::Get out of range, i = " << i
524 + << ", s = " << size << std::endl;
527 return ((const T*)data)[i-1];
531 if (i < 1 || i > size)
532 - cout << "Array<" << typeid(T).name() << ">::Set out of range, i = " << i
533 - << ", s = " << size << endl;
534 + std::cout << "Array<" << typeid(T).name() << ">::Set out of range, i = " << i
535 + << ", s = " << size << std::endl;
538 ((T*)data)[i-1] = el;
540 inline ostream & operator<< (ostream & s, const FlatArray<T,BASE,TIND> & a)
542 for (TIND i = a.Begin(); i < a.End(); i++)
543 - s << i << ": " << a[i] << endl;
544 + s << i << ": " << a[i] << std::endl;
549 inline ostream & operator<< (ostream & s, const IndirectArray<T1,T2> & ia)
551 for (int i = ia.Begin(); i < ia.End(); i++)
552 - s << i << ": " << ia[i] << endl;
553 + s << i << ": " << ia[i] << std::endl;
558 void PrintMemInfo (ostream & ost) const
560 ost << Size() << " elements of size " << sizeof(T) << " = "
561 - << Size() * sizeof(T) << endl;
562 + << Size() * sizeof(T) << std::endl;
565 MoveableArray & operator= (const T & el)
567 inline ostream & operator<< (ostream & ost, MoveableArray<T> & a)
569 for (int i = 0; i < a.Size(); i++)
570 - ost << i << ": " << a[i] << endl;
571 + ost << i << ": " << a[i] << std::endl;
575 --- netgen_ref/libsrc/general/hashtabl.hpp
576 +++ netgen/libsrc/general/hashtabl.hpp
579 void PrintMemInfo (ostream & ost) const
581 - ost << "Hash: " << endl;
582 + ost << "Hash: " << std::endl;
583 hash.PrintMemInfo (ost);
584 - ost << "Cont: " << endl;
585 + ost << "Cont: " << std::endl;
586 cont.PrintMemInfo (ost);
591 void operator++ (int)
593 - // cout << "begin Operator ++: bagnr = " << bagnr << " - pos = " << pos << endl;
594 + // std::cout << "begin Operator ++: bagnr = " << bagnr << " - pos = " << pos << std::endl;
596 while (bagnr < ht.GetNBags() &&
597 pos == ht.GetBagSize(bagnr+1))
602 - // cout << "end Operator ++: bagnr = " << bagnr << " - pos = " << pos << endl;
603 + // std::cout << "end Operator ++: bagnr = " << bagnr << " - pos = " << pos << std::endl;
606 bool operator != (int i) const
608 for (typename INDEX_2_HASHTABLE<T>::Iterator it = ht.Begin();
609 it != ht.End(); it++)
611 - ost << ht.GetHash(it) << ": " << ht.GetData(it) << endl;
612 + ost << ht.GetHash(it) << ": " << ht.GetData(it) << std::endl;
618 void operator++ (int)
620 - // cout << "begin Operator ++: bagnr = " << bagnr << " - pos = " << pos << endl;
621 + // std::cout << "begin Operator ++: bagnr = " << bagnr << " - pos = " << pos << std::endl;
623 while (bagnr < ht.GetNBags() &&
624 pos == ht.GetBagSize(bagnr+1))
629 - // cout << "end Operator ++: bagnr = " << bagnr << " - pos = " << pos << endl;
630 + // std::cout << "end Operator ++: bagnr = " << bagnr << " - pos = " << pos << std::endl;
633 bool operator != (int i) const
635 for (typename INDEX_3_HASHTABLE<T>::Iterator it = ht.Begin();
636 it != ht.End(); it++)
638 - ost << ht.GetHash(it) << ": " << ht.GetData(it) << endl;
639 + ost << ht.GetHash(it) << ": " << ht.GetData(it) << std::endl;
646 ht.GetData (i, hash, data);
647 - ost << "hash = " << hash << ", data = " << data << endl;
648 + ost << "hash = " << hash << ", data = " << data << std::endl;
654 void PrintMemInfo (ostream & ost) const
656 - cout << "Hashtable: " << Size()
657 + std::cout << "Hashtable: " << Size()
658 << " entries of size " << sizeof(INDEX_3) << " + " << sizeof(T)
659 - << " = " << Size() * (sizeof(INDEX_3) + sizeof(T)) << " bytes" << endl;
660 + << " = " << Size() * (sizeof(INDEX_3) + sizeof(T)) << " bytes" << std::endl;
667 ht.GetData (i, hash, data);
668 - ost << "hash = " << hash << ", data = " << data << endl;
669 + ost << "hash = " << hash << ", data = " << data << std::endl;
673 @@ -1079,9 +1079,9 @@
675 inline void INDEX_3_HASHTABLE<T> :: PrintMemInfo (ostream & ost) const
677 - ost << "Hash: " << endl;
678 + ost << "Hash: " << std::endl;
679 hash.PrintMemInfo (ost);
680 - ost << "Cont: " << endl;
681 + ost << "Cont: " << std::endl;
682 cont.PrintMemInfo (ost);
685 @@ -1146,9 +1146,9 @@
687 inline void INDEX_HASHTABLE<T> :: PrintMemInfo (ostream & ost) const
689 - ost << "Hash: " << endl;
690 + ost << "Hash: " << std::endl;
691 hash.PrintMemInfo (ost);
692 - ost << "Cont: " << endl;
693 + ost << "Cont: " << std::endl;
694 cont.PrintMemInfo (ost);
697 @@ -1249,11 +1249,11 @@
698 inline void INDEX_2_CLOSED_HASHTABLE<T> ::
699 PrintMemInfo (ostream & ost) const
701 - cout << "Hashtable: " << Size()
702 + std::cout << "Hashtable: " << Size()
703 << " entries of size " << sizeof(INDEX_2) << " + " << sizeof(T)
704 << " = " << Size() * (sizeof(INDEX_2) + sizeof(T)) << " bytes."
705 << " Used els: " << UsedElements()
711 @@ -1356,9 +1356,9 @@
712 inline void INDEX_3_CLOSED_HASHTABLE<T> ::
713 PrintMemInfo (ostream & ost) const
715 - cout << "Hashtable: " << Size()
716 + std::cout << "Hashtable: " << Size()
717 << " entries of size " << sizeof(INDEX_3) << " + " << sizeof(T)
718 - << " = " << Size() * (sizeof(INDEX_3) + sizeof(T)) << " bytes" << endl;
719 + << " = " << Size() * (sizeof(INDEX_3) + sizeof(T)) << " bytes" << std::endl;
723 --- netgen_ref/libsrc/general/table.hpp
724 +++ netgen/libsrc/general/table.hpp
728 if (i-BASE < 0 || i-BASE >= data.Size())
729 - cout << "table out of range, i = " << i << ", s = " << data.Size() << endl;
730 + std::cout << "table out of range, i = " << i << ", s = " << data.Size() << std::endl;
733 return FlatArray<T> (data[i-BASE].size, (T*)data[i-BASE].col);
734 --- netgen_ref/libsrc/general/template.hpp
735 +++ netgen/libsrc/general/template.hpp
737 DLL_HEADER extern ostream * testout;
739 /** use instead of cout */
740 -extern ostream * mycout;
741 +DLL_HEADER extern ostream * mycout;
743 /** error output stream */
744 -extern ostream * myerr;
745 +DLL_HEADER extern ostream * myerr;
747 /** Error messages display.
748 Error messages are displayed by this function */
749 --- netgen_ref/libsrc/geom2d/Makefile.am
750 +++ netgen/libsrc/geom2d/Makefile.am
755 -lib_LTLIBRARIES = libgeom2d.la
756 +noinst_LTLIBRARIES = libgeom2d.la
759 -lib_LTLIBRARIES += libgeom2dvis.la
760 +lib_LTLIBRARIES = libgeom2dvis.la
765 libgeom2d_la_SOURCES = genmesh2d.cpp geom2dmesh.cpp geometry2d.cpp
766 -libgeom2d_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la
768 libgeom2dvis_la_SOURCES = geom2dpkg.cpp vsgeom2d.cpp
769 libgeom2dvis_la_LIBADD = libgeom2d.la
770 --- netgen_ref/libsrc/gprim/spline.hpp
771 +++ netgen/libsrc/gprim/spline.hpp
773 /// returns a (not necessarily unit-length) tangent vector for 0 <= t <= 1
774 virtual Vec<D> GetTangent (const double t) const
776 - cerr << "GetTangent not implemented for spline base-class" << endl;
777 + std::cerr << "GetTangent not implemented for spline base-class" << std::endl;
778 Vec<D> dummy; return dummy;
781 @@ -100,10 +100,10 @@
782 virtual string GetType(void) const {return "splinebase";}
784 virtual void Project (const Point<D> point, Point<D> & point_on_curve, double & t) const
785 - { cerr << "Project not implemented for spline base-class" << endl;}
786 + { std::cerr << "Project not implemented for spline base-class" << std::endl;}
788 virtual void GetRawData (Array<double> & data) const
789 - { cerr << "GetRawData not implemented for spline base-class" << endl;}
790 + { std::cerr << "GetRawData not implemented for spline base-class" << std::endl;}
798 - void SplineSeg<D> :: PrintCoeff (ostream & ost) const
799 + void SplineSeg<D> :: PrintCoeff (std::ostream & ost) const
805 for ( int i=0; i<6; i++)
812 --- netgen_ref/libsrc/include/mystdlib.h
813 +++ netgen/libsrc/include/mystdlib.h
816 # include <pthread.h>
821 # endif // MSVC_EXPRESS
822 --- netgen_ref/libsrc/interface/Makefile.am
823 +++ netgen/libsrc/interface/Makefile.am
826 AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include -I$(top_srcdir)/libsrc/interface $(MPI_INCLUDES) $(TCL_INCLUDES) -DOPENGL
828 -lib_LTLIBRARIES = libinterface.la
829 +noinst_LTLIBRARIES = libinterface.la
830 libinterface_la_SOURCES = nginterface.cpp nginterface_v2.cpp \
831 read_fnf_mesh.cpp readtetmesh.cpp readuser.cpp writeabaqus.cpp writediffpack.cpp \
832 writedolfin.cpp writeelmer.cpp writefeap.cpp writefluent.cpp writegmsh.cpp writejcm.cpp \
833 writepermas.cpp writetecplot.cpp writetet.cpp writetochnog.cpp writeuser.cpp \
834 wuchemnitz.cpp writegmsh2.cpp writeOpenFOAM15x.cpp
837 -libinterface_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la
839 # libinterface_la_LDFLAGS = -rdynamic
840 --- netgen_ref/libsrc/interface/nginterface.cpp
841 +++ netgen/libsrc/interface/nginterface.cpp
844 +#ifndef MSVC_EXPRESS
847 +#define WINVER 0x0A00
848 +#define _WIN32_WINNT 0x0A00
851 +#include <winsock2.h>
852 +#include <winsock.h>
853 +#include <windows.h>
858 #include <mystdlib.h>
860 #include <meshing.hpp>
863 #include "nginterface.h"
864 #include "../visualization/soldata.hpp"
868 // Philippose - 30/01/2009
869 --- netgen_ref/libsrc/linalg/densemat.hpp
870 +++ netgen/libsrc/linalg/densemat.hpp
873 if (prod.Size() != height)
875 - (*myerr) << "Mult: wrong vector size " << endl;
876 + (*myerr) << "Mult: wrong vector size " << std::endl;
880 - cout << "DenseMatrix::Mult height = 0" << endl;
881 + std::cout << "DenseMatrix::Mult height = 0" << std::endl;
885 - cout << "DenseMatrix::Mult width = 0" << endl;
886 + std::cout << "DenseMatrix::Mult width = 0" << std::endl;
889 if (width != v.Size())
891 - (*myerr) << "\nMatrix and Vector don't fit" << endl;
892 + (*myerr) << "\nMatrix and Vector don't fit" << std::endl;
894 else if (Height() != prod.Size())
896 - (*myerr) << "Base_Matrix::operator*(Vector): prod vector not ok" << endl;
897 + (*myerr) << "Base_Matrix::operator*(Vector): prod vector not ok" << std::endl;
903 if (prod.Size() != height)
905 - cerr << "MatrixFixWidth::Mult: wrong vector size " << endl;
906 + cerr << "MatrixFixWidth::Mult: wrong vector size " << std::endl;
912 for (int j = 0; j < m.Width(); j++)
913 ost << m.Get(i+1,j+1) << " ";
919 --- netgen_ref/libsrc/meshing/Makefile.am
920 +++ netgen/libsrc/meshing/Makefile.am
925 -lib_LTLIBRARIES = libmesh.la
926 +noinst_LTLIBRARIES = libmesh.la
928 libmesh_la_SOURCES = adfront2.cpp adfront3.cpp bisect.cpp boundarylayer.cpp \
929 clusters.cpp curvedelems.cpp delaunay.cpp delaunay2d.cpp \
931 topology.cpp triarls.cpp validate.cpp zrefine.cpp bcfunctions.cpp \
932 parallelmesh.cpp paralleltop.cpp paralleltop.hpp basegeom.cpp
934 -libmesh_la_LIBADD = $(top_builddir)/libsrc/linalg/libla.la \
935 - $(top_builddir)/libsrc/gprim/libgprim.la \
936 - $(top_builddir)/libsrc/general/libgen.la \
938 +libmesh_la_LIBADD = -lz
940 --- netgen_ref/libsrc/meshing/classifyhpel.hpp
941 +++ netgen/libsrc/meshing/classifyhpel.hpp
946 - cout << "debug" << endl;
947 - *testout << "debug" << endl;
948 - *testout << "ep = " << ep1 << ep2 << ep3 << ep4 << endl;
949 - *testout << "cp = " << cp1 << cp2 << cp3 << cp4 << endl;
950 - *testout << "edge = " << isedge1 << isedge2 << isedge3 << isedge4 << isedge5 << isedge6 << endl;
951 + std::cout << "debug" << std::endl;
952 + *testout << "debug" << std::endl;
953 + *testout << "ep = " << ep1 << ep2 << ep3 << ep4 << std::endl;
954 + *testout << "cp = " << cp1 << cp2 << cp3 << cp4 << std::endl;
955 + *testout << "edge = " << isedge1 << isedge2 << isedge3 << isedge4 << isedge5 << isedge6 << std::endl;
959 @@ -402,18 +402,18 @@
963 - if (debug) cout << "type = " << type << endl;
964 + if (debug) std::cout << "type = " << type << std::endl;
969 - (*testout) << "undefined element" << endl
970 - << "cp = " << cp1 << cp2 << cp3 << cp4 << endl
971 - << "ep = " << ep1 << ep2 << ep3 << ep4 << endl
972 + (*testout) << "undefined element" << std::endl
973 + << "cp = " << cp1 << cp2 << cp3 << cp4 << std::endl
974 + << "ep = " << ep1 << ep2 << ep3 << ep4 << std::endl
975 << "isedge = " << isedge1 << isedge2 << isedge3
976 - << isedge4 << isedge5 << isedge6 << endl
977 - << "isface = " << isface1 << isface2 << isface3 << isface4 << endl;
978 - cout << "undefined element !!! " << endl;
979 + << isedge4 << isedge5 << isedge6 << std::endl
980 + << "isface = " << isface1 << isface2 << isface3 << isface4 << std::endl;
981 + std::cout << "undefined element !!! " << std::endl;
989 - cout << " **** WARNING: Edge between to different singular faces should be marked singular " << endl;
990 + std::cout << " **** WARNING: Edge between to different singular faces should be marked singular " << std::endl;
998 - *testout << " Prism with pnums " << endl;
999 + *testout << " Prism with pnums " << std::endl;
1000 for(int j=0;j<6;j++) *testout << el.pnums[j] << "\t";
1002 + *testout << std::endl;
1007 for(int k=0;k<6;k++) el.pnums[k] = pnums[k];
1010 - /* *testout << " Classified Prism with pnums " << endl;
1011 + /* *testout << " Classified Prism with pnums " << std::endl;
1012 for(int j=0;j<6;j++) *testout << el.pnums[j] << "\t";
1014 + *testout << std::endl;
1020 bool sing_face = faces.Used (i3);
1022 - // *testout << " facepoint " << facepoint << endl;
1023 + // *testout << " facepoint " << facepoint << std::endl;
1026 // Try all rotations of the trig
1028 pnums[m] = el.PNum(p[m]); // global vertex number
1029 // *testout << pnums[m] << " \t ";
1031 - // *testout << endl ;
1032 + // *testout << std::endl ;
1037 for(int k=0;k<3;k++)
1040 - // *testout << " fp [" << k << "] = " << facepoint[pnums[k]] << endl;
1041 - // *testout << " fd.DomainIn()" << fd.DomainIn() << endl;
1042 - // *testout << " fd.DomainOut()" << fd.DomainOut() << endl;
1043 + // *testout << " fp [" << k << "] = " << facepoint[pnums[k]] << std::endl;
1044 + // *testout << " fd.DomainIn()" << fd.DomainIn() << std::endl;
1045 + // *testout << " fd.DomainOut()" << fd.DomainOut() << std::endl;
1046 if( facepoint[pnums[k]] && (facepoint[pnums[k]] ==-1 ||
1047 facepoint[pnums[k]] == fd.DomainIn() || facepoint[pnums[k]] == fd.DomainOut()))
1048 point_sing[p[k]-1] = 1;
1051 /* *testout << " pointsing NACH FACEPOints ... FALLS EDGEPOINT UMSETZEN" ;
1052 for (int k=0;k<3;k++) *testout << "\t" << point_sing[p[k]-1] ;
1053 - *testout << endl; */
1054 + *testout << std::endl; */
1057 const ELEMENT_EDGE * eledges = MeshTopology::GetEdges1(TRIG);
1058 @@ -746,13 +746,13 @@
1060 /* *testout << " pointsing NACH edges UND FACEEDGES UMSETZEN ... " ;
1061 for (int k=0;k<3;k++) *testout << "\t" << point_sing[p[k]-1] ;
1063 + *testout << std::endl;
1068 - *testout << " dim " << dim << endl;
1069 - *testout << " edgepoint_dom " << edgepoint_dom << endl;
1070 + *testout << " dim " << dim << std::endl;
1071 + *testout << " edgepoint_dom " << edgepoint_dom << std::endl;
1076 if(cornerpoint.Test(el.PNum(p[k])))
1077 point_sing[p[k]-1] = 3;
1079 - *testout << "point_sing = " << point_sing[0] << point_sing[1] << point_sing[2] << endl;
1080 + *testout << "point_sing = " << point_sing[0] << point_sing[1] << point_sing[2] << std::endl;
1082 if(edge_sing[0] + edge_sing[1] + edge_sing[2] == 0)
1084 @@ -854,21 +854,21 @@
1085 else if (edge_sing[2] && edge_sing[1] && edge_sing[0])
1086 type = HP_TRIG_3SINGEDGES;
1088 - // cout << " run for " << j << " gives type " << type << endl;
1089 - //*testout << " run for " << j << " gives type " << type << endl;
1090 + // std::cout << " run for " << j << " gives type " << type << std::endl;
1091 + //*testout << " run for " << j << " gives type " << type << std::endl;
1093 if(type!=HP_NONE) break;
1096 - *testout << "type = " << type << endl;
1097 + *testout << "type = " << type << std::endl;
1099 for(int k=0;k<3;k++) el[k] = pnums[k];
1100 /*if(type != HP_NONE)
1103 - cout << " TRIG with pnums " << pnums[0] << "\t" <<
1104 - pnums[1] << "\t" << pnums[2] << endl;
1105 - cout << " type " << type << endl;
1106 + std::cout << " TRIG with pnums " << pnums[0] << "\t" <<
1107 + pnums[1] << "\t" << pnums[2] << std::endl;
1108 + std::cout << " type " << type << std::endl;
1116 - // (*testout) << "cp = " << cp1 << cp2 << cp3 << ", ep = " << ep1 << ep2 << ep3 << endl;
1117 + // (*testout) << "cp = " << cp1 << cp2 << cp3 << ", ep = " << ep1 << ep2 << ep3 << std::endl;
1119 int p[3] = { el.PNumMod (j), el.PNumMod (j+1), el.PNumMod (j+2)};
1125 - // cout << " isedge " << isedge1 << " \t " << isedge2 << " \t " << isedge3 << endl;
1126 + // std::cout << " isedge " << isedge1 << " \t " << isedge2 << " \t " << isedge3 << std::endl;
1130 @@ -1031,11 +1031,11 @@
1134 - cout << " used " << face_edges.Used (INDEX_2::Sort (el.PNumMod(j), el.PNumMod(j+1))) << endl;
1135 + std::cout << " used " << face_edges.Used (INDEX_2::Sort (el.PNumMod(j), el.PNumMod(j+1))) << std::endl;
1137 - cout << " isedge " << isedge1 << " \t " << isedge2 << " \t " << isedge3 << endl;
1138 - cout << " ep " << ep1 << "\t" << ep2 << " \t " << ep3 << endl;
1139 - cout << " cp " << cp1 << "\t" << cp2 << " \t " << cp3 << endl;
1140 + std::cout << " isedge " << isedge1 << " \t " << isedge2 << " \t " << isedge3 << std::endl;
1141 + std::cout << " ep " << ep1 << "\t" << ep2 << " \t " << ep3 << std::endl;
1142 + std::cout << " cp " << cp1 << "\t" << cp2 << " \t " << cp3 << std::endl;
1146 @@ -1127,9 +1127,9 @@
1147 /*if(type != HP_NONE)
1150 - cout << " TRIG with pnums " << pnums[0] << "\t" <<
1151 - pnums[1] << "\t" << pnums[2] << endl;
1152 - cout << " type " << type << endl;
1153 + std::cout << " TRIG with pnums " << pnums[0] << "\t" <<
1154 + pnums[1] << "\t" << pnums[2] << std::endl;
1155 + std::cout << " type " << type << std::endl;
1159 @@ -1144,7 +1144,7 @@
1160 int ep1(-1), ep2(-1), ep3(-1), ep4(-1), cp1(-1), cp2(-1), cp3(-1), cp4(-1);
1161 int isedge1, isedge2, isedge3, isedge4;
1163 - *testout << "edges = " << edges << endl;
1164 + *testout << "edges = " << edges << std::endl;
1166 for (int j = 1; j <= 4; j++)
1168 @@ -1301,9 +1301,9 @@
1169 int sumep = ep1 + ep2 + ep3 + ep4;
1170 int sumedge = isedge1 + isedge2 + isedge3 + isedge4;
1172 - *testout << "isedge = " << isedge1 << isedge2 << isedge3 << isedge4 << endl;
1173 - *testout << "iscp = " << cp1 << cp2 << cp3 << cp4 << endl;
1174 - *testout << "isep = " << ep1 << ep2 << ep3 << ep4 << endl;
1175 + *testout << "isedge = " << isedge1 << isedge2 << isedge3 << isedge4 << std::endl;
1176 + *testout << "iscp = " << cp1 << cp2 << cp3 << cp4 << std::endl;
1177 + *testout << "isep = " << ep1 << ep2 << ep3 << ep4 << std::endl;
1181 @@ -1463,23 +1463,23 @@
1182 pnums[3] = el.PNumMod (j+3);
1183 for (int k=0;k<4;k++) el[k] = pnums[k];
1185 - /* cout << " QUAD with pnums " << pnums[0] << "\t" <<
1186 + /* std::cout << " QUAD with pnums " << pnums[0] << "\t" <<
1187 pnums[1] << "\t" << pnums[2] << "\t" << pnums[3]
1188 - << endl << " of type " << type << endl; */
1189 + << std::endl << " of type " << type << std::endl; */
1194 if (type == HP_NONE)
1196 - (*testout) << "undefined element" << endl
1197 - << "cp = " << cp1 << cp2 << cp3 << cp4 << endl
1198 - << "ep = " << ep1 << ep2 << ep3 << ep4 << endl
1199 + (*testout) << "undefined element" << std::endl
1200 + << "cp = " << cp1 << cp2 << cp3 << cp4 << std::endl
1201 + << "ep = " << ep1 << ep2 << ep3 << ep4 << std::endl
1202 << "isedge = " << isedge1 << isedge2 << isedge3
1203 - << isedge4 << endl;
1204 + << isedge4 << std::endl;
1207 - *testout << "quad type = " << type << endl;
1208 + *testout << "quad type = " << type << std::endl;
1212 @@ -1574,9 +1574,9 @@
1214 for(int l=0;l<8;l++) pnums[l] = el[p[l]-1];
1215 for(int l=0;l<8;l++) el[l] = pnums[l];
1216 - /* cout << " HEX with pnums " << pnums[0] << "\t" <<
1217 + /* std::cout << " HEX with pnums " << pnums[0] << "\t" <<
1218 pnums[1] << "\t" << pnums[2] << "\t" << pnums[3] << "\t" <<
1219 - pnums[4] << "\t" << pnums[5] << endl << " of type " << type << endl; */
1220 + pnums[4] << "\t" << pnums[5] << std::endl << " of type " << type << std::endl; */
1224 @@ -1623,7 +1623,7 @@
1226 hpel.type = HP_SEGM_SINGCORNERS;
1228 - // cout << " SEGM found with " << hpel[0] << " \t" << hpel[1] << endl << " of type " << hpel.type << endl;
1229 + // std::cout << " SEGM found with " << hpel[0] << " \t" << hpel[1] << std::endl << " of type " << hpel.type << std::endl;
1233 --- netgen_ref/libsrc/meshing/findip.hpp
1234 +++ netgen/libsrc/meshing/findip.hpp
1236 static int timer = NgProfiler::CreateTimer ("FindInnerPoint");
1237 NgProfiler::RegionTimer reg (timer);
1239 + if ( points.Size() < 3 )
1245 --- netgen_ref/libsrc/meshing/global.hpp
1246 +++ netgen/libsrc/meshing/global.hpp
1248 /* Date: 01. Okt. 95 */
1249 /**************************************************************************/
1251 +#include <myadt.hpp>
1254 global functions and variables
1258 extern Array<int> tets_in_qualclass;
1260 - class multithreadt
1261 + class DLL_HEADER multithreadt
1269 - extern volatile multithreadt multithread;
1270 + DLL_HEADER extern volatile multithreadt multithread;
1272 DLL_HEADER extern string ngdir;
1273 extern DebugParameters debugparam;
1274 --- netgen_ref/libsrc/meshing/improve3.cpp
1275 +++ netgen/libsrc/meshing/improve3.cpp
1276 @@ -1219,6 +1219,7 @@
1280 + int nbtetused = 0;
1282 for (int l = 2; l < nsuround; l++)
1284 @@ -1239,10 +1240,12 @@
1287 suroundpts[l] = newpi;
1293 + if ( nbtetused < nsuround )
1297 for (int k = 0; k < nsuround; k++)
1298 --- netgen_ref/libsrc/meshing/meshclass.hpp
1299 +++ netgen/libsrc/meshing/meshclass.hpp
1301 { return lockedpoints; }
1303 /// Returns number of domains
1304 - int GetNDomains() const;
1305 + DLL_HEADER int GetNDomains() const;
1308 int GetDimension() const
1310 { dimension = dim; }
1312 /// sets internal tables
1313 - void CalcSurfacesOfNode ();
1314 + void DLL_HEADER CalcSurfacesOfNode ();
1316 /// additional (temporarily) fix points
1317 void FixPoints (const BitArray & fixpoints);
1318 @@ -390,13 +390,13 @@
1320 DLL_HEADER void SetGlobalH (double h);
1322 - void SetMinimalH (double h);
1323 + void DLL_HEADER SetMinimalH (double h);
1325 double MaxHDomain (int dom) const;
1327 void SetMaxHDomain (const Array<double> & mhd);
1329 - double GetH (const Point3d & p) const;
1330 + double DLL_HEADER GetH (const Point3d & p) const;
1332 double GetMinH (const Point3d & pmin, const Point3d & pmax);
1334 --- netgen_ref/libsrc/meshing/meshtype.cpp
1335 +++ netgen/libsrc/meshing/meshtype.cpp
1337 #include <mystdlib.h>
1338 +#include <float.h> // to get DBL_MIN defined
1340 #include "meshing.hpp"
1344 double det = trans.Det();
1348 + if (det <= DBL_MIN) // avoid FPE
1351 err += frob * frob / det;
1354 double det = trans(0,0)*trans(1,1)-trans(1,0)*trans(0,1);
1358 + if (det <= DBL_MIN) // avoid FPE
1363 = dtrans(0,0) * trans(1,1) - trans(0,1) * dtrans(1,0)
1364 + trans(0,0) * dtrans(1,1) - dtrans(0,1) * trans(1,0);
1368 + if (det <= DBL_MIN) // avoid FPE
1375 double det = trans.Det();
1378 + if (det <= DBL_MIN) // avoid FPE
1381 err += frob * frob / det;
1382 @@ -1864,7 +1869,8 @@
1385 double noz = 1-p(2);
1386 - if (noz == 0.0) noz = 1e-10;
1387 + //if (noz == 0.0) noz = 1e-10;
1388 + if (noz <= DBL_MIN) noz = 1e-10; // avoid FPE
1390 double xi = p(0) / noz;
1391 double eta = p(1) / noz;
1392 @@ -2030,7 +2036,8 @@
1394 double det = -trans.Det();
1398 + if (det <= DBL_MIN) // avoid FPE
1401 err += frob * frob * frob / det;
1402 @@ -2102,7 +2109,8 @@
1408 + if (det <= DBL_MIN) // avoid FPE
1412 @@ -2184,7 +2192,7 @@
1417 + if (det <= DBL_MIN)
1421 --- netgen_ref/libsrc/meshing/meshtype.hpp
1422 +++ netgen/libsrc/meshing/meshtype.hpp
1427 +class Mesh; // added due to compilation errors on some platforms
1431 @@ -323,19 +324,19 @@
1436 + DLL_HEADER Element2d ();
1438 - Element2d (int anp);
1439 + DLL_HEADER Element2d (int anp);
1441 DLL_HEADER Element2d (ELEMENT_TYPE type);
1443 - Element2d (int pi1, int pi2, int pi3);
1444 + DLL_HEADER Element2d (int pi1, int pi2, int pi3);
1446 - Element2d (int pi1, int pi2, int pi3, int pi4);
1447 + DLL_HEADER Element2d (int pi1, int pi2, int pi3, int pi4);
1449 - ELEMENT_TYPE GetType () const { return typ; }
1450 + DLL_HEADER ELEMENT_TYPE GetType () const { return typ; }
1452 - void SetType (ELEMENT_TYPE atyp)
1453 + DLL_HEADER void SetType (ELEMENT_TYPE atyp)
1461 - int GetNP() const { return np; }
1462 + DLL_HEADER int GetNP() const { return np; }
1465 + DLL_HEADER int GetNV() const
1467 if (typ == TRIG || typ == TRIG6)
1472 if (typ != QUAD && typ != QUAD6 && typ != QUAD8)
1473 - PrintSysError ("element2d::GetNV not implemented for typ", typ)
1474 + PrintSysError ("element2d::GetNV not implemented for typ", typ);
1478 @@ -384,95 +385,95 @@
1482 - PointIndex & operator[] (int i) { return pnum[i]; }
1483 + DLL_HEADER PointIndex & operator[] (int i) { return pnum[i]; }
1485 - const PointIndex & operator[] (int i) const { return pnum[i]; }
1486 + DLL_HEADER const PointIndex & operator[] (int i) const { return pnum[i]; }
1488 - FlatArray<const PointIndex> PNums () const
1489 + DLL_HEADER FlatArray<const PointIndex> PNums () const
1490 { return FlatArray<const PointIndex> (np, &pnum[0]); }
1493 - PointIndex & PNum (int i) { return pnum[i-1]; }
1494 + DLL_HEADER PointIndex & PNum (int i) { return pnum[i-1]; }
1496 - const PointIndex & PNum (int i) const { return pnum[i-1]; }
1497 + DLL_HEADER const PointIndex & PNum (int i) const { return pnum[i-1]; }
1499 - PointIndex & PNumMod (int i) { return pnum[(i-1) % np]; }
1500 + DLL_HEADER PointIndex & PNumMod (int i) { return pnum[(i-1) % np]; }
1502 - const PointIndex & PNumMod (int i) const { return pnum[(i-1) % np]; }
1503 + DLL_HEADER const PointIndex & PNumMod (int i) const { return pnum[(i-1) % np]; }
1507 - PointGeomInfo & GeomInfoPi (int i) { return geominfo[i-1]; }
1508 + DLL_HEADER PointGeomInfo & GeomInfoPi (int i) { return geominfo[i-1]; }
1510 - const PointGeomInfo & GeomInfoPi (int i) const { return geominfo[i-1]; }
1511 + DLL_HEADER const PointGeomInfo & GeomInfoPi (int i) const { return geominfo[i-1]; }
1513 - PointGeomInfo & GeomInfoPiMod (int i) { return geominfo[(i-1) % np]; }
1514 + DLL_HEADER PointGeomInfo & GeomInfoPiMod (int i) { return geominfo[(i-1) % np]; }
1516 - const PointGeomInfo & GeomInfoPiMod (int i) const { return geominfo[(i-1) % np]; }
1517 + DLL_HEADER const PointGeomInfo & GeomInfoPiMod (int i) const { return geominfo[(i-1) % np]; }
1520 - void SetIndex (int si) { index = si; }
1521 + DLL_HEADER void SetIndex (int si) { index = si; }
1523 - int GetIndex () const { return index; }
1524 + DLL_HEADER int GetIndex () const { return index; }
1526 - int GetOrder () const { return orderx; }
1527 - void SetOrder (int aorder) { orderx = ordery = aorder; }
1528 + DLL_HEADER int GetOrder () const { return orderx; }
1529 + DLL_HEADER void SetOrder (int aorder) { orderx = ordery = aorder; }
1532 - void GetOrder (int & ox, int & oy) const { ox = orderx, oy =ordery;};
1533 - void GetOrder (int & ox, int & oy, int & oz) const { ox = orderx; oy = ordery; oz=0; }
1534 - void SetOrder (int ox, int oy, int /* oz */) { orderx = ox; ordery = oy;}
1535 - void SetOrder (int ox, int oy) { orderx = ox; ordery = oy;}
1536 + DLL_HEADER void GetOrder (int & ox, int & oy) const { ox = orderx, oy =ordery;};
1537 + DLL_HEADER void GetOrder (int & ox, int & oy, int & oz) const { ox = orderx; oy = ordery; oz=0; }
1538 + DLL_HEADER void SetOrder (int ox, int oy, int /* oz */) { orderx = ox; ordery = oy;}
1539 + DLL_HEADER void SetOrder (int ox, int oy) { orderx = ox; ordery = oy;}
1543 - void GetBox (const T_POINTS & points, Box3d & box) const;
1544 + DLL_HEADER void GetBox (const T_POINTS & points, Box3d & box) const;
1545 /// invert orientation
1546 - inline void Invert ();
1547 + DLL_HEADER inline void Invert ();
1550 + DLL_HEADER void Invert2 ();
1551 /// first point number is smallest
1552 - inline void NormalizeNumbering ();
1553 + DLL_HEADER inline void NormalizeNumbering ();
1555 - void NormalizeNumbering2 ();
1556 + DLL_HEADER void NormalizeNumbering2 ();
1558 - bool BadElement() const { return badel; }
1559 + DLL_HEADER bool BadElement() const { return badel; }
1561 // friend ostream & operator<<(ostream & s, const Element2d & el);
1565 /// get number of 'integration points'
1566 - int GetNIP () const;
1567 - void GetIntegrationPoint (int ip, Point2d & p, double & weight) const;
1568 + DLL_HEADER int GetNIP () const;
1569 + DLL_HEADER void GetIntegrationPoint (int ip, Point2d & p, double & weight) const;
1571 - void GetTransformation (int ip, const Array<Point2d> & points,
1572 + DLL_HEADER void GetTransformation (int ip, const Array<Point2d> & points,
1573 class DenseMatrix & trans) const;
1574 - void GetTransformation (int ip, class DenseMatrix & pmat,
1575 + DLL_HEADER void GetTransformation (int ip, class DenseMatrix & pmat,
1576 class DenseMatrix & trans) const;
1578 - void GetShape (const Point2d & p, class Vector & shape) const;
1579 - void GetShapeNew (const Point<2> & p, class FlatVector & shape) const;
1580 + DLL_HEADER void GetShape (const Point2d & p, class Vector & shape) const;
1581 + DLL_HEADER void GetShapeNew (const Point<2> & p, class FlatVector & shape) const;
1583 - void GetDShape (const Point2d & p, class DenseMatrix & dshape) const;
1584 - void GetDShapeNew (const Point<2> & p, class MatrixFixWidth<2> & dshape) const;
1585 + DLL_HEADER void GetDShape (const Point2d & p, class DenseMatrix & dshape) const;
1586 + DLL_HEADER void GetDShapeNew (const Point<2> & p, class MatrixFixWidth<2> & dshape) const;
1588 - void GetPointMatrix (const Array<Point2d> & points,
1589 + DLL_HEADER void GetPointMatrix (const Array<Point2d> & points,
1590 class DenseMatrix & pmat) const;
1592 - void ComputeIntegrationPointData () const;
1593 + DLL_HEADER void ComputeIntegrationPointData () const;
1596 - double CalcJacobianBadness (const Array<Point2d> & points) const;
1597 - double CalcJacobianBadness (const T_POINTS & points,
1598 + DLL_HEADER double CalcJacobianBadness (const Array<Point2d> & points) const;
1599 + DLL_HEADER double CalcJacobianBadness (const T_POINTS & points,
1600 const Vec<3> & n) const;
1601 - double CalcJacobianBadnessDirDeriv (const Array<Point2d> & points,
1602 + DLL_HEADER double CalcJacobianBadnessDirDeriv (const Array<Point2d> & points,
1603 int pi, Vec2d & dir, double & dd) const;
1607 - void Delete () { deleted = 1; pnum[0] = pnum[1] = pnum[2] = pnum[3] = PointIndex::BASE-1; }
1608 - bool IsDeleted () const
1609 + DLL_HEADER void Delete () { deleted = 1; pnum[0] = pnum[1] = pnum[2] = pnum[3] = PointIndex::BASE-1; }
1610 + DLL_HEADER bool IsDeleted () const
1613 if (pnum[0] < PointIndex::BASE && !deleted)
1614 @@ -483,27 +484,27 @@
1616 // Philippose - 08 August 2010
1617 // Access functions for the new property: visible
1618 - void Visible(bool vis = 1)
1619 + DLL_HEADER void Visible(bool vis = 1)
1621 - bool IsVisible () const
1622 + DLL_HEADER bool IsVisible () const
1625 - void SetRefinementFlag (bool rflag = 1)
1626 + DLL_HEADER void SetRefinementFlag (bool rflag = 1)
1627 { refflag = rflag; }
1628 - bool TestRefinementFlag () const
1629 + DLL_HEADER bool TestRefinementFlag () const
1632 - void SetStrongRefinementFlag (bool rflag = 1)
1633 + DLL_HEADER void SetStrongRefinementFlag (bool rflag = 1)
1634 { strongrefflag = rflag; }
1635 - bool TestStrongRefinementFlag () const
1636 + DLL_HEADER bool TestStrongRefinementFlag () const
1637 { return strongrefflag; }
1640 - SurfaceElementIndex NextElement() { return next; }
1641 + DLL_HEADER SurfaceElementIndex NextElement() { return next; }
1643 - bool operator==(const Element2d & el2) const;
1644 + DLL_HEADER bool operator==(const Element2d & el2) const;
1646 - int HasFace(const Element2d& el) const;
1647 + DLL_HEADER int HasFace(const Element2d& el) const;
1655 - ostream & operator<<(ostream & s, const Element2d & el);
1656 + DLL_HEADER ostream & operator<<(ostream & s, const Element2d & el);
1664 - PrintSysError ("Element3d::GetNV not implemented for typ ", typ)
1665 + PrintSysError ("Element3d::GetNV not implemented for typ ", typ);
1670 case PRISM12: return 5;
1673 - PrintSysError ("element3d::GetNFaces not implemented for typ", typ)
1674 + PrintSysError ("element3d::GetNFaces not implemented for typ", typ);
1678 --- netgen_ref/libsrc/occ/Makefile.am
1679 +++ netgen/libsrc/occ/Makefile.am
1684 -lib_LTLIBRARIES = libocc.la
1685 +noinst_LTLIBRARIES = libocc.la
1688 -lib_LTLIBRARIES += liboccvis.la
1689 +lib_LTLIBRARIES = liboccvis.la
1693 --- netgen_ref/libsrc/occ/Partition_Inter2d.cxx
1694 +++ netgen/libsrc/occ/Partition_Inter2d.cxx
1696 #include <TopOpeBRep_EdgesIntersector.hxx>
1697 #include <TopOpeBRep_Point2d.hxx>
1698 #include <TopTools_ListIteratorOfListOfShape.hxx>
1699 -#include <TopTools_ListOfShape.hxx>
1700 #include <TopTools_MapIteratorOfMapOfShape.hxx>
1701 -#include <TopTools_MapOfShape.hxx>
1702 #include <TopoDS.hxx>
1703 #include <TopoDS_Edge.hxx>
1704 #include <TopoDS_Vertex.hxx>
1705 --- netgen_ref/libsrc/occ/Partition_Inter2d.hxx
1706 +++ netgen/libsrc/occ/Partition_Inter2d.hxx
1708 #ifndef _Partition_Inter2d_HeaderFile
1709 #define _Partition_Inter2d_HeaderFile
1711 -#ifndef _Handle_BRepAlgo_AsDes_HeaderFile
1712 +#include <Standard_Version.hxx>
1714 +#if OCC_VERSION_MAJOR < 7
1715 #include <Handle_BRepAlgo_AsDes.hxx>
1717 #ifndef _Standard_Real_HeaderFile
1719 #ifndef _Standard_Boolean_HeaderFile
1720 #include <Standard_Boolean.hxx>
1723 +#include <TopTools_MapOfShape.hxx>
1724 +#include <TopTools_ListOfShape.hxx>
1726 class BRepAlgo_AsDes;
1728 -class TopTools_MapOfShape;
1729 class TopoDS_Vertex;
1730 -class TopTools_ListOfShape;
1734 --- netgen_ref/libsrc/occ/Partition_Inter3d.cxx
1735 +++ netgen/libsrc/occ/Partition_Inter3d.cxx
1737 #include <TopOpeBRepTool_BoxSort.hxx>
1738 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
1739 #include <TopTools_ListIteratorOfListOfShape.hxx>
1740 -#include <TopTools_ListOfShape.hxx>
1741 #include <TopoDS.hxx>
1742 #include <TopoDS_Compound.hxx>
1743 #include <TopoDS_Edge.hxx>
1745 Handle (Geom_Surface) S = BRep_Tool::Surface(F,L);
1747 if (S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
1748 - S = (*(Handle_Geom_RectangularTrimmedSurface*)&S)->BasisSurface();
1749 + S = Handle(Geom_RectangularTrimmedSurface)::DownCast (S)->BasisSurface();
1751 if (!S->IsUPeriodic() && !S->IsVPeriodic())
1753 --- netgen_ref/libsrc/occ/Partition_Inter3d.hxx
1754 +++ netgen/libsrc/occ/Partition_Inter3d.hxx
1756 #ifndef _Partition_Inter3d_HeaderFile
1757 #define _Partition_Inter3d_HeaderFile
1759 -#ifndef _Handle_BRepAlgo_AsDes_HeaderFile
1760 +#include <Standard_Version.hxx>
1762 +#if OCC_VERSION_MAJOR < 7
1763 #include <Handle_BRepAlgo_AsDes.hxx>
1765 #ifndef _TopTools_DataMapOfShapeListOfShape_HeaderFile
1767 #ifndef _TopTools_MapOfShape_HeaderFile
1768 #include <TopTools_MapOfShape.hxx>
1770 +#ifndef _TopTools_ListOfShape_HeaderFile
1771 +#include <TopTools_ListOfShape.hxx>
1773 #ifndef _TopTools_DataMapOfShapeShape_HeaderFile
1774 #include <TopTools_DataMapOfShapeShape.hxx>
1777 #include <Standard_Boolean.hxx>
1779 class BRepAlgo_AsDes;
1780 -class TopTools_ListOfShape;
1781 -class TopTools_DataMapOfShapeShape;
1783 -class TopTools_MapOfShape;
1785 class TopoDS_Vertex;
1788 void FacesPartition(const TopoDS_Face& F1,const TopoDS_Face& F2) ;
1789 Standard_Boolean IsDone(const TopoDS_Face& F1,const TopoDS_Face& F2) const;
1790 TopTools_MapOfShape& TouchedFaces() ;
1791 - Handle_BRepAlgo_AsDes AsDes() const;
1792 + Handle(BRepAlgo_AsDes) AsDes() const;
1793 TopTools_MapOfShape& NewEdges() ;
1794 Standard_Boolean HasSameDomainF(const TopoDS_Shape& F) const;
1795 Standard_Boolean IsSameDomainF(const TopoDS_Shape& F1,const TopoDS_Shape& F2) const;
1796 const TopTools_ListOfShape& SameDomain(const TopoDS_Face& F) const;
1797 TopoDS_Vertex ReplaceSameDomainV(const TopoDS_Vertex& V,const TopoDS_Edge& E) const;
1798 - Handle_BRepAlgo_AsDes SectionEdgesAD() const;
1799 + Handle(BRepAlgo_AsDes) SectionEdgesAD() const;
1800 Standard_Boolean IsSectionEdge(const TopoDS_Edge& E) const;
1801 Standard_Boolean HasSectionEdge(const TopoDS_Face& F) const;
1802 Standard_Boolean IsSplitOn(const TopoDS_Edge& NewE,const TopoDS_Edge& OldE,const TopoDS_Face& F) const;
1803 @@ -121,11 +123,11 @@
1807 - Handle_BRepAlgo_AsDes myAsDes;
1808 + Handle(BRepAlgo_AsDes) myAsDes;
1809 TopTools_DataMapOfShapeListOfShape myDone;
1810 TopTools_MapOfShape myTouched;
1811 TopTools_MapOfShape myNewEdges;
1812 - Handle_BRepAlgo_AsDes mySectionEdgesAD;
1813 + Handle(BRepAlgo_AsDes) mySectionEdgesAD;
1814 TopTools_DataMapOfShapeListOfShape mySameDomainFM;
1815 TopTools_DataMapOfShapeShape mySameDomainVM;
1817 --- netgen_ref/libsrc/occ/Partition_Loop.hxx
1818 +++ netgen/libsrc/occ/Partition_Loop.hxx
1823 -class TopTools_ListOfShape;
1826 #ifndef _Standard_HeaderFile
1827 #include <Standard.hxx>
1828 --- netgen_ref/libsrc/occ/Partition_Loop2d.cxx
1829 +++ netgen/libsrc/occ/Partition_Loop2d.cxx
1831 Cc->D1(uc, PC, CTg1);
1832 if (!isForward) CTg1.Reverse();
1834 - Standard_Real anglemin = 3 * PI, tolAng = 1.e-8;
1835 + Standard_Real anglemin = 3 * M_PI, tolAng = 1.e-8;
1837 // select an edge whose first derivative is most left of CTg1
1838 // ie an angle between Tg1 and CTg1 is least
1841 Standard_Real angle = Tg1.Angle(CTg1);
1843 - if (PI - Abs(angle) <= tolAng)
1844 + if (M_PI - Abs(angle) <= tolAng)
1846 // an angle is too close to PI; assure that an angle sign really
1847 // reflects an edge position: +PI - an edge is worst,
1848 --- netgen_ref/libsrc/occ/Partition_Loop2d.hxx
1849 +++ netgen/libsrc/occ/Partition_Loop2d.hxx
1854 -class TopTools_ListOfShape;
1855 class BRepAlgo_Image;
1858 --- netgen_ref/libsrc/occ/Partition_Loop3d.hxx
1859 +++ netgen/libsrc/occ/Partition_Loop3d.hxx
1861 #ifndef _TopTools_ListOfShape_HeaderFile
1862 #include <TopTools_ListOfShape.hxx>
1864 +#ifndef _TopTools_MapOfOrientedShape_HeaderFile
1865 +#include <TopTools_MapOfOrientedShape.hxx>
1867 #ifndef _TopTools_IndexedDataMapOfShapeListOfShape_HeaderFile
1868 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
1871 #include <Standard_Real.hxx>
1874 -class TopTools_ListOfShape;
1875 -class TopTools_MapOfOrientedShape;
1879 --- netgen_ref/libsrc/occ/Partition_Spliter.cxx
1880 +++ netgen/libsrc/occ/Partition_Spliter.cxx
1882 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
1883 #include <TopTools_IndexedMapOfShape.hxx>
1884 #include <TopTools_ListIteratorOfListOfShape.hxx>
1885 -#include <TopTools_ListOfShape.hxx>
1886 #include <TopTools_MapIteratorOfMapOfShape.hxx>
1887 #include <TopTools_SequenceOfShape.hxx>
1889 --- netgen_ref/libsrc/occ/Partition_Spliter.hxx
1890 +++ netgen/libsrc/occ/Partition_Spliter.hxx
1892 #ifndef _TopTools_DataMapOfShapeShape_HeaderFile
1893 #include <TopTools_DataMapOfShapeShape.hxx>
1895 -#ifndef _Handle_BRepAlgo_AsDes_HeaderFile
1896 -#include <Handle_BRepAlgo_AsDes.hxx>
1898 #ifndef _BRepAlgo_Image_HeaderFile
1899 #include <BRepAlgo_Image.hxx>
1903 class BRepAlgo_AsDes;
1905 -class TopTools_ListOfShape;
1910 TopTools_DataMapOfShapeShape myFaceShapeMap;
1911 TopTools_DataMapOfShapeShape myInternalFaces;
1912 TopTools_DataMapOfShapeShape myIntNotClFaces;
1913 - Handle_BRepAlgo_AsDes myAsDes;
1914 + Handle(BRepAlgo_AsDes) myAsDes;
1915 BRepAlgo_Image myImagesFaces;
1916 BRepAlgo_Image myImagesEdges;
1917 BRepAlgo_Image myImageShape;
1918 --- netgen_ref/libsrc/occ/occconstruction.cpp
1919 +++ netgen/libsrc/occ/occconstruction.cpp
1921 #include <BRepAlgoAPI_Common.hxx>
1922 #include <BRepAlgoAPI_Fuse.hxx>
1923 #include <BRepAlgoAPI_Section.hxx>
1924 -#include <BRepOffsetAPI_Sewing.hxx>
1925 +//#include <BRepOffsetAPI_Sewing.hxx>
1926 //#include <BRepAlgo_Sewing.hxx>
1927 #include <BRepOffsetAPI_MakeOffsetShape.hxx>
1928 #include <ShapeFix_Shape.hxx>
1929 --- netgen_ref/libsrc/occ/occgenmesh.cpp
1930 +++ netgen/libsrc/occ/occgenmesh.cpp
1931 @@ -1,1467 +1,1570 @@
1934 -#include <mystdlib.h>
1935 -#include <occgeom.hpp>
1936 -#include <meshing.hpp>
1942 -#include "occmeshsurf.hpp"
1945 -#define TCL_ERROR 1
1947 -#define DIVIDEEDGESECTIONS 1000
1948 -#define IGNORECURVELENGTH 1e-4
1949 -#define VSMALL 1e-10
1952 - bool merge_solids = 1;
1955 - // can you please explain what you intend to compute here (JS) !!!
1956 - double Line :: Dist (Line l)
1959 - Vec<3> q = l.p1-l.p0;
1962 - Point<3> p = p0 + 0.5*n;
1963 - double lambda = (p-l.p0)*n / (nq + VSMALL);
1965 - if (lambda >= 0 && lambda <= 1)
1967 - double d = (p-l.p0-lambda*q).Length();
1968 - // if (d < 1e-3) d = 1e99;
1977 - double Line :: Length ()
1979 - return (p1-p0).Length();
1984 - inline Point<3> occ2ng (const gp_Pnt & p)
1986 - return Point<3> (p.X(), p.Y(), p.Z());
1991 - double ComputeH (double kappa)
1994 - kappa *= mparam.curvaturesafety;
1996 - if (mparam.maxh * kappa < 1)
1997 - hret = mparam.maxh;
1999 - hret = 1 / (kappa + VSMALL);
2001 - if (mparam.maxh < hret)
2002 - hret = mparam.maxh;
2010 - void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2,
2011 - BRepLProp_SLProps * prop, Mesh & mesh, int depth, double h = 0)
2015 - gp_Pnt pnt0,pnt1,pnt2;
2017 - prop->SetParameters (par0.X(), par0.Y());
2018 - pnt0 = prop->Value();
2020 - prop->SetParameters (par1.X(), par1.Y());
2021 - pnt1 = prop->Value();
2023 - prop->SetParameters (par2.X(), par2.Y());
2024 - pnt2 = prop->Value();
2027 - double maxside = pnt0.Distance(pnt1);
2029 - aux = pnt1.Distance(pnt2);
2035 - aux = pnt2.Distance(pnt0);
2046 - parmid.SetX( (par0.X()+par1.X()+par2.X()) / 3 );
2047 - parmid.SetY( (par0.Y()+par1.Y()+par2.Y()) / 3 );
2051 - double curvature = 0;
2053 - prop->SetParameters (parmid.X(), parmid.Y());
2054 - if (!prop->IsCurvatureDefined())
2056 - (*testout) << "curvature not defined!" << endl;
2059 - curvature = max(fabs(prop->MinCurvature()),
2060 - fabs(prop->MaxCurvature()));
2062 - prop->SetParameters (par0.X(), par0.Y());
2063 - if (!prop->IsCurvatureDefined())
2065 - (*testout) << "curvature not defined!" << endl;
2068 - curvature = max(curvature,max(fabs(prop->MinCurvature()),
2069 - fabs(prop->MaxCurvature())));
2071 - prop->SetParameters (par1.X(), par1.Y());
2072 - if (!prop->IsCurvatureDefined())
2074 - (*testout) << "curvature not defined!" << endl;
2077 - curvature = max(curvature,max(fabs(prop->MinCurvature()),
2078 - fabs(prop->MaxCurvature())));
2080 - prop->SetParameters (par2.X(), par2.Y());
2081 - if (!prop->IsCurvatureDefined())
2083 - (*testout) << "curvature not defined!" << endl;
2086 - curvature = max(curvature,max(fabs(prop->MinCurvature()),
2087 - fabs(prop->MaxCurvature())));
2089 - //(*testout) << "curvature " << curvature << endl;
2091 - if (curvature < 1e-3)
2093 - //(*testout) << "curvature too small (" << curvature << ")!" << endl;
2095 - // return war bis 10.2.05 auskommentiert
2100 - h = ComputeH (curvature+1e-10);
2102 - if(h < 1e-4*maxside)
2106 - if (h > 30) return;
2109 - if (h < maxside && depth < 10)
2111 - //cout << "\r h " << h << flush;
2114 - //cout << "h " << h << " maxside " << maxside << " depth " << depth << endl;
2115 - //cout << "par0 " << par0.X() << " " << par0.Y()
2116 - //<< " par1 " << par1.X() << " " << par1.Y()
2117 - // << " par2 " << par2.X() << " " << par2.Y()<< endl;
2121 - pm.SetX(0.5*(par1.X()+par2.X())); pm.SetY(0.5*(par1.Y()+par2.Y()));
2122 - RestrictHTriangle(pm, par2, par0, prop, mesh, depth+1, h);
2123 - RestrictHTriangle(pm, par0, par1, prop, mesh, depth+1, h);
2127 - pm.SetX(0.5*(par0.X()+par2.X())); pm.SetY(0.5*(par0.Y()+par2.Y()));
2128 - RestrictHTriangle(pm, par1, par2, prop, mesh, depth+1, h);
2129 - RestrictHTriangle(pm, par0, par1, prop, mesh, depth+1, h);
2133 - pm.SetX(0.5*(par0.X()+par1.X())); pm.SetY(0.5*(par0.Y()+par1.Y()));
2134 - RestrictHTriangle(pm, par1, par2, prop, mesh, depth+1, h);
2135 - RestrictHTriangle(pm, par2, par0, prop, mesh, depth+1, h);
2144 - prop->SetParameters (parmid.X(), parmid.Y());
2145 - pnt = prop->Value();
2146 - p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z());
2147 - mesh.RestrictLocalH (p3d, h);
2149 - p3d = Point3d(pnt0.X(), pnt0.Y(), pnt0.Z());
2150 - mesh.RestrictLocalH (p3d, h);
2152 - p3d = Point3d(pnt1.X(), pnt1.Y(), pnt1.Z());
2153 - mesh.RestrictLocalH (p3d, h);
2155 - p3d = Point3d(pnt2.X(), pnt2.Y(), pnt2.Z());
2156 - mesh.RestrictLocalH (p3d, h);
2158 - //(*testout) << "p = " << p3d << ", h = " << h << ", maxside = " << maxside << endl;
2165 - void DivideEdge (TopoDS_Edge & edge, Array<MeshPoint> & ps,
2166 - Array<double> & params, Mesh & mesh)
2169 - double maxh = mparam.maxh;
2170 - int nsubedges = 1;
2171 - gp_Pnt pnt, oldpnt;
2172 - double svalue[DIVIDEEDGESECTIONS];
2174 - GProp_GProps system;
2175 - BRepGProp::LinearProperties(edge, system);
2176 - double L = system.Mass();
2178 - Handle(Geom_Curve) c = BRep_Tool::Curve(edge, s0, s1);
2180 - double hvalue[DIVIDEEDGESECTIONS+1];
2182 - pnt = c->Value(s0);
2184 - double olddist = 0;
2187 - int tmpVal = (int)(DIVIDEEDGESECTIONS);
2189 - for (int i = 1; i <= tmpVal; i++)
2192 - pnt = c->Value(s0+(i/double(DIVIDEEDGESECTIONS))*(s1-s0));
2193 - hvalue[i] = hvalue[i-1] +
2194 - 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
2195 - pnt.Distance(oldpnt);
2197 - //(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))
2198 - // << " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << endl;
2201 - dist = pnt.Distance(oldpnt);
2204 - // nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS]));
2205 - nsubedges = max (1, int(floor(hvalue[DIVIDEEDGESECTIONS]+0.5)));
2207 - ps.SetSize(nsubedges-1);
2208 - params.SetSize(nsubedges+1);
2214 - if (hvalue[i1]/hvalue[DIVIDEEDGESECTIONS]*nsubedges >= i)
2216 - params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
2217 - pnt = c->Value(params[i]);
2218 - ps[i-1] = MeshPoint (Point3d(pnt.X(), pnt.Y(), pnt.Z()));
2222 - if (i1 > DIVIDEEDGESECTIONS)
2225 - ps.SetSize(nsubedges-1);
2226 - params.SetSize(nsubedges+1);
2227 - cout << "divide edge: local h too small" << endl;
2229 - } while (i < nsubedges);
2232 - params[nsubedges] = s1;
2234 - if (params[nsubedges] <= params[nsubedges-1])
2236 - cout << "CORRECTED" << endl;
2237 - ps.SetSize (nsubedges-2);
2238 - params.SetSize (nsubedges);
2239 - params[nsubedges] = s1;
2246 - void OCCFindEdges (OCCGeometry & geom, Mesh & mesh)
2248 - const char * savetask = multithread.task;
2249 - multithread.task = "Edge meshing";
2251 - (*testout) << "edge meshing" << endl;
2253 - int nvertices = geom.vmap.Extent();
2254 - int nedges = geom.emap.Extent();
2256 - (*testout) << "nvertices = " << nvertices << endl;
2257 - (*testout) << "nedges = " << nedges << endl;
2259 - double eps = 1e-6 * geom.GetBoundingBox().Diam();
2261 - for (int i = 1; i <= nvertices; i++)
2263 - gp_Pnt pnt = BRep_Tool::Pnt (TopoDS::Vertex(geom.vmap(i)));
2264 - MeshPoint mp( Point<3>(pnt.X(), pnt.Y(), pnt.Z()) );
2268 - for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++)
2269 - if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
2276 - mesh.AddPoint (mp);
2279 - (*testout) << "different vertices = " << mesh.GetNP() << endl;
2282 - int first_ep = mesh.GetNP()+1;
2284 - Array<int> face2solid[2];
2285 - for (int i = 0; i<2; i++)
2287 - face2solid[i].SetSize (geom.fmap.Extent());
2288 - face2solid[i] = 0;
2292 - for (TopExp_Explorer exp0(geom.shape, TopAbs_SOLID); exp0.More(); exp0.Next())
2295 - for (TopExp_Explorer exp1(exp0.Current(), TopAbs_FACE); exp1.More(); exp1.Next())
2297 - TopoDS_Face face = TopoDS::Face(exp1.Current());
2298 - int facenr = geom.fmap.FindIndex(face);
2300 - if (face2solid[0][facenr-1] == 0)
2301 - face2solid[0][facenr-1] = solidnr;
2303 - face2solid[1][facenr-1] = solidnr;
2309 - for (int i3 = 1; i3 <= geom.fmap.Extent(); i3++)
2310 - for (TopExp_Explorer exp2(geom.fmap(i3), TopAbs_WIRE); exp2.More(); exp2.Next())
2311 - for (TopExp_Explorer exp3(exp2.Current(), TopAbs_EDGE); exp3.More(); exp3.Next())
2319 - (*testout) << "faces = " << geom.fmap.Extent() << endl;
2322 - for (int i3 = 1; i3 <= geom.fmap.Extent(); i3++)
2324 - TopoDS_Face face = TopoDS::Face(geom.fmap(i3));
2325 - facenr = geom.fmap.FindIndex (face); // sollte doch immer == i3 sein ??? JS
2327 - int solidnr0 = face2solid[0][i3-1];
2328 - int solidnr1 = face2solid[1][i3-1];
2330 - /* auskommentiert am 3.3.05 von robert
2331 - for (exp2.Init (geom.somap(solidnr0), TopAbs_FACE); exp2.More(); exp2.Next())
2333 - TopoDS_Face face2 = TopoDS::Face(exp2.Current());
2334 - if (geom.fmap.FindIndex(face2) == facenr)
2336 - // if (face.Orientation() != face2.Orientation()) swap (solidnr0, solidnr1);
2341 - mesh.AddFaceDescriptor (FaceDescriptor(facenr, solidnr0, solidnr1, 0));
2343 - // Philippose - 06/07/2009
2344 - // Add the face colour to the mesh data
2345 - Quantity_Color face_colour;
2347 - if(!(geom.face_colours.IsNull())
2348 - && (geom.face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour)))
2350 - mesh.GetFaceDescriptor(facenr).SetSurfColour(Vec3d(face_colour.Red(),face_colour.Green(),face_colour.Blue()));
2354 - mesh.GetFaceDescriptor(facenr).SetSurfColour(Vec3d(0.0,1.0,0.0));
2356 - // ACHTUNG! STIMMT NICHT ALLGEMEIN (RG)
2359 - Handle(Geom_Surface) occface = BRep_Tool::Surface(face);
2361 - for (TopExp_Explorer exp2 (face, TopAbs_WIRE); exp2.More(); exp2.Next())
2363 - TopoDS_Shape wire = exp2.Current();
2365 - for (TopExp_Explorer exp3 (wire, TopAbs_EDGE); exp3.More(); exp3.Next())
2368 - (*testout) << "edge nr " << curr << endl;
2370 - multithread.percent = 100 * curr / double (total);
2371 - if (multithread.terminate) return;
2373 - TopoDS_Edge edge = TopoDS::Edge (exp3.Current());
2374 - if (BRep_Tool::Degenerated(edge))
2376 - //(*testout) << "ignoring degenerated edge" << endl;
2380 - if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) ==
2381 - geom.vmap.FindIndex(TopExp::LastVertex (edge)))
2383 - GProp_GProps system;
2384 - BRepGProp::LinearProperties(edge, system);
2386 - if (system.Mass() < eps)
2388 - cout << "ignoring edge " << geom.emap.FindIndex (edge)
2389 - << ". closed edge with length < " << eps << endl;
2395 - Handle(Geom2d_Curve) cof;
2397 - cof = BRep_Tool::CurveOnSurface (edge, face, s0, s1);
2399 - int geomedgenr = geom.emap.FindIndex(edge);
2401 - Array <MeshPoint> mp;
2402 - Array <double> params;
2404 - DivideEdge (edge, mp, params, mesh);
2406 - Array <int> pnums;
2407 - pnums.SetSize (mp.Size()+2);
2409 - if (!merge_solids)
2411 - pnums[0] = geom.vmap.FindIndex (TopExp::FirstVertex (edge));
2412 - pnums[pnums.Size()-1] = geom.vmap.FindIndex (TopExp::LastVertex (edge));
2416 - Point<3> fp = occ2ng (BRep_Tool::Pnt (TopExp::FirstVertex (edge)));
2417 - Point<3> lp = occ2ng (BRep_Tool::Pnt (TopExp::LastVertex (edge)));
2420 - pnums.Last() = -1;
2421 - for (PointIndex pi = 1; pi < first_ep; pi++)
2423 - if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi;
2424 - if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi;
2429 - for (int i = 1; i <= mp.Size(); i++)
2433 - for (j = first_ep; j <= mesh.GetNP(); j++)
2434 - if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps)
2444 - mesh.AddPoint (mp[i-1]);
2445 - (*testout) << "add meshpoint " << mp[i-1] << endl;
2446 - pnums[i] = mesh.GetNP();
2449 - (*testout) << "NP = " << mesh.GetNP() << endl;
2451 - //(*testout) << pnums[pnums.Size()-1] << endl;
2453 - for (int i = 1; i <= mp.Size()+1; i++)
2458 - seg[0] = pnums[i-1];
2459 - seg[1] = pnums[i];
2460 - seg.edgenr = edgenr;
2462 - seg.epgeominfo[0].dist = params[i-1];
2463 - seg.epgeominfo[1].dist = params[i];
2464 - seg.epgeominfo[0].edgenr = geomedgenr;
2465 - seg.epgeominfo[1].edgenr = geomedgenr;
2468 - p2d = cof->Value(params[i-1]);
2469 - // if (i == 1) p2d = cof->Value(s0);
2470 - seg.epgeominfo[0].u = p2d.X();
2471 - seg.epgeominfo[0].v = p2d.Y();
2472 - p2d = cof->Value(params[i]);
2473 - // if (i == mp.Size()+1) p2d = cof -> Value(s1);
2474 - seg.epgeominfo[1].u = p2d.X();
2475 - seg.epgeominfo[1].v = p2d.Y();
2478 - if (occface->IsUPeriodic())
2480 - cout << "U Periodic" << endl;
2481 - if (fabs(seg.epgeominfo[1].u-seg.epgeominfo[0].u) >
2482 - fabs(seg.epgeominfo[1].u-
2483 - (seg.epgeominfo[0].u-occface->UPeriod())))
2484 - seg.epgeominfo[0].u = p2d.X()+occface->UPeriod();
2486 - if (fabs(seg.epgeominfo[1].u-seg.epgeominfo[0].u) >
2487 - fabs(seg.epgeominfo[1].u-
2488 - (seg.epgeominfo[0].u+occface->UPeriod())))
2489 - seg.epgeominfo[0].u = p2d.X()-occface->UPeriod();
2492 - if (occface->IsVPeriodic())
2494 - cout << "V Periodic" << endl;
2495 - if (fabs(seg.epgeominfo[1].v-seg.epgeominfo[0].v) >
2496 - fabs(seg.epgeominfo[1].v-
2497 - (seg.epgeominfo[0].v-occface->VPeriod())))
2498 - seg.epgeominfo[0].v = p2d.Y()+occface->VPeriod();
2500 - if (fabs(seg.epgeominfo[1].v-seg.epgeominfo[0].v) >
2501 - fabs(seg.epgeominfo[1].v-
2502 - (seg.epgeominfo[0].v+occface->VPeriod())))
2503 - seg.epgeominfo[0].v = p2d.Y()-occface->VPeriod();
2507 - if (edge.Orientation() == TopAbs_REVERSED)
2509 - swap (seg[0], seg[1]);
2510 - swap (seg.epgeominfo[0].dist, seg.epgeominfo[1].dist);
2511 - swap (seg.epgeominfo[0].u, seg.epgeominfo[1].u);
2512 - swap (seg.epgeominfo[0].v, seg.epgeominfo[1].v);
2515 - mesh.AddSegment (seg);
2517 - //edgesegments[geomedgenr-1]->Append(mesh.GetNSeg());
2524 - // for(i=1; i<=mesh.GetNSeg(); i++)
2525 - // (*testout) << "edge " << mesh.LineSegment(i).edgenr << " face " << mesh.LineSegment(i).si
2526 - // << " p1 " << mesh.LineSegment(i)[0] << " p2 " << mesh.LineSegment(i)[1] << endl;
2529 - mesh.CalcSurfacesOfNode();
2530 - multithread.task = savetask;
2536 - void OCCMeshSurface (OCCGeometry & geom, Mesh & mesh, int perfstepsend)
2541 - const char * savetask = multithread.task;
2542 - multithread.task = "Surface meshing";
2544 - geom.facemeshstatus = 0;
2546 - int noldp = mesh.GetNP();
2548 - double starttime = GetTime();
2550 - Array<int> glob2loc(noldp);
2552 - //int projecttype = PARAMETERSPACE;
2554 - int projecttype = PARAMETERSPACE;
2558 - int surfmesherror = 0;
2560 - for (k = 1; k <= mesh.GetNFD(); k++)
2562 - if(1==0 && !geom.fvispar[k-1].IsDrawable())
2564 - (*testout) << "ignoring face " << k << endl;
2565 - cout << "ignoring face " << k << endl;
2569 - (*testout) << "mesh face " << k << endl;
2570 - multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
2571 - geom.facemeshstatus[k-1] = -1;
2577 - cout << "skipped" << endl;
2583 - FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
2585 - int oldnf = mesh.GetNSE();
2587 - Box<3> bb = geom.GetBoundingBox();
2589 - // int projecttype = PLANESPACE;
2591 - Meshing2OCCSurfaces meshing(TopoDS::Face(geom.fmap(k)), bb, projecttype);
2593 - if (meshing.GetProjectionType() == PLANESPACE)
2594 - PrintMessage (2, "Face ", k, " / ", mesh.GetNFD(), " (plane space projection)");
2596 - PrintMessage (2, "Face ", k, " / ", mesh.GetNFD(), " (parameter space projection)");
2598 - if (surfmesherror)
2599 - cout << "Surface meshing error occured before (in " << surfmesherror << " faces)" << endl;
2601 - // Meshing2OCCSurfaces meshing(f2, bb);
2602 - meshing.SetStartTime (starttime);
2604 - //(*testout) << "Face " << k << endl << endl;
2607 - if (meshing.GetProjectionType() == PLANESPACE)
2611 - for (i = 1; i <= mesh.GetNSeg(); i++)
2613 - Segment & seg = mesh.LineSegment(i);
2616 - for (j = 1; j <= 2; j++)
2618 - int pi = (j == 1) ? seg[0] : seg[1];
2619 - if (!glob2loc.Get(pi))
2621 - meshing.AddPoint (mesh.Point(pi), pi);
2623 - glob2loc.Elem(pi) = cntp;
2629 - for (i = 1; i <= mesh.GetNSeg(); i++)
2631 - Segment & seg = mesh.LineSegment(i);
2634 - PointGeomInfo gi0, gi1;
2635 - gi0.trignum = gi1.trignum = k;
2636 - gi0.u = seg.epgeominfo[0].u;
2637 - gi0.v = seg.epgeominfo[0].v;
2638 - gi1.u = seg.epgeominfo[1].u;
2639 - gi1.v = seg.epgeominfo[1].v;
2641 - meshing.AddBoundaryElement (glob2loc.Get(seg[0]), glob2loc.Get(seg[1]), gi0, gi1);
2642 - //(*testout) << gi0.u << " " << gi0.v << endl;
2643 - //(*testout) << gi1.u << " " << gi1.v << endl;
2651 - for (i = 1; i <= mesh.GetNSeg(); i++)
2652 - if (mesh.LineSegment(i).si == k)
2656 - Array< PointGeomInfo > gis;
2658 - gis.SetAllocSize (cntp);
2661 - for (i = 1; i <= mesh.GetNSeg(); i++)
2663 - Segment & seg = mesh.LineSegment(i);
2666 - PointGeomInfo gi0, gi1;
2667 - gi0.trignum = gi1.trignum = k;
2668 - gi0.u = seg.epgeominfo[0].u;
2669 - gi0.v = seg.epgeominfo[0].v;
2670 - gi1.u = seg.epgeominfo[1].u;
2671 - gi1.v = seg.epgeominfo[1].v;
2673 - int locpnum[2] = {0, 0};
2675 - for (j = 0; j < 2; j++)
2677 - PointGeomInfo gi = (j == 0) ? gi0 : gi1;
2680 - for (l = 0; l < gis.Size() && locpnum[j] == 0; l++)
2682 - double dist = sqr (gis[l].u-gi.u)+sqr(gis[l].v-gi.v);
2688 - if (locpnum[j] == 0)
2690 - int pi = (j == 0) ? seg[0] : seg[1];
2691 - meshing.AddPoint (mesh.Point(pi), pi);
2693 - gis.SetSize (gis.Size()+1);
2699 - meshing.AddBoundaryElement (locpnum[0], locpnum[1], gi0, gi1);
2700 - //(*testout) << gi0.u << " " << gi0.v << endl;
2701 - //(*testout) << gi1.u << " " << gi1.v << endl;
2711 - // Philippose - 15/01/2009
2712 - double maxh = geom.face_maxh[k-1];
2713 - //double maxh = mparam.maxh;
2714 - mparam.checkoverlap = 0;
2715 - // int noldpoints = mesh->GetNP();
2716 - int noldsurfel = mesh.GetNSE();
2718 - GProp_GProps sprops;
2719 - BRepGProp::SurfaceProperties(TopoDS::Face(geom.fmap(k)),sprops);
2720 - meshing.SetMaxArea(2.*sprops.Mass());
2722 - MESHING2_RESULT res;
2725 - res = meshing.GenerateMesh (mesh, mparam, maxh, k);
2728 - catch (SingularMatrixException)
2730 - (*myerr) << "Singular Matrix" << endl;
2731 - res = MESHING2_GIVEUP;
2734 - catch (UVBoundsException)
2736 - (*myerr) << "UV bounds exceeded" << endl;
2737 - res = MESHING2_GIVEUP;
2740 - projecttype = PARAMETERSPACE;
2742 - if (res != MESHING2_OK)
2746 - for (int i = noldsurfel+1; i <= mesh.GetNSE(); i++)
2747 - mesh.DeleteSurfaceElement (i);
2751 - cout << "retry Surface " << k << endl;
2760 - geom.facemeshstatus[k-1] = -1;
2761 - PrintError ("Problem in Surface mesh generation");
2763 - // throw NgException ("Problem in Surface mesh generation");
2768 - geom.facemeshstatus[k-1] = 1;
2773 - for (i = oldnf+1; i <= mesh.GetNSE(); i++)
2774 - mesh.SurfaceElement(i).SetIndex (k);
2778 -// ofstream problemfile("occmesh.rep");
2780 -// problemfile << "SURFACEMESHING" << endl << endl;
2782 - if (surfmesherror)
2784 - cout << "WARNING! NOT ALL FACES HAVE BEEN MESHED" << endl;
2785 - cout << "SURFACE MESHING ERROR OCCURED IN " << surfmesherror << " FACES:" << endl;
2786 - for (int i = 1; i <= geom.fmap.Extent(); i++)
2787 - if (geom.facemeshstatus[i-1] == -1)
2789 - cout << "Face " << i << endl;
2790 -// problemfile << "problem with face " << i << endl;
2791 -// problemfile << "vertices: " << endl;
2792 - TopExp_Explorer exp0,exp1,exp2;
2793 - for ( exp0.Init(TopoDS::Face (geom.fmap(i)), TopAbs_WIRE); exp0.More(); exp0.Next() )
2795 - TopoDS_Wire wire = TopoDS::Wire(exp0.Current());
2796 - for ( exp1.Init(wire,TopAbs_EDGE); exp1.More(); exp1.Next() )
2798 - TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
2799 - for ( exp2.Init(edge,TopAbs_VERTEX); exp2.More(); exp2.Next() )
2801 - TopoDS_Vertex vertex = TopoDS::Vertex(exp2.Current());
2802 - gp_Pnt point = BRep_Tool::Pnt(vertex);
2803 -// problemfile << point.X() << " " << point.Y() << " " << point.Z() << endl;
2807 -// problemfile << endl;
2810 - cout << endl << endl;
2811 - cout << "for more information open IGES/STEP Topology Explorer" << endl;
2812 -// problemfile.close();
2813 - throw NgException ("Problem in Surface mesh generation");
2817 -// problemfile << "OK" << endl << endl;
2818 -// problemfile.close();
2824 - if (multithread.terminate || perfstepsend < MESHCONST_OPTSURFACE)
2827 - multithread.task = "Optimizing surface";
2829 - static int timer_opt2d = NgProfiler::CreateTimer ("Optimization 2D");
2830 - NgProfiler::StartTimer (timer_opt2d);
2832 - for (k = 1; k <= mesh.GetNFD(); k++)
2834 - // if (k != 42) continue;
2835 - // if (k != 36) continue;
2837 - // (*testout) << "optimize face " << k << endl;
2838 - multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
2840 - FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
2842 - PrintMessage (1, "Optimize Surface ", k);
2843 - for (i = 1; i <= mparam.optsteps2d; i++)
2845 - // (*testout) << "optstep " << i << endl;
2846 - if (multithread.terminate) return;
2849 - MeshOptimize2dOCCSurfaces meshopt(geom);
2850 - meshopt.SetFaceIndex (k);
2851 - meshopt.SetImproveEdges (0);
2852 - meshopt.SetMetricWeight (mparam.elsizeweight);
2853 - //meshopt.SetMetricWeight (0.2);
2854 - meshopt.SetWriteStatus (0);
2856 - // (*testout) << "EdgeSwapping (mesh, (i > mparam.optsteps2d/2))" << endl;
2857 - meshopt.EdgeSwapping (mesh, (i > mparam.optsteps2d/2));
2860 - if (multithread.terminate) return;
2862 - MeshOptimize2dOCCSurfaces meshopt(geom);
2863 - meshopt.SetFaceIndex (k);
2864 - meshopt.SetImproveEdges (0);
2865 - //meshopt.SetMetricWeight (0.2);
2866 - meshopt.SetMetricWeight (mparam.elsizeweight);
2867 - meshopt.SetWriteStatus (0);
2869 - // (*testout) << "ImproveMesh (mesh)" << endl;
2870 - meshopt.ImproveMesh (mesh, mparam);
2874 - MeshOptimize2dOCCSurfaces meshopt(geom);
2875 - meshopt.SetFaceIndex (k);
2876 - meshopt.SetImproveEdges (0);
2877 - //meshopt.SetMetricWeight (0.2);
2878 - meshopt.SetMetricWeight (mparam.elsizeweight);
2879 - meshopt.SetWriteStatus (0);
2881 - // (*testout) << "CombineImprove (mesh)" << endl;
2882 - meshopt.CombineImprove (mesh);
2885 - if (multithread.terminate) return;
2887 - MeshOptimize2dOCCSurfaces meshopt(geom);
2888 - meshopt.SetFaceIndex (k);
2889 - meshopt.SetImproveEdges (0);
2890 - //meshopt.SetMetricWeight (0.2);
2891 - meshopt.SetMetricWeight (mparam.elsizeweight);
2892 - meshopt.SetWriteStatus (0);
2894 - // (*testout) << "ImproveMesh (mesh)" << endl;
2895 - meshopt.ImproveMesh (mesh, mparam);
2902 - mesh.CalcSurfacesOfNode();
2905 - NgProfiler::StopTimer (timer_opt2d);
2907 - multithread.task = savetask;
2912 - void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh)
2914 - mesh.SetGlobalH (mparam.maxh);
2915 - mesh.SetMinimalH (mparam.minh);
2917 - Array<double> maxhdom;
2918 - maxhdom.SetSize (geom.NrSolids());
2919 - maxhdom = mparam.maxh;
2921 - mesh.SetMaxHDomain (maxhdom);
2923 - Box<3> bb = geom.GetBoundingBox();
2924 - bb.Increase (bb.Diam()/10);
2926 - mesh.SetLocalH (bb.PMin(), bb.PMax(), 0.5);
2928 - if (mparam.uselocalh)
2930 - const char * savetask = multithread.task;
2931 - multithread.percent = 0;
2933 - mesh.SetLocalH (bb.PMin(), bb.PMax(), mparam.grading);
2935 - int nedges = geom.emap.Extent();
2937 - double mincurvelength = IGNORECURVELENGTH;
2938 - double maxedgelen = 0;
2939 - double minedgelen = 1e99;
2941 - if(occparam.resthminedgelenenable)
2943 - mincurvelength = occparam.resthminedgelen;
2944 - if(mincurvelength < IGNORECURVELENGTH) mincurvelength = IGNORECURVELENGTH;
2947 - multithread.task = "Setting local mesh size (elements per edge)";
2949 - // setting elements per edge
2951 - for (int i = 1; i <= nedges && !multithread.terminate; i++)
2953 - TopoDS_Edge e = TopoDS::Edge (geom.emap(i));
2954 - multithread.percent = 100 * (i-1)/double(nedges);
2955 - if (BRep_Tool::Degenerated(e)) continue;
2957 - GProp_GProps system;
2958 - BRepGProp::LinearProperties(e, system);
2959 - double len = system.Mass();
2961 - if (len < mincurvelength)
2963 - (*testout) << "ignored" << endl;
2967 - double localh = len/mparam.segmentsperedge;
2970 - // Philippose - 23/01/2009
2971 - // Find all the parent faces of a given edge
2972 - // and limit the mesh size of the edge based on the
2973 - // mesh size limit of the face
2974 - TopTools_IndexedDataMapOfShapeListOfShape edge_face_map;
2975 - edge_face_map.Clear();
2977 - TopExp::MapShapesAndAncestors(geom.shape, TopAbs_EDGE, TopAbs_FACE, edge_face_map);
2978 - const TopTools_ListOfShape& parent_faces = edge_face_map.FindFromKey(e);
2980 - TopTools_ListIteratorOfListOfShape parent_face_list;
2982 - for(parent_face_list.Initialize(parent_faces); parent_face_list.More(); parent_face_list.Next())
2984 - TopoDS_Face parent_face = TopoDS::Face(parent_face_list.Value());
2986 - int face_index = geom.fmap.FindIndex(parent_face);
2988 - if(face_index >= 1) localh = min(localh,geom.face_maxh[face_index - 1]);
2991 - Handle(Geom_Curve) c = BRep_Tool::Curve(e, s0, s1);
2993 - maxedgelen = max (maxedgelen, len);
2994 - minedgelen = min (minedgelen, len);
2996 - // Philippose - 23/01/2009
2997 - // Modified the calculation of maxj, because the
2998 - // method used so far always results in maxj = 2,
2999 - // which causes the localh to be set only at the
3000 - // starting, mid and end of the edge.
3002 - // int maxj = 2 * (int) ceil (localh/len);
3003 - int maxj = max((int) ceil(len/localh), 2);
3005 - for (int j = 0; j <= maxj; j++)
3007 - gp_Pnt pnt = c->Value (s0+double(j)/maxj*(s1-s0));
3008 - mesh.RestrictLocalH (Point3d(pnt.X(), pnt.Y(), pnt.Z()), localh);
3012 - multithread.task = "Setting local mesh size (edge curvature)";
3014 - // setting edge curvature
3016 - int nsections = 20;
3018 - for (int i = 1; i <= nedges && !multithread.terminate; i++)
3020 - double maxcur = 0;
3021 - multithread.percent = 100 * (i-1)/double(nedges);
3022 - TopoDS_Edge edge = TopoDS::Edge (geom.emap(i));
3023 - if (BRep_Tool::Degenerated(edge)) continue;
3025 - Handle(Geom_Curve) c = BRep_Tool::Curve(edge, s0, s1);
3026 - BRepAdaptor_Curve brepc(edge);
3027 - BRepLProp_CLProps prop(brepc, 2, 1e-5);
3029 - for (int j = 1; j <= nsections; j++)
3031 - double s = s0 + j/(double) nsections * (s1-s0);
3032 - prop.SetParameter (s);
3033 - double curvature = prop.Curvature();
3034 - if(curvature> maxcur) maxcur = curvature;
3036 - if (curvature >= 1e99)
3039 - gp_Pnt pnt = c->Value (s);
3041 - mesh.RestrictLocalH (Point3d(pnt.X(), pnt.Y(), pnt.Z()), ComputeH (fabs(curvature)));
3043 - // (*testout) << "edge " << i << " max. curvature: " << maxcur << endl;
3046 - multithread.task = "Setting local mesh size (face curvature)";
3048 - // setting face curvature
3050 - int nfaces = geom.fmap.Extent();
3052 - for (int i = 1; i <= nfaces && !multithread.terminate; i++)
3054 - multithread.percent = 100 * (i-1)/double(nfaces);
3055 - TopoDS_Face face = TopoDS::Face(geom.fmap(i));
3056 - TopLoc_Location loc;
3057 - Handle(Geom_Surface) surf = BRep_Tool::Surface (face);
3058 - Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation (face, loc);
3060 - if (triangulation.IsNull()) continue;
3062 - BRepAdaptor_Surface sf(face, Standard_True);
3063 - BRepLProp_SLProps prop(sf, 2, 1e-5);
3065 - int ntriangles = triangulation -> NbTriangles();
3066 - for (int j = 1; j <= ntriangles; j++)
3071 - for (int k = 1; k <=3; k++)
3073 - int n = triangulation->Triangles()(j)(k);
3074 - p[k-1] = triangulation->Nodes()(n).Transformed(loc);
3075 - par[k-1] = triangulation->UVNodes()(n);
3078 - //double maxside = 0;
3079 - //maxside = max (maxside, p[0].Distance(p[1]));
3080 - //maxside = max (maxside, p[0].Distance(p[2]));
3081 - //maxside = max (maxside, p[1].Distance(p[2]));
3082 - //cout << "\rFace " << i << " pos11 ntriangles " << ntriangles << " maxside " << maxside << flush;
3084 - RestrictHTriangle (par[0], par[1], par[2], &prop, mesh, 0);
3085 - //cout << "\rFace " << i << " pos12 ntriangles " << ntriangles << flush;
3089 - // setting close edges
3091 - if (occparam.resthcloseedgeenable)
3093 - multithread.task = "Setting local mesh size (close edges)";
3095 - int sections = 100;
3097 - Array<Line> lines(sections*nedges);
3099 - Box3dTree* searchtree =
3100 - new Box3dTree (bb.PMin(), bb.PMax());
3103 - for (int i = 1; i <= nedges && !multithread.terminate; i++)
3105 - TopoDS_Edge edge = TopoDS::Edge (geom.emap(i));
3106 - if (BRep_Tool::Degenerated(edge)) continue;
3109 - Handle(Geom_Curve) c = BRep_Tool::Curve(edge, s0, s1);
3110 - BRepAdaptor_Curve brepc(edge);
3111 - BRepLProp_CLProps prop(brepc, 1, 1e-5);
3112 - prop.SetParameter (s0);
3114 - gp_Vec d0 = prop.D1().Normalized();
3115 - double s_start = s0;
3117 - for (int j = 1; j <= sections; j++)
3119 - double s = s0 + (s1-s0)*(double)j/(double)sections;
3120 - prop.SetParameter (s);
3121 - gp_Vec d1 = prop.D1().Normalized();
3122 - double cosalpha = fabs(d0*d1);
3123 - if ((j == sections) || (cosalpha < cos(10.0/180.0*M_PI)))
3126 - gp_Pnt p0 = c->Value (s_start);
3127 - gp_Pnt p1 = c->Value (s);
3128 - lines[nlines].p0 = Point<3> (p0.X(), p0.Y(), p0.Z());
3129 - lines[nlines].p1 = Point<3> (p1.X(), p1.Y(), p1.Z());
3132 - box.SetPoint (Point3d(lines[nlines].p0));
3133 - box.AddPoint (Point3d(lines[nlines].p1));
3135 - searchtree->Insert (box.PMin(), box.PMax(), nlines+1);
3144 - Array<int> linenums;
3146 - for (int i = 0; i < nlines; i++)
3148 - multithread.percent = (100*i)/double(nlines);
3149 - Line & line = lines[i];
3152 - box.SetPoint (Point3d(line.p0));
3153 - box.AddPoint (Point3d(line.p1));
3154 - double maxhline = max (mesh.GetH(box.PMin()),
3155 - mesh.GetH(box.PMax()));
3156 - box.Increase(maxhline);
3158 - double mindist = 1e99;
3159 - linenums.SetSize(0);
3160 - searchtree->GetIntersecting(box.PMin(),box.PMax(),linenums);
3162 - for (int j = 0; j < linenums.Size(); j++)
3164 - int num = linenums[j]-1;
3165 - if (i == num) continue;
3166 - if ((line.p0-lines[num].p0).Length2() < 1e-15) continue;
3167 - if ((line.p0-lines[num].p1).Length2() < 1e-15) continue;
3168 - if ((line.p1-lines[num].p0).Length2() < 1e-15) continue;
3169 - if ((line.p1-lines[num].p1).Length2() < 1e-15) continue;
3170 - mindist = min (mindist, line.Dist(lines[num]));
3173 - mindist /= (occparam.resthcloseedgefac + VSMALL);
3175 - if (mindist < 1e-3)
3177 - (*testout) << "extremely small local h: " << mindist
3178 - << " --> setting to 1e-3" << endl;
3179 - (*testout) << "somewhere near " << line.p0 << " - " << line.p1 << endl;
3183 - mesh.RestrictLocalHLine(line.p0, line.p1, mindist);
3187 - multithread.task = savetask;
3191 - // Philippose - 09/03/2009
3192 - // Added the capability to load the mesh size from a
3193 - // file also for OpenCascade Geometry
3195 - // ** If the "uselocalh" option is ticked in
3196 - // the "mesh options...insider" menu, the mesh
3197 - // size will be further modified by the topology
3198 - // analysis routines.
3199 - // ** To use the mesh size file as the sole source
3200 - // for defining the mesh size, uncheck the "uselocalh"
3202 - mesh.LoadLocalMeshSize (mparam.meshsizefilename);
3207 - int OCCGenerateMesh (OCCGeometry & geom, Mesh *& mesh, MeshingParameters & mparam,
3208 - int perfstepsstart, int perfstepsend)
3210 - multithread.percent = 0;
3212 - if (perfstepsstart <= MESHCONST_ANALYSE)
3215 - mesh = new Mesh();
3216 - mesh->geomtype = Mesh::GEOM_OCC;
3218 - OCCSetLocalMeshSize(geom,*mesh);
3221 - if (multithread.terminate || perfstepsend <= MESHCONST_ANALYSE)
3224 - if (perfstepsstart <= MESHCONST_MESHEDGES)
3226 - OCCFindEdges (geom, *mesh);
3229 - cout << "Removing redundant points" << endl;
3232 - int np = mesh->GetNP();
3233 - Array<int> equalto;
3235 - equalto.SetSize (np);
3238 - for (i = 1; i <= np; i++)
3240 - for (j = i+1; j <= np; j++)
3242 - if (!equalto[j-1] && (Dist2 (mesh->Point(i), mesh->Point(j)) < 1e-12))
3247 - for (i = 1; i <= np; i++)
3250 - cout << "Point " << i << " is equal to Point " << equalto[i-1] << endl;
3251 - for (j = 1; j <= mesh->GetNSeg(); j++)
3253 - Segment & seg = mesh->LineSegment(j);
3254 - if (seg[0] == i) seg[0] = equalto[i-1];
3255 - if (seg[1] == i) seg[1] = equalto[i-1];
3259 - cout << "Removing degenerated segments" << endl;
3260 - for (j = 1; j <= mesh->GetNSeg(); j++)
3262 - Segment & seg = mesh->LineSegment(j);
3263 - if (seg[0] == seg[1])
3265 - mesh->DeleteSegment(j);
3266 - cout << "Deleting Segment " << j << endl;
3274 - for (int i = 1; i <= geom.fmap.Extent(); i++)
3276 - Handle(Geom_Surface) hf1 =
3277 - BRep_Tool::Surface(TopoDS::Face(geom.fmap(i)));
3278 - for (int j = i+1; j <= geom.fmap.Extent(); j++)
3280 - Handle(Geom_Surface) hf2 =
3281 - BRep_Tool::Surface(TopoDS::Face(geom.fmap(j)));
3282 - if (hf1 == hf2) cout << "face " << i << " and face " << j << " lie on same surface" << endl;
3288 - (*logout) << "Edges meshed" << endl
3289 - << "time = " << GetTime() << " sec" << endl
3290 - << "points: " << mesh->GetNP() << endl;
3294 - if (multithread.terminate || perfstepsend <= MESHCONST_MESHEDGES)
3297 - if (perfstepsstart <= MESHCONST_MESHSURFACE)
3299 - OCCMeshSurface (geom, *mesh, perfstepsend);
3300 - if (multithread.terminate) return TCL_OK;
3303 - (*logout) << "Surfaces meshed" << endl
3304 - << "time = " << GetTime() << " sec" << endl
3305 - << "points: " << mesh->GetNP() << endl;
3309 - (*statout) << mesh->GetNSeg() << " & "
3310 - << mesh->GetNSE() << " & - &"
3311 - << GetTime() << " & " << endl;
3314 - // MeshQuality2d (*mesh);
3315 - mesh->CalcSurfacesOfNode();
3318 - if (multithread.terminate || perfstepsend <= MESHCONST_OPTSURFACE)
3321 - if (perfstepsstart <= MESHCONST_MESHVOLUME)
3323 - multithread.task = "Volume meshing";
3325 - MESHING3_RESULT res = MeshVolume (mparam, *mesh);
3328 - ofstream problemfile("occmesh.rep",ios_base::app);
3330 - problemfile << "VOLUMEMESHING" << endl << endl;
3331 - if(res != MESHING3_OK)
3332 - problemfile << "ERROR" << endl << endl;
3334 - problemfile << "OK" << endl
3335 - << mesh->GetNE() << " elements" << endl << endl;
3337 - problemfile.close();
3340 - if (res != MESHING3_OK) return TCL_ERROR;
3342 - if (multithread.terminate) return TCL_OK;
3344 - RemoveIllegalElements (*mesh);
3345 - if (multithread.terminate) return TCL_OK;
3347 - MeshQuality3d (*mesh);
3350 - (*statout) << GetTime() << " & ";
3354 - (*logout) << "Volume meshed" << endl
3355 - << "time = " << GetTime() << " sec" << endl
3356 - << "points: " << mesh->GetNP() << endl;
3360 - if (multithread.terminate || perfstepsend <= MESHCONST_MESHVOLUME)
3363 - if (perfstepsstart <= MESHCONST_OPTVOLUME)
3365 - multithread.task = "Volume optimization";
3367 - OptimizeVolume (mparam, *mesh);
3368 - if (multithread.terminate) return TCL_OK;
3371 - (*statout) << GetTime() << " & "
3372 - << mesh->GetNE() << " & "
3373 - << mesh->GetNP() << " " << '\\' << '\\' << " \\" << "hline" << endl;
3377 - (*logout) << "Volume optimized" << endl
3378 - << "time = " << GetTime() << " sec" << endl
3379 - << "points: " << mesh->GetNP() << endl;
3382 - // cout << "Optimization complete" << endl;
3386 - (*testout) << "NP: " << mesh->GetNP() << endl;
3387 - for (int i = 1; i <= mesh->GetNP(); i++)
3388 - (*testout) << mesh->Point(i) << endl;
3390 - (*testout) << endl << "NSegments: " << mesh->GetNSeg() << endl;
3391 - for (int i = 1; i <= mesh->GetNSeg(); i++)
3392 - (*testout) << mesh->LineSegment(i) << endl;
3401 +#include <mystdlib.h>
3402 +#include <occgeom.hpp>
3403 +#include <meshing.hpp>
3409 +#include "occmeshsurf.hpp"
3412 +#define TCL_ERROR 1
3414 +#define DIVIDEEDGESECTIONS 1000
3415 +#define IGNORECURVELENGTH 1e-4
3416 +#define VSMALL 1e-10
3419 + DLL_HEADER bool merge_solids = 1;
3422 + // can you please explain what you intend to compute here (JS) !!!
3423 + double Line :: Dist (Line l)
3426 + Vec<3> q = l.p1-l.p0;
3429 + Point<3> p = p0 + 0.5*n;
3430 + double lambda = (p-l.p0)*n / (nq + VSMALL);
3432 + if (lambda >= 0 && lambda <= 1)
3434 + double d = (p-l.p0-lambda*q).Length();
3435 + // if (d < 1e-3) d = 1e99;
3444 + double Line :: Length ()
3446 + return (p1-p0).Length();
3451 + inline Point<3> occ2ng (const gp_Pnt & p)
3453 + return Point<3> (p.X(), p.Y(), p.Z());
3458 + double ComputeH (double kappa)
3461 + kappa *= mparam.curvaturesafety;
3463 + if (mparam.maxh * kappa < 1)
3464 + hret = mparam.maxh;
3466 + hret = 1 / (kappa + VSMALL);
3468 + if (mparam.maxh < hret)
3469 + hret = mparam.maxh;
3477 + void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2,
3478 + BRepLProp_SLProps * prop, Mesh & mesh, int depth, double h = 0)
3482 + gp_Pnt pnt0,pnt1,pnt2;
3484 + prop->SetParameters (par0.X(), par0.Y());
3485 + pnt0 = prop->Value();
3487 + prop->SetParameters (par1.X(), par1.Y());
3488 + pnt1 = prop->Value();
3490 + prop->SetParameters (par2.X(), par2.Y());
3491 + pnt2 = prop->Value();
3494 + double maxside = pnt0.Distance(pnt1);
3496 + aux = pnt1.Distance(pnt2);
3502 + aux = pnt2.Distance(pnt0);
3513 + parmid.SetX( (par0.X()+par1.X()+par2.X()) / 3 );
3514 + parmid.SetY( (par0.Y()+par1.Y()+par2.Y()) / 3 );
3518 + double curvature = 0;
3520 + prop->SetParameters (parmid.X(), parmid.Y());
3521 + if (!prop->IsCurvatureDefined())
3523 + (*testout) << "curvature not defined!" << std::endl;
3526 + curvature = max(fabs(prop->MinCurvature()),
3527 + fabs(prop->MaxCurvature()));
3529 + prop->SetParameters (par0.X(), par0.Y());
3530 + if (!prop->IsCurvatureDefined())
3532 + (*testout) << "curvature not defined!" << std::endl;
3535 + curvature = max(curvature,max(fabs(prop->MinCurvature()),
3536 + fabs(prop->MaxCurvature())));
3538 + prop->SetParameters (par1.X(), par1.Y());
3539 + if (!prop->IsCurvatureDefined())
3541 + (*testout) << "curvature not defined!" << std::endl;
3544 + curvature = max(curvature,max(fabs(prop->MinCurvature()),
3545 + fabs(prop->MaxCurvature())));
3547 + prop->SetParameters (par2.X(), par2.Y());
3548 + if (!prop->IsCurvatureDefined())
3550 + (*testout) << "curvature not defined!" << std::endl;
3553 + curvature = max(curvature,max(fabs(prop->MinCurvature()),
3554 + fabs(prop->MaxCurvature())));
3556 + //(*testout) << "curvature " << curvature << std::endl;
3558 + if (curvature < 1e-3)
3560 + //(*testout) << "curvature too small (" << curvature << ")!" << std::endl;
3562 + // return war bis 10.2.05 auskommentiert
3567 + h = ComputeH (curvature+1e-10);
3569 + if(h < 1e-4*maxside)
3572 + // commented to restrict H on a large sphere for example
3573 + //if (h > 30) return;
3576 + if (h < maxside && depth < 10)
3578 + //std::cout << "\r h " << h << flush;
3581 + //std::cout << "h " << h << " maxside " << maxside << " depth " << depth << std::endl;
3582 + //std::cout << "par0 " << par0.X() << " " << par0.Y()
3583 + //<< " par1 " << par1.X() << " " << par1.Y()
3584 + // << " par2 " << par2.X() << " " << par2.Y()<< std::endl;
3588 + pm.SetX(0.5*(par1.X()+par2.X())); pm.SetY(0.5*(par1.Y()+par2.Y()));
3589 + RestrictHTriangle(pm, par2, par0, prop, mesh, depth+1, h);
3590 + RestrictHTriangle(pm, par0, par1, prop, mesh, depth+1, h);
3594 + pm.SetX(0.5*(par0.X()+par2.X())); pm.SetY(0.5*(par0.Y()+par2.Y()));
3595 + RestrictHTriangle(pm, par1, par2, prop, mesh, depth+1, h);
3596 + RestrictHTriangle(pm, par0, par1, prop, mesh, depth+1, h);
3600 + pm.SetX(0.5*(par0.X()+par1.X())); pm.SetY(0.5*(par0.Y()+par1.Y()));
3601 + RestrictHTriangle(pm, par1, par2, prop, mesh, depth+1, h);
3602 + RestrictHTriangle(pm, par2, par0, prop, mesh, depth+1, h);
3611 + prop->SetParameters (parmid.X(), parmid.Y());
3612 + pnt = prop->Value();
3613 + p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z());
3614 + mesh.RestrictLocalH (p3d, h);
3616 + p3d = Point3d(pnt0.X(), pnt0.Y(), pnt0.Z());
3617 + mesh.RestrictLocalH (p3d, h);
3619 + p3d = Point3d(pnt1.X(), pnt1.Y(), pnt1.Z());
3620 + mesh.RestrictLocalH (p3d, h);
3622 + p3d = Point3d(pnt2.X(), pnt2.Y(), pnt2.Z());
3623 + mesh.RestrictLocalH (p3d, h);
3625 + //(*testout) << "p = " << p3d << ", h = " << h << ", maxside = " << maxside << std::endl;
3632 + void DivideEdge (TopoDS_Edge & edge, Array<MeshPoint> & ps,
3633 + Array<double> & params, Mesh & mesh)
3636 + double maxh = mparam.maxh;
3637 + int nsubedges = 1;
3638 + gp_Pnt pnt, oldpnt;
3639 + double svalue[DIVIDEEDGESECTIONS];
3641 + GProp_GProps system;
3642 + BRepGProp::LinearProperties(edge, system);
3643 + double L = system.Mass();
3645 + Handle(Geom_Curve) c = BRep_Tool::Curve(edge, s0, s1);
3647 + double hvalue[DIVIDEEDGESECTIONS+1];
3649 + pnt = c->Value(s0);
3651 + //double olddist = 0; -- useless variables
3652 + //double dist = 0;
3654 + int tmpVal = (int)(DIVIDEEDGESECTIONS);
3656 + for (int i = 1; i <= tmpVal; i++)
3659 + pnt = c->Value(s0+(i/double(DIVIDEEDGESECTIONS))*(s1-s0));
3660 + // -- no more than 1 segment per <edge length>/DIVIDEEDGESECTIONS
3661 + hvalue[i] = hvalue[i-1] +
3662 + // 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
3663 + // pnt.Distance(oldpnt);
3665 + 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
3666 + pnt.Distance(oldpnt));
3668 + //(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))
3669 + // << " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << std::endl;
3671 + //olddist = dist; -- useless variables
3672 + //dist = pnt.Distance(oldpnt);
3675 + // nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS]));
3676 + nsubedges = max (1, int(floor(hvalue[DIVIDEEDGESECTIONS]+0.5)));
3678 + ps.SetSize(nsubedges-1);
3679 + params.SetSize(nsubedges+1);
3685 + if (hvalue[i1]/hvalue[DIVIDEEDGESECTIONS]*nsubedges >= i)
3687 + // -- for nsubedges comparable to DIVIDEEDGESECTIONS
3688 + //params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
3689 + double d1 = i1 - (hvalue[i1] - i*hvalue[DIVIDEEDGESECTIONS]/nsubedges)/(hvalue[i1]-hvalue[i1-1]);
3690 + params[i] = s0+(d1/double(DIVIDEEDGESECTIONS))*(s1-s0);
3691 + pnt = c->Value(params[i]);
3692 + ps[i-1] = MeshPoint (Point3d(pnt.X(), pnt.Y(), pnt.Z()));
3696 + if (i1 > DIVIDEEDGESECTIONS)
3699 + ps.SetSize(nsubedges-1);
3700 + params.SetSize(nsubedges+1);
3701 + std::cout << "divide edge: local h too small" << std::endl;
3703 + } while (i < nsubedges);
3706 + params[nsubedges] = s1;
3708 + if (params[nsubedges] <= params[nsubedges-1])
3710 + std::cout << "CORRECTED" << std::endl;
3711 + ps.SetSize (nsubedges-2);
3712 + params.SetSize (nsubedges);
3713 + params[nsubedges] = s1;
3720 + void OCCFindEdges (OCCGeometry & geom, Mesh & mesh)
3722 + const char * savetask = multithread.task;
3723 + multithread.task = "Edge meshing";
3725 + (*testout) << "edge meshing" << std::endl;
3727 + int nvertices = geom.vmap.Extent();
3728 + int nedges = geom.emap.Extent();
3730 + (*testout) << "nvertices = " << nvertices << std::endl;
3731 + (*testout) << "nedges = " << nedges << std::endl;
3733 + double eps = 1e-6 * geom.GetBoundingBox().Diam();
3734 + const double eps2 = eps * eps; // -- small optimization
3736 + int first_vp = mesh.GetNP()+1; // -- to support SALOME sub-meshes
3738 + for (int i = 1; i <= nvertices; i++)
3740 + gp_Pnt pnt = BRep_Tool::Pnt (TopoDS::Vertex(geom.vmap(i)));
3741 + MeshPoint mp( Point<3>(pnt.X(), pnt.Y(), pnt.Z()) );
3745 + for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++)
3746 + //if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
3747 + if ( Dist2 (mesh[pi], Point<3>(mp)) < eps2 ) // -- small optimization
3754 + mesh.AddPoint (mp);
3757 + (*testout) << "different vertices = " << mesh.GetNP() << std::endl;
3760 + int first_ep = mesh.GetNP()+1;
3762 + Array<int> face2solid[2];
3763 + for (int i = 0; i<2; i++)
3765 + face2solid[i].SetSize (geom.fmap.Extent());
3766 + face2solid[i] = 0;
3770 + for (TopExp_Explorer exp0(geom.shape, TopAbs_SOLID); exp0.More(); exp0.Next())
3773 + for (TopExp_Explorer exp1(exp0.Current(), TopAbs_FACE); exp1.More(); exp1.Next())
3775 + TopoDS_Face face = TopoDS::Face(exp1.Current());
3776 + int facenr = geom.fmap.FindIndex(face);
3777 + if ( facenr < 1 ) continue; // -- to support SALOME sub-meshes
3779 + if (face2solid[0][facenr-1] == 0)
3780 + face2solid[0][facenr-1] = solidnr;
3782 + face2solid[1][facenr-1] = solidnr;
3788 + for (int i3 = 1; i3 <= geom.fmap.Extent(); i3++)
3789 + for (TopExp_Explorer exp2(geom.fmap(i3), TopAbs_WIRE); exp2.More(); exp2.Next())
3790 + for (TopExp_Explorer exp3(exp2.Current(), TopAbs_EDGE); exp3.More(); exp3.Next())
3797 + edgenr = mesh.GetNSeg(); // to support SALOME sub-meshes
3799 + (*testout) << "faces = " << geom.fmap.Extent() << std::endl;
3802 + for (int i3 = 1; i3 <= geom.fmap.Extent(); i3++)
3804 + TopoDS_Face face = TopoDS::Face(geom.fmap(i3));
3805 + facenr = geom.fmap.FindIndex (face); // sollte doch immer == i3 sein ??? JS
3807 + int solidnr0 = face2solid[0][i3-1];
3808 + int solidnr1 = face2solid[1][i3-1];
3810 + /* auskommentiert am 3.3.05 von robert
3811 + for (exp2.Init (geom.somap(solidnr0), TopAbs_FACE); exp2.More(); exp2.Next())
3813 + TopoDS_Face face2 = TopoDS::Face(exp2.Current());
3814 + if (geom.fmap.FindIndex(face2) == facenr)
3816 + // if (face.Orientation() != face2.Orientation()) swap (solidnr0, solidnr1);
3821 + mesh.AddFaceDescriptor (FaceDescriptor(facenr, solidnr0, solidnr1, 0));
3823 + // Philippose - 06/07/2009
3824 + // Add the face colour to the mesh data
3825 + Quantity_Color face_colour;
3827 + if(!(geom.face_colours.IsNull())
3828 + && (geom.face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour)))
3830 + mesh.GetFaceDescriptor(facenr).SetSurfColour(Vec3d(face_colour.Red(),face_colour.Green(),face_colour.Blue()));
3834 + mesh.GetFaceDescriptor(facenr).SetSurfColour(Vec3d(0.0,1.0,0.0));
3836 + // ACHTUNG! STIMMT NICHT ALLGEMEIN (RG)
3839 + Handle(Geom_Surface) occface = BRep_Tool::Surface(face);
3841 + for (TopExp_Explorer exp2 (face, TopAbs_WIRE); exp2.More(); exp2.Next())
3843 + TopoDS_Shape wire = exp2.Current();
3845 + for (TopExp_Explorer exp3 (wire, TopAbs_EDGE); exp3.More(); exp3.Next())
3848 + (*testout) << "edge nr " << curr << std::endl;
3850 + multithread.percent = 100 * curr / double (total);
3851 + if (multithread.terminate) return;
3853 + TopoDS_Edge edge = TopoDS::Edge (exp3.Current());
3854 + if (BRep_Tool::Degenerated(edge))
3856 + //(*testout) << "ignoring degenerated edge" << std::endl;
3859 + if ( geom.emap.FindIndex(edge) < 1 ) continue; // to support SALOME sub-meshes
3861 + if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) ==
3862 + geom.vmap.FindIndex(TopExp::LastVertex (edge)))
3864 + GProp_GProps system;
3865 + BRepGProp::LinearProperties(edge, system);
3867 + if (system.Mass() < eps)
3869 + std::cout << "ignoring edge " << geom.emap.FindIndex (edge)
3870 + << ". closed edge with length < " << eps << std::endl;
3876 + Handle(Geom2d_Curve) cof;
3878 + cof = BRep_Tool::CurveOnSurface (edge, face, s0, s1);
3880 + int geomedgenr = geom.emap.FindIndex(edge);
3882 + Array <MeshPoint> mp;
3883 + Array <double> params;
3885 + DivideEdge (edge, mp, params, mesh);
3887 + Array <int> pnums;
3888 + pnums.SetSize (mp.Size()+2);
3890 + if (!merge_solids)
3892 + //pnums[0] = geom.vmap.FindIndex (TopExp::FirstVertex (edge));
3893 + //pnums[pnums.Size()-1] = geom.vmap.FindIndex (TopExp::LastVertex (edge));
3894 + MeshPoint dfltP ( Point<3> ( 0, 0, 0 ) );
3895 + int *ipp[] = { &pnums[0], &pnums[pnums.Size()-1] };
3896 + TopoDS_Iterator vIt( edge, false );
3897 + TopoDS_Vertex v[2];
3898 + v[0] = TopoDS::Vertex( vIt.Value() ); vIt.Next();
3899 + v[1] = TopoDS::Vertex( vIt.Value() );
3900 + if ( v[0].Orientation() == TopAbs_REVERSED )
3901 + std::swap( v[0], v[1] );
3902 + for ( int i = 0; i < 2; ++i)
3904 + int &ip = *ipp[i];
3905 + ip = geom.vmap.FindIndex ( v[i] );
3906 + if ( ip == 0 || ip > nvertices )
3910 + ip = iv = geom.vmap.Add( v[i] );
3911 + gp_Pnt pnt = BRep_Tool::Pnt( v[i] );
3912 + MeshPoint mp( Point<3>(pnt.X(), pnt.Y(), pnt.Z()) );
3913 + for (PointIndex pi = 1; pi < first_vp; pi++)
3914 + if ( Dist2 (mesh.Point(pi), Point<3>(mp)) < 1e-100 )
3917 + if ( mesh.Point(ip).GetLayer() != dfltP.GetLayer() && mesh.Point(ip).GetLayer() != iv )
3919 + if ( mesh.Point(ip).GetLayer() == dfltP.GetLayer())
3920 + mesh.Point(ip) = MeshPoint( mesh.Point(ip), iv );
3926 + ip += first_vp - 1;
3932 + TopoDS_Iterator vIt( edge, false );
3933 + TopoDS_Vertex v1 = TopoDS::Vertex( vIt.Value() ); vIt.Next();
3934 + TopoDS_Vertex v2 = TopoDS::Vertex( vIt.Value() );
3935 + if ( v1.Orientation() == TopAbs_REVERSED )
3936 + std::swap( v1, v2 );
3937 + const bool isClosedEdge = v1.IsSame( v2 );
3939 + Point<3> fp = occ2ng (BRep_Tool::Pnt (v1));
3940 + Point<3> lp = occ2ng (BRep_Tool::Pnt (v2));
3941 + double tol2 = min( eps*eps, 1e-6 * Dist2( fp, lp ));
3942 + if ( isClosedEdge )
3943 + tol2 = BRep_Tool::Tolerance( v1 ) * BRep_Tool::Tolerance( v1 );
3946 + pnums.Last() = -1;
3947 + for (PointIndex pi = 1; pi < first_ep; pi++)
3949 + if (Dist2 (mesh[pi], fp) < tol2) pnums[0] = pi;
3950 + if (Dist2 (mesh[pi], lp) < tol2) pnums.Last() = pi;
3952 + if (( isClosedEdge && pnums[0] != pnums.Last() ) ||
3953 + ( !isClosedEdge && pnums[0] == pnums.Last() ))
3954 + pnums[0] = pnums.Last() = -1;
3955 + if ( pnums[0] == -1 || pnums.Last() == -1 )
3957 + // take into account a possible large gap between a vertex and an edge curve
3958 + // end and a large vertex tolerance covering the whole edge
3959 + if ( pnums[0] == -1 )
3961 + double tol = BRep_Tool::Tolerance( v1 );
3962 + for (PointIndex pi = 1; pi < first_ep; pi++)
3963 + if (pi != pnums.Last() && Dist2 (mesh[pi], fp) < 2*tol*tol)
3966 + if ( pnums[0] == -1 )
3967 + pnums[0] = first_ep-1- nvertices + geom.vmap.FindIndex ( v1 );
3969 + if ( isClosedEdge )
3971 + pnums.Last() = pnums[0];
3975 + if ( pnums.Last() == -1 )
3977 + double tol = BRep_Tool::Tolerance( v2 );
3978 + for (PointIndex pi = 1; pi < first_ep; pi++)
3979 + if (pi != pnums[0] && Dist2 (mesh[pi], lp) < 2*tol*tol)
3980 + pnums.Last() = pi;
3982 + if ( pnums.Last() == -1 )
3983 + pnums.Last() = first_ep-1-nvertices + geom.vmap.FindIndex ( v2 );
3986 + if ( Dist2( fp, mesh[PointIndex(pnums[0])]) >
3987 + Dist2( lp, mesh[PointIndex(pnums.Last())]))
3988 + std::swap( pnums[0], pnums.Last() );
3994 + for (int i = 1; i <= mp.Size(); i++)
3998 + for (j = first_ep; j <= mesh.GetNP(); j++)
4000 + if (!merge_solids && mesh.Point(j).GetLayer() != geomedgenr ) continue; // to support SALOME fuse edges
4001 + if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps)
4012 + mesh.AddPoint (mp[i-1], geomedgenr); // to support SALOME fuse edges
4013 + (*testout) << "add meshpoint " << mp[i-1] << std::endl;
4014 + pnums[i] = mesh.GetNP();
4017 + (*testout) << "NP = " << mesh.GetNP() << std::endl;
4019 + //(*testout) << pnums[pnums.Size()-1] << std::endl;
4021 + for (int i = 1; i <= mp.Size()+1; i++)
4026 + seg[0] = pnums[i-1];
4027 + seg[1] = pnums[i];
4028 + seg.edgenr = edgenr;
4030 + seg.epgeominfo[0].dist = params[i-1];
4031 + seg.epgeominfo[1].dist = params[i];
4032 + seg.epgeominfo[0].edgenr = geomedgenr;
4033 + seg.epgeominfo[1].edgenr = geomedgenr;
4036 + p2d = cof->Value(params[i-1]);
4037 + // if (i == 1) p2d = cof->Value(s0);
4038 + seg.epgeominfo[0].u = p2d.X();
4039 + seg.epgeominfo[0].v = p2d.Y();
4040 + p2d = cof->Value(params[i]);
4041 + // if (i == mp.Size()+1) p2d = cof -> Value(s1);
4042 + seg.epgeominfo[1].u = p2d.X();
4043 + seg.epgeominfo[1].v = p2d.Y();
4046 + if (occface->IsUPeriodic())
4048 + std::cout << "U Periodic" << std::endl;
4049 + if (fabs(seg.epgeominfo[1].u-seg.epgeominfo[0].u) >
4050 + fabs(seg.epgeominfo[1].u-
4051 + (seg.epgeominfo[0].u-occface->UPeriod())))
4052 + seg.epgeominfo[0].u = p2d.X()+occface->UPeriod();
4054 + if (fabs(seg.epgeominfo[1].u-seg.epgeominfo[0].u) >
4055 + fabs(seg.epgeominfo[1].u-
4056 + (seg.epgeominfo[0].u+occface->UPeriod())))
4057 + seg.epgeominfo[0].u = p2d.X()-occface->UPeriod();
4060 + if (occface->IsVPeriodic())
4062 + std::cout << "V Periodic" << std::endl;
4063 + if (fabs(seg.epgeominfo[1].v-seg.epgeominfo[0].v) >
4064 + fabs(seg.epgeominfo[1].v-
4065 + (seg.epgeominfo[0].v-occface->VPeriod())))
4066 + seg.epgeominfo[0].v = p2d.Y()+occface->VPeriod();
4068 + if (fabs(seg.epgeominfo[1].v-seg.epgeominfo[0].v) >
4069 + fabs(seg.epgeominfo[1].v-
4070 + (seg.epgeominfo[0].v+occface->VPeriod())))
4071 + seg.epgeominfo[0].v = p2d.Y()-occface->VPeriod();
4075 + if (edge.Orientation() == TopAbs_REVERSED)
4077 + swap (seg[0], seg[1]);
4078 + swap (seg.epgeominfo[0].dist, seg.epgeominfo[1].dist);
4079 + swap (seg.epgeominfo[0].u, seg.epgeominfo[1].u);
4080 + swap (seg.epgeominfo[0].v, seg.epgeominfo[1].v);
4083 + mesh.AddSegment (seg);
4085 + //edgesegments[geomedgenr-1]->Append(mesh.GetNSeg());
4092 + // for(i=1; i<=mesh.GetNSeg(); i++)
4093 + // (*testout) << "edge " << mesh.LineSegment(i).edgenr << " face " << mesh.LineSegment(i).si
4094 + // << " p1 " << mesh.LineSegment(i)[0] << " p2 " << mesh.LineSegment(i)[1] << std::endl;
4096 + for (int j = 1; j <= mesh.GetNP(); j++) // to support SALOME fuse edges: set level to zero
4097 + mesh.Point(j) = MeshPoint( (Point<3>&) mesh.Point(j) );
4099 + mesh.CalcSurfacesOfNode();
4100 + multithread.task = savetask;
4106 + void OCCMeshSurface (OCCGeometry & geom, Mesh & mesh, int perfstepsend)
4111 + const char * savetask = multithread.task;
4112 + multithread.task = "Surface meshing";
4114 + geom.facemeshstatus = 0;
4116 + int noldp = mesh.GetNP();
4118 + double starttime = GetTime();
4120 + Array<int> glob2loc(noldp);
4122 + //int projecttype = PARAMETERSPACE;
4124 + int projecttype = PARAMETERSPACE;
4128 + int surfmesherror = 0;
4130 + for (k = 1; k <= mesh.GetNFD(); k++)
4132 + if(1==0 && !geom.fvispar[k-1].IsDrawable())
4134 + (*testout) << "ignoring face " << k << std::endl;
4135 + std::cout << "ignoring face " << k << std::endl;
4139 + (*testout) << "mesh face " << k << std::endl;
4140 + multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
4141 + geom.facemeshstatus[k-1] = -1;
4147 + std::cout << "skipped" << std::endl;
4153 + FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
4155 + int oldnf = mesh.GetNSE();
4157 + Box<3> bb = geom.GetBoundingBox();
4159 + // int projecttype = PLANESPACE;
4161 + Meshing2OCCSurfaces meshing(TopoDS::Face(geom.fmap(k)), bb, projecttype);
4163 + if (meshing.GetProjectionType() == PLANESPACE)
4164 + PrintMessage (2, "Face ", k, " / ", mesh.GetNFD(), " (plane space projection)");
4166 + PrintMessage (2, "Face ", k, " / ", mesh.GetNFD(), " (parameter space projection)");
4168 + if (surfmesherror)
4169 + std::cout << "Surface meshing error occured before (in " << surfmesherror << " faces)" << std::endl;
4171 + // Meshing2OCCSurfaces meshing(f2, bb);
4172 + meshing.SetStartTime (starttime);
4174 + //(*testout) << "Face " << k << std::endl << std::endl;
4177 + if (meshing.GetProjectionType() == PLANESPACE)
4181 + for (i = 1; i <= mesh.GetNSeg(); i++)
4183 + Segment & seg = mesh.LineSegment(i);
4186 + for (j = 1; j <= 2; j++)
4188 + int pi = (j == 1) ? seg[0] : seg[1];
4189 + if (!glob2loc.Get(pi))
4191 + meshing.AddPoint (mesh.Point(pi), pi);
4193 + glob2loc.Elem(pi) = cntp;
4199 + for (i = 1; i <= mesh.GetNSeg(); i++)
4201 + Segment & seg = mesh.LineSegment(i);
4204 + PointGeomInfo gi0, gi1;
4205 + gi0.trignum = gi1.trignum = k;
4206 + gi0.u = seg.epgeominfo[0].u;
4207 + gi0.v = seg.epgeominfo[0].v;
4208 + gi1.u = seg.epgeominfo[1].u;
4209 + gi1.v = seg.epgeominfo[1].v;
4211 + meshing.AddBoundaryElement (glob2loc.Get(seg[0]), glob2loc.Get(seg[1]), gi0, gi1);
4212 + //(*testout) << gi0.u << " " << gi0.v << std::endl;
4213 + //(*testout) << gi1.u << " " << gi1.v << std::endl;
4221 + for (i = 1; i <= mesh.GetNSeg(); i++)
4222 + if (mesh.LineSegment(i).si == k)
4226 + Array< PointGeomInfo > gis;
4228 + gis.SetAllocSize (cntp);
4231 + for (i = 1; i <= mesh.GetNSeg(); i++)
4233 + Segment & seg = mesh.LineSegment(i);
4236 + PointGeomInfo gi0, gi1;
4237 + gi0.trignum = gi1.trignum = k;
4238 + gi0.u = seg.epgeominfo[0].u;
4239 + gi0.v = seg.epgeominfo[0].v;
4240 + gi1.u = seg.epgeominfo[1].u;
4241 + gi1.v = seg.epgeominfo[1].v;
4243 + int locpnum[2] = {0, 0};
4245 + for (j = 0; j < 2; j++)
4247 + PointGeomInfo gi = (j == 0) ? gi0 : gi1;
4250 + for (l = 0; l < gis.Size() && locpnum[j] == 0; l++)
4252 + double dist = sqr (gis[l].u-gi.u)+sqr(gis[l].v-gi.v);
4258 + if (locpnum[j] == 0)
4260 + int pi = (j == 0) ? seg[0] : seg[1];
4261 + meshing.AddPoint (mesh.Point(pi), pi);
4263 + gis.SetSize (gis.Size()+1);
4269 + meshing.AddBoundaryElement (locpnum[0], locpnum[1], gi0, gi1);
4270 + //(*testout) << gi0.u << " " << gi0.v << std::endl;
4271 + //(*testout) << gi1.u << " " << gi1.v << std::endl;
4281 + // Philippose - 15/01/2009
4282 + double maxh = geom.face_maxh[k-1];
4283 + //double maxh = mparam.maxh;
4284 + mparam.checkoverlap = 0;
4285 + // int noldpoints = mesh->GetNP();
4286 + int noldsurfel = mesh.GetNSE();
4288 + GProp_GProps sprops;
4289 + BRepGProp::SurfaceProperties(TopoDS::Face(geom.fmap(k)),sprops);
4290 + meshing.SetMaxArea(2.*sprops.Mass());
4292 + MESHING2_RESULT res;
4295 + res = meshing.GenerateMesh (mesh, mparam, maxh, k);
4298 + catch (SingularMatrixException)
4300 + (*myerr) << "Singular Matrix" << std::endl;
4301 + res = MESHING2_GIVEUP;
4304 + catch (UVBoundsException)
4306 + (*myerr) << "UV bounds exceeded" << std::endl;
4307 + res = MESHING2_GIVEUP;
4310 + projecttype = PARAMETERSPACE;
4312 + if (res != MESHING2_OK)
4316 + for (int i = noldsurfel+1; i <= mesh.GetNSE(); i++)
4317 + mesh.DeleteSurfaceElement (i);
4321 + std::cout << "retry Surface " << k << std::endl;
4330 + geom.facemeshstatus[k-1] = -1;
4331 + PrintError ("Problem in Surface mesh generation");
4333 + // throw NgException ("Problem in Surface mesh generation");
4338 + geom.facemeshstatus[k-1] = 1;
4343 + for (i = oldnf+1; i <= mesh.GetNSE(); i++)
4344 + mesh.SurfaceElement(i).SetIndex (k);
4348 +// ofstream problemfile("occmesh.rep");
4350 +// problemfile << "SURFACEMESHING" << std::endl << std::endl;
4352 + if (surfmesherror)
4354 + std::cout << "WARNING! NOT ALL FACES HAVE BEEN MESHED" << std::endl;
4355 + std::cout << "SURFACE MESHING ERROR OCCURED IN " << surfmesherror << " FACES:" << std::endl;
4356 + for (int i = 1; i <= geom.fmap.Extent(); i++)
4357 + if (geom.facemeshstatus[i-1] == -1)
4359 + std::cout << "Face " << i << std::endl;
4360 +// problemfile << "problem with face " << i << std::endl;
4361 +// problemfile << "vertices: " << std::endl;
4362 + TopExp_Explorer exp0,exp1,exp2;
4363 + for ( exp0.Init(TopoDS::Face (geom.fmap(i)), TopAbs_WIRE); exp0.More(); exp0.Next() )
4365 + TopoDS_Wire wire = TopoDS::Wire(exp0.Current());
4366 + for ( exp1.Init(wire,TopAbs_EDGE); exp1.More(); exp1.Next() )
4368 + TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
4369 + for ( exp2.Init(edge,TopAbs_VERTEX); exp2.More(); exp2.Next() )
4371 + TopoDS_Vertex vertex = TopoDS::Vertex(exp2.Current());
4372 + gp_Pnt point = BRep_Tool::Pnt(vertex);
4373 +// problemfile << point.X() << " " << point.Y() << " " << point.Z() << std::endl;
4377 +// problemfile << std::endl;
4380 + std::cout << std::endl << std::endl;
4381 + std::cout << "for more information open IGES/STEP Topology Explorer" << std::endl;
4382 +// problemfile.close();
4383 + throw NgException ("Problem in Surface mesh generation");
4387 +// problemfile << "OK" << std::endl << std::endl;
4388 +// problemfile.close();
4394 + if (multithread.terminate || perfstepsend < MESHCONST_OPTSURFACE)
4397 + multithread.task = "Optimizing surface";
4399 + static int timer_opt2d = NgProfiler::CreateTimer ("Optimization 2D");
4400 + NgProfiler::StartTimer (timer_opt2d);
4402 + for (k = 1; k <= mesh.GetNFD(); k++)
4404 + // if (k != 42) continue;
4405 + // if (k != 36) continue;
4407 + // (*testout) << "optimize face " << k << std::endl;
4408 + multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
4410 + FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
4412 + PrintMessage (1, "Optimize Surface ", k);
4413 + for (i = 1; i <= mparam.optsteps2d; i++)
4415 + // (*testout) << "optstep " << i << std::endl;
4416 + if (multithread.terminate) return;
4419 + MeshOptimize2dOCCSurfaces meshopt(geom);
4420 + meshopt.SetFaceIndex (k);
4421 + meshopt.SetImproveEdges (0);
4422 + meshopt.SetMetricWeight (mparam.elsizeweight);
4423 + //meshopt.SetMetricWeight (0.2);
4424 + meshopt.SetWriteStatus (0);
4426 + // (*testout) << "EdgeSwapping (mesh, (i > mparam.optsteps2d/2))" << std::endl;
4427 + meshopt.EdgeSwapping (mesh, (i > mparam.optsteps2d/2));
4430 + if (multithread.terminate) return;
4432 + MeshOptimize2dOCCSurfaces meshopt(geom);
4433 + meshopt.SetFaceIndex (k);
4434 + meshopt.SetImproveEdges (0);
4435 + //meshopt.SetMetricWeight (0.2);
4436 + meshopt.SetMetricWeight (mparam.elsizeweight);
4437 + meshopt.SetWriteStatus (0);
4439 + // (*testout) << "ImproveMesh (mesh)" << std::endl;
4440 + meshopt.ImproveMesh (mesh, mparam);
4444 + MeshOptimize2dOCCSurfaces meshopt(geom);
4445 + meshopt.SetFaceIndex (k);
4446 + meshopt.SetImproveEdges (0);
4447 + //meshopt.SetMetricWeight (0.2);
4448 + meshopt.SetMetricWeight (mparam.elsizeweight);
4449 + meshopt.SetWriteStatus (0);
4451 + // (*testout) << "CombineImprove (mesh)" << std::endl;
4452 + meshopt.CombineImprove (mesh);
4455 + if (multithread.terminate) return;
4457 + MeshOptimize2dOCCSurfaces meshopt(geom);
4458 + meshopt.SetFaceIndex (k);
4459 + meshopt.SetImproveEdges (0);
4460 + //meshopt.SetMetricWeight (0.2);
4461 + meshopt.SetMetricWeight (mparam.elsizeweight);
4462 + meshopt.SetWriteStatus (0);
4464 + // (*testout) << "ImproveMesh (mesh)" << std::endl;
4465 + meshopt.ImproveMesh (mesh, mparam);
4472 + mesh.CalcSurfacesOfNode();
4475 + NgProfiler::StopTimer (timer_opt2d);
4477 + multithread.task = savetask;
4482 + void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh)
4484 + mesh.SetGlobalH (mparam.maxh);
4485 + mesh.SetMinimalH (mparam.minh);
4487 + Array<double> maxhdom;
4488 + maxhdom.SetSize (geom.NrSolids());
4489 + maxhdom = mparam.maxh;
4491 + mesh.SetMaxHDomain (maxhdom);
4493 + Box<3> bb = geom.GetBoundingBox();
4494 + bb.Increase (bb.Diam()/10);
4496 + mesh.SetLocalH (bb.PMin(), bb.PMax(), 0.5);
4498 + if (mparam.uselocalh)
4500 + const char * savetask = multithread.task;
4501 + multithread.percent = 0;
4503 + mesh.SetLocalH (bb.PMin(), bb.PMax(), mparam.grading);
4505 + int nedges = geom.emap.Extent();
4507 + double mincurvelength = IGNORECURVELENGTH;
4508 + double maxedgelen = 0;
4509 + double minedgelen = 1e99;
4511 + if(occparam.resthminedgelenenable)
4513 + mincurvelength = occparam.resthminedgelen;
4514 + if(mincurvelength < IGNORECURVELENGTH) mincurvelength = IGNORECURVELENGTH;
4517 + multithread.task = "Setting local mesh size (elements per edge)";
4519 + // setting elements per edge
4521 + for (int i = 1; i <= nedges && !multithread.terminate; i++)
4523 + TopoDS_Edge e = TopoDS::Edge (geom.emap(i));
4524 + multithread.percent = 100 * (i-1)/double(nedges);
4525 + if (BRep_Tool::Degenerated(e)) continue;
4527 + GProp_GProps system;
4528 + BRepGProp::LinearProperties(e, system);
4529 + double len = system.Mass();
4531 + if (len < mincurvelength)
4533 + (*testout) << "ignored" << std::endl;
4537 + double localh = len/mparam.segmentsperedge;
4540 + // Philippose - 23/01/2009
4541 + // Find all the parent faces of a given edge
4542 + // and limit the mesh size of the edge based on the
4543 + // mesh size limit of the face
4544 + TopTools_IndexedDataMapOfShapeListOfShape edge_face_map;
4545 + edge_face_map.Clear();
4547 + TopExp::MapShapesAndAncestors(geom.shape, TopAbs_EDGE, TopAbs_FACE, edge_face_map);
4548 + const TopTools_ListOfShape& parent_faces = edge_face_map.FindFromKey(e);
4550 + TopTools_ListIteratorOfListOfShape parent_face_list;
4552 + for(parent_face_list.Initialize(parent_faces); parent_face_list.More(); parent_face_list.Next())
4554 + TopoDS_Face parent_face = TopoDS::Face(parent_face_list.Value());
4556 + int face_index = geom.fmap.FindIndex(parent_face);
4558 + if(face_index >= 1) localh = min(localh,geom.face_maxh[face_index - 1]);
4561 + Handle(Geom_Curve) c = BRep_Tool::Curve(e, s0, s1);
4563 + maxedgelen = max (maxedgelen, len);
4564 + minedgelen = min (minedgelen, len);
4566 + // Philippose - 23/01/2009
4567 + // Modified the calculation of maxj, because the
4568 + // method used so far always results in maxj = 2,
4569 + // which causes the localh to be set only at the
4570 + // starting, mid and end of the edge.
4572 + // int maxj = 2 * (int) ceil (localh/len);
4573 + int maxj = max((int) ceil(len/localh), 2);
4575 + for (int j = 0; j <= maxj; j++)
4577 + gp_Pnt pnt = c->Value (s0+double(j)/maxj*(s1-s0));
4578 + mesh.RestrictLocalH (Point3d(pnt.X(), pnt.Y(), pnt.Z()), localh);
4582 + multithread.task = "Setting local mesh size (edge curvature)";
4584 + // setting edge curvature
4586 + int nsections = 20;
4588 + for (int i = 1; i <= nedges && !multithread.terminate; i++)
4590 + double maxcur = 0;
4591 + multithread.percent = 100 * (i-1)/double(nedges);
4592 + TopoDS_Edge edge = TopoDS::Edge (geom.emap(i));
4593 + if (BRep_Tool::Degenerated(edge)) continue;
4595 + Handle(Geom_Curve) c = BRep_Tool::Curve(edge, s0, s1);
4596 + BRepAdaptor_Curve brepc(edge);
4597 + BRepLProp_CLProps prop(brepc, 2, 1e-5);
4599 + for (int j = 1; j <= nsections; j++)
4601 + double s = s0 + j/(double) nsections * (s1-s0);
4602 + prop.SetParameter (s);
4603 + double curvature = prop.Curvature();
4604 + if(curvature> maxcur) maxcur = curvature;
4606 + if (curvature >= 1e99)
4609 + gp_Pnt pnt = c->Value (s);
4611 + mesh.RestrictLocalH (Point3d(pnt.X(), pnt.Y(), pnt.Z()), ComputeH (fabs(curvature)));
4613 + // (*testout) << "edge " << i << " max. curvature: " << maxcur << std::endl;
4616 + multithread.task = "Setting local mesh size (face curvature)";
4618 + // setting face curvature
4620 + int nfaces = geom.fmap.Extent();
4622 + for (int i = 1; i <= nfaces && !multithread.terminate; i++)
4624 + multithread.percent = 100 * (i-1)/double(nfaces);
4625 + TopoDS_Face face = TopoDS::Face(geom.fmap(i));
4626 + TopLoc_Location loc;
4627 + Handle(Geom_Surface) surf = BRep_Tool::Surface (face);
4628 + Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation (face, loc);
4630 + if (triangulation.IsNull()) continue;
4632 + BRepAdaptor_Surface sf(face, Standard_True);
4633 + BRepLProp_SLProps prop(sf, 2, 1e-5);
4635 + int ntriangles = triangulation -> NbTriangles();
4636 + for (int j = 1; j <= ntriangles; j++)
4641 + for (int k = 1; k <=3; k++)
4643 + int n = triangulation->Triangles()(j)(k);
4644 + p[k-1] = triangulation->Nodes()(n).Transformed(loc);
4645 + par[k-1] = triangulation->UVNodes()(n);
4648 + //double maxside = 0;
4649 + //maxside = max (maxside, p[0].Distance(p[1]));
4650 + //maxside = max (maxside, p[0].Distance(p[2]));
4651 + //maxside = max (maxside, p[1].Distance(p[2]));
4652 + //std::cout << "\rFace " << i << " pos11 ntriangles " << ntriangles << " maxside " << maxside << flush;
4654 + RestrictHTriangle (par[0], par[1], par[2], &prop, mesh, 0);
4655 + //std::cout << "\rFace " << i << " pos12 ntriangles " << ntriangles << flush;
4659 + // setting close edges
4661 + if (occparam.resthcloseedgeenable)
4663 + multithread.task = "Setting local mesh size (close edges)";
4665 + int sections = 100;
4667 + Array<Line> lines(sections*nedges);
4669 + Box3dTree* searchtree =
4670 + new Box3dTree (bb.PMin(), bb.PMax());
4673 + for (int i = 1; i <= nedges && !multithread.terminate; i++)
4675 + TopoDS_Edge edge = TopoDS::Edge (geom.emap(i));
4676 + if (BRep_Tool::Degenerated(edge)) continue;
4679 + Handle(Geom_Curve) c = BRep_Tool::Curve(edge, s0, s1);
4680 + BRepAdaptor_Curve brepc(edge);
4681 + BRepLProp_CLProps prop(brepc, 1, 1e-5);
4682 + prop.SetParameter (s0);
4684 + gp_Vec d0 = prop.D1().Normalized();
4685 + double s_start = s0;
4687 + for (int j = 1; j <= sections; j++)
4689 + double s = s0 + (s1-s0)*(double)j/(double)sections;
4690 + prop.SetParameter (s);
4691 + gp_Vec d1 = prop.D1().Normalized();
4692 + double cosalpha = fabs(d0*d1);
4693 + if ((j == sections) || (cosalpha < cos(10.0/180.0*M_PI)))
4696 + gp_Pnt p0 = c->Value (s_start);
4697 + gp_Pnt p1 = c->Value (s);
4698 + lines[nlines].p0 = Point<3> (p0.X(), p0.Y(), p0.Z());
4699 + lines[nlines].p1 = Point<3> (p1.X(), p1.Y(), p1.Z());
4702 + box.SetPoint (Point3d(lines[nlines].p0));
4703 + box.AddPoint (Point3d(lines[nlines].p1));
4705 + searchtree->Insert (box.PMin(), box.PMax(), nlines+1);
4714 + Array<int> linenums;
4716 + for (int i = 0; i < nlines; i++)
4718 + multithread.percent = (100*i)/double(nlines);
4719 + Line & line = lines[i];
4722 + box.SetPoint (Point3d(line.p0));
4723 + box.AddPoint (Point3d(line.p1));
4724 + double maxhline = max (mesh.GetH(box.PMin()),
4725 + mesh.GetH(box.PMax()));
4726 + box.Increase(maxhline);
4728 + double mindist = 1e99;
4729 + linenums.SetSize(0);
4730 + searchtree->GetIntersecting(box.PMin(),box.PMax(),linenums);
4732 + for (int j = 0; j < linenums.Size(); j++)
4734 + int num = linenums[j]-1;
4735 + if (i == num) continue;
4736 + if ((line.p0-lines[num].p0).Length2() < 1e-15) continue;
4737 + if ((line.p0-lines[num].p1).Length2() < 1e-15) continue;
4738 + if ((line.p1-lines[num].p0).Length2() < 1e-15) continue;
4739 + if ((line.p1-lines[num].p1).Length2() < 1e-15) continue;
4740 + mindist = min (mindist, line.Dist(lines[num]));
4743 + mindist /= (occparam.resthcloseedgefac + VSMALL);
4745 + if (mindist < 1e-3)
4747 + (*testout) << "extremely small local h: " << mindist
4748 + << " --> setting to 1e-3" << std::endl;
4749 + (*testout) << "somewhere near " << line.p0 << " - " << line.p1 << std::endl;
4753 + mesh.RestrictLocalHLine(line.p0, line.p1, mindist);
4757 + multithread.task = savetask;
4761 + // Philippose - 09/03/2009
4762 + // Added the capability to load the mesh size from a
4763 + // file also for OpenCascade Geometry
4765 + // ** If the "uselocalh" option is ticked in
4766 + // the "mesh options...insider" menu, the mesh
4767 + // size will be further modified by the topology
4768 + // analysis routines.
4769 + // ** To use the mesh size file as the sole source
4770 + // for defining the mesh size, uncheck the "uselocalh"
4772 + mesh.LoadLocalMeshSize (mparam.meshsizefilename);
4777 + int OCCGenerateMesh (OCCGeometry & geom, Mesh *& mesh, MeshingParameters & mparam,
4778 + int perfstepsstart, int perfstepsend)
4780 + multithread.percent = 0;
4782 + if (perfstepsstart <= MESHCONST_ANALYSE)
4785 + mesh = new Mesh();
4786 + mesh->geomtype = Mesh::GEOM_OCC;
4788 + OCCSetLocalMeshSize(geom,*mesh);
4791 + if (multithread.terminate || perfstepsend <= MESHCONST_ANALYSE)
4794 + if (perfstepsstart <= MESHCONST_MESHEDGES)
4796 + OCCFindEdges (geom, *mesh);
4799 + std::cout << "Removing redundant points" << std::endl;
4802 + int np = mesh->GetNP();
4803 + Array<int> equalto;
4805 + equalto.SetSize (np);
4808 + for (i = 1; i <= np; i++)
4810 + for (j = i+1; j <= np; j++)
4812 + if (!equalto[j-1] && (Dist2 (mesh->Point(i), mesh->Point(j)) < 1e-12))
4817 + for (i = 1; i <= np; i++)
4820 + std::cout << "Point " << i << " is equal to Point " << equalto[i-1] << std::endl;
4821 + for (j = 1; j <= mesh->GetNSeg(); j++)
4823 + Segment & seg = mesh->LineSegment(j);
4824 + if (seg[0] == i) seg[0] = equalto[i-1];
4825 + if (seg[1] == i) seg[1] = equalto[i-1];
4829 + std::cout << "Removing degenerated segments" << std::endl;
4830 + for (j = 1; j <= mesh->GetNSeg(); j++)
4832 + Segment & seg = mesh->LineSegment(j);
4833 + if (seg[0] == seg[1])
4835 + mesh->DeleteSegment(j);
4836 + std::cout << "Deleting Segment " << j << std::endl;
4844 + for (int i = 1; i <= geom.fmap.Extent(); i++)
4846 + Handle(Geom_Surface) hf1 =
4847 + BRep_Tool::Surface(TopoDS::Face(geom.fmap(i)));
4848 + for (int j = i+1; j <= geom.fmap.Extent(); j++)
4850 + Handle(Geom_Surface) hf2 =
4851 + BRep_Tool::Surface(TopoDS::Face(geom.fmap(j)));
4852 + if (hf1 == hf2) std::cout << "face " << i << " and face " << j << " lie on same surface" << std::endl;
4858 + (*logout) << "Edges meshed" << std::endl
4859 + << "time = " << GetTime() << " sec" << std::endl
4860 + << "points: " << mesh->GetNP() << std::endl;
4864 + if (multithread.terminate || perfstepsend <= MESHCONST_MESHEDGES)
4867 + if (perfstepsstart <= MESHCONST_MESHSURFACE)
4869 + OCCMeshSurface (geom, *mesh, perfstepsend);
4870 + if (multithread.terminate) return TCL_OK;
4873 + (*logout) << "Surfaces meshed" << std::endl
4874 + << "time = " << GetTime() << " sec" << std::endl
4875 + << "points: " << mesh->GetNP() << std::endl;
4879 + (*statout) << mesh->GetNSeg() << " & "
4880 + << mesh->GetNSE() << " & - &"
4881 + << GetTime() << " & " << std::endl;
4884 + // MeshQuality2d (*mesh);
4885 + mesh->CalcSurfacesOfNode();
4888 + if (multithread.terminate || perfstepsend <= MESHCONST_OPTSURFACE)
4891 + if (perfstepsstart <= MESHCONST_MESHVOLUME)
4893 + multithread.task = "Volume meshing";
4895 + MESHING3_RESULT res = MeshVolume (mparam, *mesh);
4898 + ofstream problemfile("occmesh.rep",ios_base::app);
4900 + problemfile << "VOLUMEMESHING" << std::endl << std::endl;
4901 + if(res != MESHING3_OK)
4902 + problemfile << "ERROR" << std::endl << std::endl;
4904 + problemfile << "OK" << std::endl
4905 + << mesh->GetNE() << " elements" << std::endl << std::endl;
4907 + problemfile.close();
4910 + if (res != MESHING3_OK) return TCL_ERROR;
4912 + if (multithread.terminate) return TCL_OK;
4914 + RemoveIllegalElements (*mesh);
4915 + if (multithread.terminate) return TCL_OK;
4917 + MeshQuality3d (*mesh);
4920 + (*statout) << GetTime() << " & ";
4924 + (*logout) << "Volume meshed" << std::endl
4925 + << "time = " << GetTime() << " sec" << std::endl
4926 + << "points: " << mesh->GetNP() << std::endl;
4930 + if (multithread.terminate || perfstepsend <= MESHCONST_MESHVOLUME)
4933 + if (perfstepsstart <= MESHCONST_OPTVOLUME)
4935 + multithread.task = "Volume optimization";
4937 + OptimizeVolume (mparam, *mesh);
4938 + if (multithread.terminate) return TCL_OK;
4941 + (*statout) << GetTime() << " & "
4942 + << mesh->GetNE() << " & "
4943 + << mesh->GetNP() << " " << '\\' << '\\' << " \\" << "hline" << std::endl;
4947 + (*logout) << "Volume optimized" << std::endl
4948 + << "time = " << GetTime() << " sec" << std::endl
4949 + << "points: " << mesh->GetNP() << std::endl;
4952 + // std::cout << "Optimization complete" << std::endl;
4956 + (*testout) << "NP: " << mesh->GetNP() << std::endl;
4957 + for (int i = 1; i <= mesh->GetNP(); i++)
4958 + (*testout) << mesh->Point(i) << std::endl;
4960 + (*testout) << std::endl << "NSegments: " << mesh->GetNSeg() << std::endl;
4961 + for (int i = 1; i <= mesh->GetNSeg(); i++)
4962 + (*testout) << mesh->LineSegment(i) << std::endl;
4969 --- netgen_ref/libsrc/occ/occgeom.cpp
4970 +++ netgen/libsrc/occ/occgeom.cpp
4971 @@ -1,1612 +1,1669 @@
4975 -#include <mystdlib.h>
4976 -#include <occgeom.hpp>
4977 -#include "ShapeAnalysis_ShapeTolerance.hxx"
4978 -#include "ShapeAnalysis_ShapeContents.hxx"
4979 -#include "ShapeAnalysis_CheckSmallFace.hxx"
4980 -#include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"
4981 -#include "ShapeAnalysis_Surface.hxx"
4982 -#include "BRepAlgoAPI_Fuse.hxx"
4983 -#include "BRepCheck_Analyzer.hxx"
4984 -#include "BRepLib.hxx"
4985 -#include "ShapeBuild_ReShape.hxx"
4986 -#include "ShapeFix.hxx"
4987 -#include "ShapeFix_FixSmallFace.hxx"
4988 -#include "Partition_Spliter.hxx"
4993 - void OCCGeometry :: PrintNrShapes ()
4995 - TopExp_Explorer e;
4997 - for (e.Init(shape, TopAbs_COMPSOLID); e.More(); e.Next()) count++;
4998 - cout << "CompSolids: " << count << endl;
5000 - cout << "Solids : " << somap.Extent() << endl;
5001 - cout << "Shells : " << shmap.Extent() << endl;
5002 - cout << "Faces : " << fmap.Extent() << endl;
5003 - cout << "Edges : " << emap.Extent() << endl;
5004 - cout << "Vertices : " << vmap.Extent() << endl;
5010 - void PrintContents (OCCGeometry * geom)
5012 - ShapeAnalysis_ShapeContents cont;
5014 - cont.Perform(geom->shape);
5016 - (*testout) << "OCC CONTENTS" << endl;
5017 - (*testout) << "============" << endl;
5018 - (*testout) << "SOLIDS : " << cont.NbSolids() << endl;
5019 - (*testout) << "SHELLS : " << cont.NbShells() << endl;
5020 - (*testout) << "FACES : " << cont.NbFaces() << endl;
5021 - (*testout) << "WIRES : " << cont.NbWires() << endl;
5022 - (*testout) << "EDGES : " << cont.NbEdges() << endl;
5023 - (*testout) << "VERTICES : " << cont.NbVertices() << endl;
5025 - TopExp_Explorer e;
5027 - for (e.Init(geom->shape, TopAbs_COMPOUND); e.More(); e.Next())
5029 - (*testout) << "Compounds: " << count << endl;
5032 - for (e.Init(geom->shape, TopAbs_COMPSOLID); e.More(); e.Next())
5034 - (*testout) << "CompSolids: " << count << endl;
5036 - (*testout) << endl;
5038 - cout << "Highest entry in topology hierarchy: " << endl;
5040 - cout << count << " composite solid(s)" << endl;
5042 - if (geom->somap.Extent())
5043 - cout << geom->somap.Extent() << " solid(s)" << endl;
5045 - if (geom->shmap.Extent())
5046 - cout << geom->shmap.Extent() << " shells(s)" << endl;
5048 - if (geom->fmap.Extent())
5049 - cout << geom->fmap.Extent() << " face(s)" << endl;
5051 - if (geom->wmap.Extent())
5052 - cout << geom->wmap.Extent() << " wire(s)" << endl;
5054 - if (geom->emap.Extent())
5055 - cout << geom->emap.Extent() << " edge(s)" << endl;
5057 - if (geom->vmap.Extent())
5058 - cout << geom->vmap.Extent() << " vertices(s)" << endl;
5060 - cout << "no entities" << endl;
5066 - void OCCGeometry :: HealGeometry ()
5068 - int nrc = 0, nrcs = 0,
5069 - nrso = somap.Extent(),
5070 - nrsh = shmap.Extent(),
5071 - nrf = fmap.Extent(),
5072 - nrw = wmap.Extent(),
5073 - nre = emap.Extent(),
5074 - nrv = vmap.Extent();
5076 - TopExp_Explorer exp0;
5077 - TopExp_Explorer exp1;
5080 - for (exp0.Init(shape, TopAbs_COMPOUND); exp0.More(); exp0.Next()) nrc++;
5081 - for (exp0.Init(shape, TopAbs_COMPSOLID); exp0.More(); exp0.Next()) nrcs++;
5083 - double surfacecont = 0;
5086 - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
5087 - rebuild->Apply(shape);
5088 - for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
5090 - TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
5091 - if ( BRep_Tool::Degenerated(edge) )
5092 - rebuild->Remove(edge, false);
5094 - shape = rebuild->Apply(shape);
5100 - for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next())
5102 - TopoDS_Face face = TopoDS::Face(exp0.Current());
5104 - GProp_GProps system;
5105 - BRepGProp::SurfaceProperties(face, system);
5106 - surfacecont += system.Mass();
5110 - cout << "Starting geometry healing procedure (tolerance: " << tolerance << ")" << endl
5111 - << "-----------------------------------" << endl;
5114 - cout << endl << "- repairing faces" << endl;
5116 - Handle(ShapeFix_Face) sff;
5117 - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
5118 - rebuild->Apply(shape);
5121 - for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next())
5123 - // Variable to hold the colour (if there exists one) of
5124 - // the current face being processed
5125 - Quantity_Color face_colour;
5127 - TopoDS_Face face = TopoDS::Face (exp0.Current());
5129 - if(face_colours.IsNull()
5130 - || (!(face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour))))
5132 - // Set the default face colour to green (Netgen Standard)
5133 - // if no colour has been defined for the face
5134 - face_colour = Quantity_Color(0.0,1.0,0.0,Quantity_TOC_RGB);
5137 - sff = new ShapeFix_Face (face);
5138 - sff->FixAddNaturalBoundMode() = Standard_True;
5139 - sff->FixSmallAreaWireMode() = Standard_True;
5142 - if(sff->Status(ShapeExtend_DONE1) ||
5143 - sff->Status(ShapeExtend_DONE2) ||
5144 - sff->Status(ShapeExtend_DONE3) ||
5145 - sff->Status(ShapeExtend_DONE4) ||
5146 - sff->Status(ShapeExtend_DONE5))
5148 - cout << "repaired face " << fmap.FindIndex(face) << " ";
5149 - if(sff->Status(ShapeExtend_DONE1))
5150 - cout << "(some wires are fixed)" <<endl;
5151 - else if(sff->Status(ShapeExtend_DONE2))
5152 - cout << "(orientation of wires fixed)" <<endl;
5153 - else if(sff->Status(ShapeExtend_DONE3))
5154 - cout << "(missing seam added)" <<endl;
5155 - else if(sff->Status(ShapeExtend_DONE4))
5156 - cout << "(small area wire removed)" <<endl;
5157 - else if(sff->Status(ShapeExtend_DONE5))
5158 - cout << "(natural bounds added)" <<endl;
5159 - TopoDS_Face newface = sff->Face();
5161 - rebuild->Replace(face, newface, Standard_False);
5164 - // Set the original colour of the face to the newly created
5165 - // face (after the healing process)
5166 - face = TopoDS::Face (exp0.Current());
5167 - face_colours->SetColor(face,face_colour,XCAFDoc_ColorSurf);
5169 - shape = rebuild->Apply(shape);
5174 - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
5175 - rebuild->Apply(shape);
5176 - for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
5178 - TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
5179 - if ( BRep_Tool::Degenerated(edge) )
5180 - rebuild->Remove(edge, false);
5182 - shape = rebuild->Apply(shape);
5186 - if (fixsmalledges)
5188 - cout << endl << "- fixing small edges" << endl;
5190 - Handle(ShapeFix_Wire) sfw;
5191 - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
5192 - rebuild->Apply(shape);
5195 - for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next())
5197 - TopoDS_Face face = TopoDS::Face(exp0.Current());
5199 - for (exp1.Init (face, TopAbs_WIRE); exp1.More(); exp1.Next())
5201 - TopoDS_Wire oldwire = TopoDS::Wire(exp1.Current());
5202 - sfw = new ShapeFix_Wire (oldwire, face ,tolerance);
5203 - sfw->ModifyTopologyMode() = Standard_True;
5205 - sfw->ClosedWireMode() = Standard_True;
5207 - bool replace = false;
5209 - replace = sfw->FixReorder() || replace;
5211 - replace = sfw->FixConnected() || replace;
5215 - if (sfw->FixSmall (Standard_False, tolerance) && ! (sfw->StatusSmall(ShapeExtend_FAIL1) ||
5216 - sfw->StatusSmall(ShapeExtend_FAIL2) ||
5217 - sfw->StatusSmall(ShapeExtend_FAIL3)))
5219 - cout << "Fixed small edge in wire " << wmap.FindIndex (oldwire) << endl;
5223 - else if (sfw->StatusSmall(ShapeExtend_FAIL1))
5224 - cerr << "Failed to fix small edge in wire " << wmap.FindIndex (oldwire)
5225 - << ", edge cannot be checked (no 3d curve and no pcurve)" << endl;
5226 - else if (sfw->StatusSmall(ShapeExtend_FAIL2))
5227 - cerr << "Failed to fix small edge in wire " << wmap.FindIndex (oldwire)
5228 - << ", edge is null-length and has different vertives at begin and end, and lockvtx is True or ModifiyTopologyMode is False" << endl;
5229 - else if (sfw->StatusSmall(ShapeExtend_FAIL3))
5230 - cerr << "Failed to fix small edge in wire " << wmap.FindIndex (oldwire)
5231 - << ", CheckConnected has failed" << endl;
5233 - replace = sfw->FixEdgeCurves() || replace;
5235 - replace = sfw->FixDegenerated() || replace;
5237 - replace = sfw->FixSelfIntersection() || replace;
5239 - replace = sfw->FixLacking(Standard_True) || replace;
5243 - TopoDS_Wire newwire = sfw->Wire();
5244 - rebuild->Replace(oldwire, newwire, Standard_False);
5247 - //delete sfw; sfw = NULL;
5252 - shape = rebuild->Apply(shape);
5258 - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
5259 - rebuild->Apply(shape);
5261 - for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
5263 - TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
5264 - if (vmap.FindIndex(TopExp::FirstVertex (edge)) ==
5265 - vmap.FindIndex(TopExp::LastVertex (edge)))
5267 - GProp_GProps system;
5268 - BRepGProp::LinearProperties(edge, system);
5269 - if (system.Mass() < tolerance)
5271 - cout << "removing degenerated edge " << emap.FindIndex(edge)
5272 - << " from vertex " << vmap.FindIndex(TopExp::FirstVertex (edge))
5273 - << " to vertex " << vmap.FindIndex(TopExp::LastVertex (edge)) << endl;
5274 - rebuild->Remove(edge, false);
5278 - shape = rebuild->Apply(shape);
5280 - //delete rebuild; rebuild = NULL;
5286 - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
5287 - rebuild->Apply(shape);
5288 - for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
5290 - TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
5291 - if ( BRep_Tool::Degenerated(edge) )
5292 - rebuild->Remove(edge, false);
5294 - shape = rebuild->Apply(shape);
5300 - Handle(ShapeFix_Wireframe) sfwf = new ShapeFix_Wireframe;
5301 - sfwf->SetPrecision(tolerance);
5302 - sfwf->Load (shape);
5303 - sfwf->ModeDropSmallEdges() = Standard_True;
5305 - sfwf->SetPrecision(boundingbox.Diam());
5307 - if (sfwf->FixWireGaps())
5309 - cout << endl << "- fixing wire gaps" << endl;
5310 - if (sfwf->StatusWireGaps(ShapeExtend_OK)) cout << "no gaps found" << endl;
5311 - if (sfwf->StatusWireGaps(ShapeExtend_DONE1)) cout << "some 2D gaps fixed" << endl;
5312 - if (sfwf->StatusWireGaps(ShapeExtend_DONE2)) cout << "some 3D gaps fixed" << endl;
5313 - if (sfwf->StatusWireGaps(ShapeExtend_FAIL1)) cout << "failed to fix some 2D gaps" << endl;
5314 - if (sfwf->StatusWireGaps(ShapeExtend_FAIL2)) cout << "failed to fix some 3D gaps" << endl;
5317 - sfwf->SetPrecision(tolerance);
5321 - for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
5323 - TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
5324 - if ( BRep_Tool::Degenerated(edge) )
5325 - cout << "degenerated edge at position 4" << endl;
5331 - if (sfwf->FixSmallEdges())
5333 - cout << endl << "- fixing wire frames" << endl;
5334 - if (sfwf->StatusSmallEdges(ShapeExtend_OK)) cout << "no small edges found" << endl;
5335 - if (sfwf->StatusSmallEdges(ShapeExtend_DONE1)) cout << "some small edges fixed" << endl;
5336 - if (sfwf->StatusSmallEdges(ShapeExtend_FAIL1)) cout << "failed to fix some small edges" << endl;
5341 - shape = sfwf->Shape();
5343 - //delete sfwf; sfwf = NULL;
5344 - //delete rebuild; rebuild = NULL;
5353 - for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
5355 - TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
5356 - if ( BRep_Tool::Degenerated(edge) )
5357 - cout << "degenerated edge at position 5" << endl;
5364 - if (fixspotstripfaces)
5367 - cout << endl << "- fixing spot and strip faces" << endl;
5368 - Handle(ShapeFix_FixSmallFace) sffsm = new ShapeFix_FixSmallFace();
5369 - sffsm -> Init (shape);
5370 - sffsm -> SetPrecision (tolerance);
5371 - sffsm -> Perform();
5373 - shape = sffsm -> FixShape();
5374 - //delete sffsm; sffsm = NULL;
5379 - for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
5381 - TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
5382 - if ( BRep_Tool::Degenerated(edge) )
5383 - cout << "degenerated edge at position 6" << endl;
5391 - cout << endl << "- sewing faces" << endl;
5393 - BRepOffsetAPI_Sewing sewedObj(tolerance);
5395 - for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next())
5397 - TopoDS_Face face = TopoDS::Face (exp0.Current());
5398 - sewedObj.Add (face);
5401 - sewedObj.Perform();
5403 - if (!sewedObj.SewedShape().IsNull())
5404 - shape = sewedObj.SewedShape();
5406 - cout << " not possible";
5412 - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
5413 - rebuild->Apply(shape);
5414 - for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
5416 - TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
5417 - if ( BRep_Tool::Degenerated(edge) )
5418 - rebuild->Remove(edge, false);
5420 - shape = rebuild->Apply(shape);
5426 - cout << endl << "- making solids" << endl;
5428 - BRepBuilderAPI_MakeSolid ms;
5430 - for (exp0.Init(shape, TopAbs_SHELL); exp0.More(); exp0.Next())
5433 - ms.Add (TopoDS::Shell(exp0.Current()));
5438 - cout << " not possible (no shells)" << endl;
5442 - BRepCheck_Analyzer ba(ms);
5443 - if (ba.IsValid ())
5445 - Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
5447 - sfs->SetPrecision(tolerance);
5448 - sfs->SetMaxTolerance(tolerance);
5450 - shape = sfs->Shape();
5452 - for (exp0.Init(shape, TopAbs_SOLID); exp0.More(); exp0.Next())
5454 - TopoDS_Solid solid = TopoDS::Solid(exp0.Current());
5455 - TopoDS_Solid newsolid = solid;
5456 - BRepLib::OrientClosedSolid (newsolid);
5457 - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
5458 - // rebuild->Apply(shape);
5459 - rebuild->Replace(solid, newsolid, Standard_False);
5460 - TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_COMPSOLID);//, 1);
5461 - // TopoDS_Shape newshape = rebuild->Apply(shape);
5465 - //delete sfs; sfs = NULL;
5468 - cout << " not possible" << endl;
5474 - if (splitpartitions)
5476 - cout << "- running SALOME partition splitter" << endl;
5478 - TopExp_Explorer e2;
5479 - Partition_Spliter ps;
5482 - for (e2.Init (shape, TopAbs_SOLID);
5483 - e2.More(); e2.Next())
5486 - ps.AddShape (e2.Current());
5490 - shape = ps.Shape();
5492 - cout << " before: " << count << " solids" << endl;
5495 - for (e2.Init (shape, TopAbs_SOLID);
5496 - e2.More(); e2.Next()) count++;
5498 - cout << " after : " << count << " solids" << endl;
5506 - for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
5508 - TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
5509 - if ( BRep_Tool::Degenerated(edge) )
5510 - cout << "degenerated edge at position 8" << endl;
5515 - double newsurfacecont = 0;
5518 - for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next())
5520 - TopoDS_Face face = TopoDS::Face(exp0.Current());
5521 - GProp_GProps system;
5522 - BRepGProp::SurfaceProperties(face, system);
5523 - newsurfacecont += system.Mass();
5527 - int nnrc = 0, nnrcs = 0,
5528 - nnrso = somap.Extent(),
5529 - nnrsh = shmap.Extent(),
5530 - nnrf = fmap.Extent(),
5531 - nnrw = wmap.Extent(),
5532 - nnre = emap.Extent(),
5533 - nnrv = vmap.Extent();
5535 - for (exp0.Init(shape, TopAbs_COMPOUND); exp0.More(); exp0.Next()) nnrc++;
5536 - for (exp0.Init(shape, TopAbs_COMPSOLID); exp0.More(); exp0.Next()) nnrcs++;
5538 - cout << "-----------------------------------" << endl;
5539 - cout << "Compounds : " << nnrc << " (" << nrc << ")" << endl;
5540 - cout << "Composite solids: " << nnrcs << " (" << nrcs << ")" << endl;
5541 - cout << "Solids : " << nnrso << " (" << nrso << ")" << endl;
5542 - cout << "Shells : " << nnrsh << " (" << nrsh << ")" << endl;
5543 - cout << "Wires : " << nnrw << " (" << nrw << ")" << endl;
5544 - cout << "Faces : " << nnrf << " (" << nrf << ")" << endl;
5545 - cout << "Edges : " << nnre << " (" << nre << ")" << endl;
5546 - cout << "Vertices : " << nnrv << " (" << nrv << ")" << endl;
5548 - cout << "Totol surface area : " << newsurfacecont << " (" << surfacecont << ")" << endl;
5555 - void OCCGeometry :: BuildFMap()
5564 - TopExp_Explorer exp0, exp1, exp2, exp3, exp4, exp5;
5566 - for (exp0.Init(shape, TopAbs_COMPOUND);
5567 - exp0.More(); exp0.Next())
5569 - TopoDS_Compound compound = TopoDS::Compound (exp0.Current());
5570 - (*testout) << "compound" << endl;
5572 - for (exp1.Init(compound, TopAbs_SHELL);
5573 - exp1.More(); exp1.Next())
5575 - (*testout) << "shell " << ++i << endl;
5579 - for (exp0.Init(shape, TopAbs_SOLID);
5580 - exp0.More(); exp0.Next())
5582 - TopoDS_Solid solid = TopoDS::Solid (exp0.Current());
5584 - if (somap.FindIndex(solid) < 1)
5586 - somap.Add (solid);
5588 - for (exp1.Init(solid, TopAbs_SHELL);
5589 - exp1.More(); exp1.Next())
5591 - TopoDS_Shell shell = TopoDS::Shell (exp1.Current());
5592 - if (shmap.FindIndex(shell) < 1)
5594 - shmap.Add (shell);
5596 - for (exp2.Init(shell, TopAbs_FACE);
5597 - exp2.More(); exp2.Next())
5599 - TopoDS_Face face = TopoDS::Face(exp2.Current());
5600 - if (fmap.FindIndex(face) < 1)
5603 - (*testout) << "face " << fmap.FindIndex(face) << " ";
5604 - (*testout) << ((face.Orientation() == TopAbs_REVERSED) ? "-" : "+") << ", ";
5605 - (*testout) << ((exp2.Current().Orientation() == TopAbs_REVERSED) ? "-" : "+") << endl;
5606 - for (exp3.Init(exp2.Current(), TopAbs_WIRE);
5607 - exp3.More(); exp3.Next())
5609 - TopoDS_Wire wire = TopoDS::Wire (exp3.Current());
5610 - if (wmap.FindIndex(wire) < 1)
5614 - for (exp4.Init(exp3.Current(), TopAbs_EDGE);
5615 - exp4.More(); exp4.Next())
5617 - TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
5618 - if (emap.FindIndex(edge) < 1)
5621 - for (exp5.Init(exp4.Current(), TopAbs_VERTEX);
5622 - exp5.More(); exp5.Next())
5624 - TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
5625 - if (vmap.FindIndex(vertex) < 1)
5626 - vmap.Add (vertex);
5640 - for (exp1.Init(shape, TopAbs_SHELL, TopAbs_SOLID); exp1.More(); exp1.Next())
5642 - TopoDS_Shell shell = TopoDS::Shell(exp1.Current());
5643 - if (shmap.FindIndex(shell) < 1)
5645 - shmap.Add (shell);
5647 - (*testout) << "shell " << shmap.FindIndex(shell) << " ";
5648 - (*testout) << ((shell.Orientation() == TopAbs_REVERSED) ? "-" : "+") << ", ";
5649 - (*testout) << ((exp1.Current().Orientation() == TopAbs_REVERSED) ? "-" : "+") << endl;
5651 - for (exp2.Init(shell, TopAbs_FACE); exp2.More(); exp2.Next())
5653 - TopoDS_Face face = TopoDS::Face(exp2.Current());
5654 - if (fmap.FindIndex(face) < 1)
5658 - for (exp3.Init(face, TopAbs_WIRE); exp3.More(); exp3.Next())
5660 - TopoDS_Wire wire = TopoDS::Wire (exp3.Current());
5661 - if (wmap.FindIndex(wire) < 1)
5665 - for (exp4.Init(wire, TopAbs_EDGE); exp4.More(); exp4.Next())
5667 - TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
5668 - if (emap.FindIndex(edge) < 1)
5671 - for (exp5.Init(edge, TopAbs_VERTEX); exp5.More(); exp5.Next())
5673 - TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
5674 - if (vmap.FindIndex(vertex) < 1)
5675 - vmap.Add (vertex);
5689 - for (exp2.Init(shape, TopAbs_FACE, TopAbs_SHELL); exp2.More(); exp2.Next())
5691 - TopoDS_Face face = TopoDS::Face(exp2.Current());
5692 - if (fmap.FindIndex(face) < 1)
5696 - for (exp3.Init(exp2.Current(), TopAbs_WIRE); exp3.More(); exp3.Next())
5698 - TopoDS_Wire wire = TopoDS::Wire (exp3.Current());
5699 - if (wmap.FindIndex(wire) < 1)
5703 - for (exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next())
5705 - TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
5706 - if (emap.FindIndex(edge) < 1)
5709 - for (exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next())
5711 - TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
5712 - if (vmap.FindIndex(vertex) < 1)
5713 - vmap.Add (vertex);
5725 - for (exp3.Init(shape, TopAbs_WIRE, TopAbs_FACE); exp3.More(); exp3.Next())
5727 - TopoDS_Wire wire = TopoDS::Wire (exp3.Current());
5728 - if (wmap.FindIndex(wire) < 1)
5732 - for (exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next())
5734 - TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
5735 - if (emap.FindIndex(edge) < 1)
5738 - for (exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next())
5740 - TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
5741 - if (vmap.FindIndex(vertex) < 1)
5742 - vmap.Add (vertex);
5752 - for (exp4.Init(shape, TopAbs_EDGE, TopAbs_WIRE); exp4.More(); exp4.Next())
5754 - TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
5755 - if (emap.FindIndex(edge) < 1)
5758 - for (exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next())
5760 - TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
5761 - if (vmap.FindIndex(vertex) < 1)
5762 - vmap.Add (vertex);
5770 - for (exp5.Init(shape, TopAbs_VERTEX, TopAbs_EDGE); exp5.More(); exp5.Next())
5772 - TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
5773 - if (vmap.FindIndex(vertex) < 1)
5774 - vmap.Add (vertex);
5780 - facemeshstatus.DeleteAll();
5781 - facemeshstatus.SetSize (fmap.Extent());
5782 - facemeshstatus = 0;
5784 - // Philippose - 15/01/2009
5785 - face_maxh.DeleteAll();
5786 - face_maxh.SetSize (fmap.Extent());
5787 - face_maxh = mparam.maxh;
5789 - // Philippose - 15/01/2010
5790 - face_maxh_modified.DeleteAll();
5791 - face_maxh_modified.SetSize(fmap.Extent());
5792 - face_maxh_modified = 0;
5795 - // Philippose - 17/01/2009
5796 - face_sel_status.DeleteAll();
5797 - face_sel_status.SetSize (fmap.Extent());
5798 - face_sel_status = 0;
5800 - fvispar.SetSize (fmap.Extent());
5801 - evispar.SetSize (emap.Extent());
5802 - vvispar.SetSize (vmap.Extent());
5804 - fsingular.SetSize (fmap.Extent());
5805 - esingular.SetSize (emap.Extent());
5806 - vsingular.SetSize (vmap.Extent());
5808 - fsingular = esingular = vsingular = false;
5813 - void OCCGeometry :: SewFaces ()
5815 - (*testout) << "Trying to sew faces ..." << endl;
5816 - cout << "Trying to sew faces ..." << flush;
5818 - BRepOffsetAPI_Sewing sewedObj(1);
5820 - for (int i = 1; i <= fmap.Extent(); i++)
5822 - TopoDS_Face face = TopoDS::Face (fmap(i));
5823 - sewedObj.Add (face);
5826 - sewedObj.Perform();
5828 - if (!sewedObj.SewedShape().IsNull())
5830 - shape = sewedObj.SewedShape();
5831 - cout << " done" << endl;
5834 - cout << " not possible";
5841 - void OCCGeometry :: MakeSolid ()
5843 - TopExp_Explorer exp0;
5845 - (*testout) << "Trying to build solids ..." << endl;
5846 - cout << "Trying to build solids ..." << flush;
5848 - BRepBuilderAPI_MakeSolid ms;
5850 - for (exp0.Init(shape, TopAbs_SHELL); exp0.More(); exp0.Next())
5853 - ms.Add (TopoDS::Shell(exp0.Current()));
5858 - cout << " not possible (no shells)" << endl;
5862 - BRepCheck_Analyzer ba(ms);
5863 - if (ba.IsValid ())
5865 - Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
5868 - sfs->SetPrecision(1e-5);
5869 - sfs->SetMaxTolerance(1e-5);
5873 - shape = sfs->Shape();
5875 - for (exp0.Init(shape, TopAbs_SOLID); exp0.More(); exp0.Next())
5877 - TopoDS_Solid solid = TopoDS::Solid(exp0.Current());
5878 - TopoDS_Solid newsolid = solid;
5879 - BRepLib::OrientClosedSolid (newsolid);
5880 - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
5881 - rebuild->Replace(solid, newsolid, Standard_False);
5883 - TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_SHAPE, 1);
5887 - cout << " done" << endl;
5890 - cout << " not possible" << endl;
5896 - void OCCGeometry :: BuildVisualizationMesh (double deflection)
5898 - cout << "Preparing visualization (deflection = " << deflection << ") ... " << flush;
5900 - BRepTools::Clean (shape);
5901 - // BRepMesh_IncrementalMesh::
5902 - BRepMesh_IncrementalMesh (shape, deflection, true);
5903 - cout << "done" << endl;
5909 - void OCCGeometry :: CalcBoundingBox ()
5912 - BRepBndLib::Add (shape, bb);
5914 - double x1,y1,z1,x2,y2,z2;
5915 - bb.Get (x1,y1,z1,x2,y2,z2);
5916 - Point<3> p1 = Point<3> (x1,y1,z1);
5917 - Point<3> p2 = Point<3> (x2,y2,z2);
5919 - (*testout) << "Bounding Box = [" << p1 << " - " << p2 << "]" << endl;
5920 - boundingbox = Box<3> (p1,p2);
5927 - void OCCGeometry :: Project (int surfi, Point<3> & p) const
5929 - static int cnt = 0;
5930 - if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl;
5932 - gp_Pnt pnt(p(0), p(1), p(2));
5935 - Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
5936 - Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
5937 - gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
5938 - suval.Coord( u, v);
5939 - pnt = thesurf->Value( u, v );
5942 - p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
5949 - bool OCCGeometry :: FastProject (int surfi, Point<3> & ap, double& u, double& v) const
5951 - gp_Pnt p(ap(0), ap(1), ap(2));
5953 - Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
5955 - gp_Pnt x = surface->Value (u,v);
5957 - if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
5961 - surface->D1(u,v,x,du,dv);
5967 - double det, lambda, mu;
5974 - det = Det3 (n.X(), du.X(), dv.X(),
5975 - n.Y(), du.Y(), dv.Y(),
5976 - n.Z(), du.Z(), dv.Z());
5978 - if (det < 1e-15) return false;
5980 - lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
5981 - n.Y(), p.Y()-x.Y(), dv.Y(),
5982 - n.Z(), p.Z()-x.Z(), dv.Z())/det;
5984 - mu = Det3 (n.X(), du.X(), p.X()-x.X(),
5985 - n.Y(), du.Y(), p.Y()-x.Y(),
5986 - n.Z(), du.Z(), p.Z()-x.Z())/det;
5992 - surface->D1(u,v,x,du,dv);
5994 - } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
5996 - // (*testout) << "FastProject count: " << count << endl;
5998 - if (count == 50) return false;
6000 - ap = Point<3> (x.X(), x.Y(), x.Z());
6008 - void OCCGeometry :: WriteOCC_STL(char * filename)
6010 - cout << "writing stl..."; cout.flush();
6011 - StlAPI_Writer writer;
6012 - writer.RelativeMode() = Standard_False;
6014 - writer.SetDeflection(0.02);
6015 - writer.Write(shape,filename);
6017 - cout << "done" << endl;
6022 - // Philippose - 23/02/2009
6023 - /* Special IGES File load function including the ability
6024 - to extract individual surface colours via the extended
6025 - OpenCascade XDE and XCAF Feature set.
6027 - OCCGeometry *LoadOCC_IGES(const char *filename)
6029 - OCCGeometry *occgeo;
6030 - occgeo = new OCCGeometry;
6032 - // Initiate a dummy XCAF Application to handle the IGES XCAF Document
6033 - static Handle_XCAFApp_Application dummy_app = XCAFApp_Application::GetApplication();
6035 - // Create an XCAF Document to contain the IGES file itself
6036 - Handle_TDocStd_Document iges_doc;
6038 - // Check if a IGES File is already open under this handle, if so, close it to prevent
6039 - // Segmentation Faults when trying to create a new document
6040 - if(dummy_app->NbDocuments() > 0)
6042 - dummy_app->GetDocument(1,iges_doc);
6043 - dummy_app->Close(iges_doc);
6045 - dummy_app->NewDocument ("IGES-XCAF",iges_doc);
6047 - IGESCAFControl_Reader reader;
6049 - Standard_Integer stat = reader.ReadFile((char*)filename);
6051 - if(stat != IFSelect_RetDone)
6057 - // Enable transfer of colours
6058 - reader.SetColorMode(Standard_True);
6060 - reader.Transfer(iges_doc);
6062 - // Read in the shape(s) and the colours present in the IGES File
6063 - Handle_XCAFDoc_ShapeTool iges_shape_contents = XCAFDoc_DocumentTool::ShapeTool(iges_doc->Main());
6064 - Handle_XCAFDoc_ColorTool iges_colour_contents = XCAFDoc_DocumentTool::ColorTool(iges_doc->Main());
6066 - TDF_LabelSequence iges_shapes;
6067 - iges_shape_contents->GetShapes(iges_shapes);
6069 - // List out the available colours in the IGES File as Colour Names
6070 - TDF_LabelSequence all_colours;
6071 - iges_colour_contents->GetColors(all_colours);
6072 - PrintMessage(1,"Number of colours in IGES File: ",all_colours.Length());
6073 - for(int i = 1; i <= all_colours.Length(); i++)
6075 - Quantity_Color col;
6076 - stringstream col_rgb;
6077 - iges_colour_contents->GetColor(all_colours.Value(i),col);
6078 - col_rgb << " : (" << col.Red() << "," << col.Green() << "," << col.Blue() << ")";
6079 - PrintMessage(1, "Colour [", i, "] = ",col.StringName(col.Name()),col_rgb.str());
6083 - // For the IGES Reader, all the shapes can be exported as one compund shape
6084 - // using the "OneShape" member
6085 - occgeo->shape = reader.OneShape();
6086 - occgeo->face_colours = iges_colour_contents;
6087 - occgeo->changed = 1;
6088 - occgeo->BuildFMap();
6090 - occgeo->CalcBoundingBox();
6091 - PrintContents (occgeo);
6100 - // Philippose - 29/01/2009
6101 - /* Special STEP File load function including the ability
6102 - to extract individual surface colours via the extended
6103 - OpenCascade XDE and XCAF Feature set.
6105 - OCCGeometry * LoadOCC_STEP (const char * filename)
6107 - OCCGeometry * occgeo;
6108 - occgeo = new OCCGeometry;
6110 - // Initiate a dummy XCAF Application to handle the STEP XCAF Document
6111 - static Handle_XCAFApp_Application dummy_app = XCAFApp_Application::GetApplication();
6113 - // Create an XCAF Document to contain the STEP file itself
6114 - Handle_TDocStd_Document step_doc;
6116 - // Check if a STEP File is already open under this handle, if so, close it to prevent
6117 - // Segmentation Faults when trying to create a new document
6118 - if(dummy_app->NbDocuments() > 0)
6120 - dummy_app->GetDocument(1,step_doc);
6121 - dummy_app->Close(step_doc);
6123 - dummy_app->NewDocument ("STEP-XCAF",step_doc);
6125 - STEPCAFControl_Reader reader;
6127 - // Enable transfer of colours
6128 - reader.SetColorMode(Standard_True);
6130 - Standard_Integer stat = reader.ReadFile((char*)filename);
6132 - if(stat != IFSelect_RetDone)
6138 - reader.Transfer(step_doc);
6140 - // Read in the shape(s) and the colours present in the STEP File
6141 - Handle_XCAFDoc_ShapeTool step_shape_contents = XCAFDoc_DocumentTool::ShapeTool(step_doc->Main());
6142 - Handle_XCAFDoc_ColorTool step_colour_contents = XCAFDoc_DocumentTool::ColorTool(step_doc->Main());
6144 - TDF_LabelSequence step_shapes;
6145 - step_shape_contents->GetShapes(step_shapes);
6147 - // List out the available colours in the STEP File as Colour Names
6148 - TDF_LabelSequence all_colours;
6149 - step_colour_contents->GetColors(all_colours);
6150 - PrintMessage(1,"Number of colours in STEP File: ",all_colours.Length());
6151 - for(int i = 1; i <= all_colours.Length(); i++)
6153 - Quantity_Color col;
6154 - stringstream col_rgb;
6155 - step_colour_contents->GetColor(all_colours.Value(i),col);
6156 - col_rgb << " : (" << col.Red() << "," << col.Green() << "," << col.Blue() << ")";
6157 - PrintMessage(1, "Colour [", i, "] = ",col.StringName(col.Name()),col_rgb.str());
6161 - // For the STEP File Reader in OCC, the 1st Shape contains the entire
6162 - // compound geometry as one shape
6163 - occgeo->shape = step_shape_contents->GetShape(step_shapes.Value(1));
6164 - occgeo->face_colours = step_colour_contents;
6165 - occgeo->changed = 1;
6166 - occgeo->BuildFMap();
6168 - occgeo->CalcBoundingBox();
6169 - PrintContents (occgeo);
6177 - OCCGeometry *LoadOCC_BREP (const char *filename)
6179 - OCCGeometry * occgeo;
6180 - occgeo = new OCCGeometry;
6182 - BRep_Builder aBuilder;
6183 - Standard_Boolean result = BRepTools::Read(occgeo->shape, const_cast<char*> (filename),aBuilder);
6191 - // Philippose - 23/02/2009
6192 - // Fixed a bug in the OpenCascade XDE Colour handling when
6193 - // opening BREP Files, since BREP Files have no colour data.
6194 - // Hence, the face_colours Handle needs to be created as a NULL handle.
6195 - occgeo->face_colours = Handle_XCAFDoc_ColorTool();
6196 - occgeo->face_colours.Nullify();
6197 - occgeo->changed = 1;
6198 - occgeo->BuildFMap();
6200 - occgeo->CalcBoundingBox();
6201 - PrintContents (occgeo);
6207 - void OCCGeometry :: Save (string sfilename) const
6209 - const char * filename = sfilename.c_str();
6210 - if (strlen(filename) < 4)
6211 - throw NgException ("illegal filename");
6213 - if (strcmp (&filename[strlen(filename)-3], "igs") == 0)
6215 - IGESControl_Writer writer("millimeters", 1);
6216 - writer.AddShape (shape);
6217 - writer.Write (filename);
6219 - else if (strcmp (&filename[strlen(filename)-3], "stp") == 0)
6221 - STEPControl_Writer writer;
6222 - writer.Transfer (shape, STEPControl_AsIs);
6223 - writer.Write (filename);
6225 - else if (strcmp (&filename[strlen(filename)-3], "stl") == 0)
6227 - StlAPI_Writer writer;
6228 - writer.ASCIIMode() = Standard_True;
6229 - writer.Write (shape, filename);
6231 - else if (strcmp (&filename[strlen(filename)-4], "stlb") == 0)
6233 - StlAPI_Writer writer;
6234 - writer.ASCIIMode() = Standard_False;
6235 - writer.Write (shape, filename);
6241 - const char * shapesname[] =
6242 - {" ", "CompSolids", "Solids", "Shells",
6244 - "Faces", "Wires", "Edges", "Vertices"};
6246 - const char * shapename[] =
6247 - {" ", "CompSolid", "Solid", "Shell",
6248 - "Face", "Wire", "Edge", "Vertex"};
6250 - const char * orientationstring[] =
6256 - void OCCGeometry :: RecursiveTopologyTree (const TopoDS_Shape & sh,
6257 - stringstream & str,
6258 - TopAbs_ShapeEnum l,
6260 - const char * lname)
6262 - if (l > TopAbs_VERTEX) return;
6264 - TopExp_Explorer e;
6269 - e.Init(sh, l, TopAbs_ShapeEnum(l-1));
6273 - for (; e.More(); e.Next())
6277 - stringstream lname2;
6278 - lname2 << lname << "/" << shapename[l] << count;
6279 - str << lname2.str() << " ";
6281 - switch (e.Current().ShapeType())
6283 - case TopAbs_SOLID:
6284 - count2 = somap.FindIndex(TopoDS::Solid(e.Current())); break;
6285 - case TopAbs_SHELL:
6286 - count2 = shmap.FindIndex(TopoDS::Shell(e.Current())); break;
6288 - count2 = fmap.FindIndex(TopoDS::Face(e.Current())); break;
6290 - count2 = wmap.FindIndex(TopoDS::Wire(e.Current())); break;
6292 - count2 = emap.FindIndex(TopoDS::Edge(e.Current())); break;
6293 - case TopAbs_VERTEX:
6294 - count2 = vmap.FindIndex(TopoDS::Vertex(e.Current())); break;
6296 - cout << "RecursiveTopologyTree: Case " << e.Current().ShapeType() << " not handeled" << endl;
6299 - int nrsubshapes = 0;
6301 - if (l <= TopAbs_WIRE)
6303 - TopExp_Explorer e2;
6304 - for (e2.Init (e.Current(), TopAbs_ShapeEnum (l+1));
6305 - e2.More(); e2.Next())
6309 - str << "{" << shapename[l] << " " << count2;
6311 - if (l <= TopAbs_EDGE)
6313 - str << " (" << orientationstring[e.Current().Orientation()];
6314 - if (nrsubshapes != 0) str << ", " << nrsubshapes;
6320 - RecursiveTopologyTree (e.Current(), str, TopAbs_ShapeEnum (l+1),
6321 - false, (char*)lname2.str().c_str());
6329 - void OCCGeometry :: GetTopologyTree (stringstream & str)
6331 - cout << "Building topology tree ... " << flush;
6332 - RecursiveTopologyTree (shape, str, TopAbs_COMPSOLID, false, "CompSolids");
6333 - RecursiveTopologyTree (shape, str, TopAbs_SOLID, true, "FreeSolids");
6334 - RecursiveTopologyTree (shape, str, TopAbs_SHELL, true, "FreeShells");
6335 - RecursiveTopologyTree (shape, str, TopAbs_FACE, true, "FreeFaces");
6336 - RecursiveTopologyTree (shape, str, TopAbs_WIRE, true, "FreeWires");
6337 - RecursiveTopologyTree (shape, str, TopAbs_EDGE, true, "FreeEdges");
6338 - RecursiveTopologyTree (shape, str, TopAbs_VERTEX, true, "FreeVertices");
6340 - // cout << "done" << endl;
6346 - void OCCGeometry :: CheckIrregularEntities(stringstream & str)
6348 - ShapeAnalysis_CheckSmallFace csm;
6350 - csm.SetTolerance (1e-6);
6352 - TopTools_DataMapOfShapeListOfShape mapEdges;
6353 - ShapeAnalysis_DataMapOfShapeListOfReal mapParam;
6354 - TopoDS_Compound theAllVert;
6356 - int spotfaces = 0;
6357 - int stripsupportfaces = 0;
6358 - int singlestripfaces = 0;
6359 - int stripfaces = 0;
6360 - int facessplitbyvertices = 0;
6361 - int stretchedpinfaces = 0;
6362 - int smoothpinfaces = 0;
6363 - int twistedfaces = 0;
6364 - // int edgessamebutnotidentified = 0;
6366 - cout << "checking faces ... " << flush;
6369 - for (i = 1; i <= fmap.Extent(); i++)
6371 - TopoDS_Face face = TopoDS::Face (fmap(i));
6372 - TopoDS_Edge e1, e2;
6374 - if (csm.CheckSpotFace (face))
6377 - str << "SpotFace {Spot face} ";
6379 - (*testout) << "Face " << i << " is a spot face" << endl;
6380 - str << "SpotFace/Face" << i << " ";
6381 - str << "{Face " << i << " } ";
6384 - if (csm.IsStripSupport (face))
6386 - if (!stripsupportfaces++)
6387 - str << "StripSupportFace {Strip support face} ";
6389 - (*testout) << "Face " << i << " has strip support" << endl;
6390 - str << "StripSupportFace/Face" << i << " ";
6391 - str << "{Face " << i << " } ";
6394 - if (csm.CheckSingleStrip(face, e1, e2))
6396 - if (!singlestripfaces++)
6397 - str << "SingleStripFace {Single strip face} ";
6399 - (*testout) << "Face " << i << " is a single strip (edge " << emap.FindIndex(e1)
6400 - << " and edge " << emap.FindIndex(e2) << " are identical)" << endl;
6401 - str << "SingleStripFace/Face" << i << " ";
6402 - str << "{Face " << i << " (edge " << emap.FindIndex(e1)
6403 - << " and edge " << emap.FindIndex(e2) << " are identical)} ";
6406 - if (csm.CheckStripFace(face, e1, e2))
6408 - if (!stripfaces++)
6409 - str << "StripFace {Strip face} ";
6411 - (*testout) << "Face " << i << " is a strip (edge " << emap.FindIndex(e1)
6412 - << " and edge " << emap.FindIndex(e2)
6413 - << " are identical)" << endl;
6414 - str << "StripFace/Face" << i << " ";
6415 - str << "{Face " << i << " (edge " << emap.FindIndex(e1)
6416 - << " and edge " << emap.FindIndex(e2) << " are identical)} ";
6419 - if (int count = csm.CheckSplittingVertices(face, mapEdges, mapParam, theAllVert))
6421 - if (!facessplitbyvertices++)
6422 - str << "FaceSplitByVertices {Face split by vertices} ";
6424 - (*testout) << "Face " << i << " is split by " << count
6425 - << " vertex/vertices " << endl;
6426 - str << "FaceSplitByVertices/Face" << i << " ";
6427 - str << "{Face " << i << " (split by " << count << "vertex/vertices)} ";
6430 - int whatrow, sens;
6431 - if (int type = csm.CheckPin (face, whatrow, sens))
6435 - if (!smoothpinfaces++)
6436 - str << "SmoothPinFace {Smooth pin face} ";
6438 - (*testout) << "Face " << i << " is a smooth pin" << endl;
6439 - str << "SmoothPinFace/Face" << i << " ";
6440 - str << "{Face " << i << " } ";
6444 - if (!stretchedpinfaces++)
6445 - str << "StretchedPinFace {Stretched pin face} ";
6447 - (*testout) << "Face " << i << " is a streched pin" << endl;
6448 - str << "StretchedPinFace/Face" << i << " ";
6449 - str << "{Face " << i << " } ";
6453 - double paramu, paramv;
6454 - if (csm.CheckTwisted (face, paramu, paramv))
6456 - if (!twistedfaces++)
6457 - str << "TwistedFace {Twisted face} ";
6459 - (*testout) << "Face " << i << " is twisted" << endl;
6460 - str << "TwistedFace/Face" << i << " ";
6461 - str << "{Face " << i << " } ";
6465 - cout << "done" << endl;
6466 - cout << "checking edges ... " << flush;
6470 - Array <double> edgeLengths;
6471 - Array <int> order;
6472 - edgeLengths.SetSize (emap.Extent());
6473 - order.SetSize (emap.Extent());
6475 - for (i = 1; i <= emap.Extent(); i++)
6477 - TopoDS_Edge edge1 = TopoDS::Edge (emap(i));
6478 - GProp_GProps system;
6479 - BRepGProp::LinearProperties(edge1, system);
6480 - edgeLengths[i-1] = system.Mass();
6483 - Sort (edgeLengths, order);
6485 - str << "ShortestEdges {Shortest edges} ";
6486 - for (i = 1; i <= min(20, emap.Extent()); i++)
6488 - str << "ShortestEdges/Edge" << i;
6489 - str << " {Edge " << order[i-1] << " (L=" << edgeLengths[order[i-1]-1] << ")} ";
6494 - cout << "done" << endl;
6500 - void OCCGeometry :: GetUnmeshedFaceInfo (stringstream & str)
6502 - for (int i = 1; i <= fmap.Extent(); i++)
6504 - if (facemeshstatus[i-1] == -1)
6505 - str << "Face" << i << " {Face " << i << " } ";
6513 - void OCCGeometry :: GetNotDrawableFaces (stringstream & str)
6515 - for (int i = 1; i <= fmap.Extent(); i++)
6517 - if (!fvispar[i-1].IsDrawable())
6518 - str << "Face" << i << " {Face " << i << " } ";
6526 - bool OCCGeometry :: ErrorInSurfaceMeshing ()
6528 - for (int i = 1; i <= fmap.Extent(); i++)
6529 - if (facemeshstatus[i-1] == -1)
6538 - int OCCGeometry :: GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
6539 - int perfstepsstart, int perfstepsend)
6541 - return OCCGenerateMesh (*this, mesh, mparam, perfstepsstart, perfstepsend);
6547 - const Refinement & OCCGeometry :: GetRefinement () const
6549 - return * new OCCRefinementSurfaces (*this);
6555 - OCCParameters :: OCCParameters()
6557 - resthcloseedgefac = 1;
6558 - resthcloseedgeenable = 1;
6559 - resthminedgelen = 0.001;
6560 - resthminedgelenenable = 1;
6566 - void OCCParameters :: Print(ostream & ost) const
6568 - ost << "OCC Parameters:" << endl
6569 - << "close edges: " << resthcloseedgeenable
6570 - << ", fac = " << resthcloseedgefac << endl
6571 - << "minimum edge length: " << resthminedgelenenable
6572 - << ", min len = " << resthminedgelen << endl;
6578 - OCCParameters occparam;
6587 +#include <mystdlib.h>
6588 +#include <occgeom.hpp>
6589 +#include "ShapeAnalysis_ShapeTolerance.hxx"
6590 +#include "ShapeAnalysis_ShapeContents.hxx"
6591 +#include "ShapeAnalysis_CheckSmallFace.hxx"
6592 +#include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"
6593 +#include "ShapeAnalysis_Surface.hxx"
6594 +#include <BRepTopAdaptor_FClass2d.hxx> // -- to optimize Project() and FastProject()
6595 +#include <TopAbs_State.hxx>
6596 +#include "BRepAlgoAPI_Fuse.hxx"
6597 +#include "BRepCheck_Analyzer.hxx"
6598 +#include "BRepLib.hxx"
6599 +#include "ShapeBuild_ReShape.hxx"
6600 +#include "ShapeFix.hxx"
6601 +#include "ShapeFix_FixSmallFace.hxx"
6602 +#include "Partition_Spliter.hxx"
6606 + // free data used to optimize Project() and FastProject()
6607 + OCCGeometry::~OCCGeometry()
6609 + NCollection_DataMap<int,BRepTopAdaptor_FClass2d*>::Iterator it(fclsmap);
6610 + for (; it.More(); it.Next())
6611 + delete it.Value();
6614 + void OCCGeometry :: PrintNrShapes ()
6616 + TopExp_Explorer e;
6618 + for (e.Init(shape, TopAbs_COMPSOLID); e.More(); e.Next()) count++;
6619 + std::cout << "CompSolids: " << count << std::endl;
6621 + std::cout << "Solids : " << somap.Extent() << std::endl;
6622 + std::cout << "Shells : " << shmap.Extent() << std::endl;
6623 + std::cout << "Faces : " << fmap.Extent() << std::endl;
6624 + std::cout << "Edges : " << emap.Extent() << std::endl;
6625 + std::cout << "Vertices : " << vmap.Extent() << std::endl;
6631 + void PrintContents (OCCGeometry * geom)
6633 + ShapeAnalysis_ShapeContents cont;
6635 + cont.Perform(geom->shape);
6637 + (*testout) << "OCC CONTENTS" << std::endl;
6638 + (*testout) << "============" << std::endl;
6639 + (*testout) << "SOLIDS : " << cont.NbSolids() << std::endl;
6640 + (*testout) << "SHELLS : " << cont.NbShells() << std::endl;
6641 + (*testout) << "FACES : " << cont.NbFaces() << std::endl;
6642 + (*testout) << "WIRES : " << cont.NbWires() << std::endl;
6643 + (*testout) << "EDGES : " << cont.NbEdges() << std::endl;
6644 + (*testout) << "VERTICES : " << cont.NbVertices() << std::endl;
6646 + TopExp_Explorer e;
6648 + for (e.Init(geom->shape, TopAbs_COMPOUND); e.More(); e.Next())
6650 + (*testout) << "Compounds: " << count << std::endl;
6653 + for (e.Init(geom->shape, TopAbs_COMPSOLID); e.More(); e.Next())
6655 + (*testout) << "CompSolids: " << count << std::endl;
6657 + (*testout) << std::endl;
6659 + std::cout << "Highest entry in topology hierarchy: " << std::endl;
6661 + std::cout << count << " composite solid(s)" << std::endl;
6663 + if (geom->somap.Extent())
6664 + std::cout << geom->somap.Extent() << " solid(s)" << std::endl;
6666 + if (geom->shmap.Extent())
6667 + std::cout << geom->shmap.Extent() << " shells(s)" << std::endl;
6669 + if (geom->fmap.Extent())
6670 + std::cout << geom->fmap.Extent() << " face(s)" << std::endl;
6672 + if (geom->wmap.Extent())
6673 + std::cout << geom->wmap.Extent() << " wire(s)" << std::endl;
6675 + if (geom->emap.Extent())
6676 + std::cout << geom->emap.Extent() << " edge(s)" << std::endl;
6678 + if (geom->vmap.Extent())
6679 + std::cout << geom->vmap.Extent() << " vertices(s)" << std::endl;
6681 + std::cout << "no entities" << std::endl;
6687 + void OCCGeometry :: HealGeometry ()
6689 + int nrc = 0, nrcs = 0,
6690 + nrso = somap.Extent(),
6691 + nrsh = shmap.Extent(),
6692 + nrf = fmap.Extent(),
6693 + nrw = wmap.Extent(),
6694 + nre = emap.Extent(),
6695 + nrv = vmap.Extent();
6697 + TopExp_Explorer exp0;
6698 + TopExp_Explorer exp1;
6701 + for (exp0.Init(shape, TopAbs_COMPOUND); exp0.More(); exp0.Next()) nrc++;
6702 + for (exp0.Init(shape, TopAbs_COMPSOLID); exp0.More(); exp0.Next()) nrcs++;
6704 + double surfacecont = 0;
6707 + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
6708 + rebuild->Apply(shape);
6709 + for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
6711 + TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
6712 + if ( BRep_Tool::Degenerated(edge) )
6713 + rebuild->Remove(edge);
6715 + shape = rebuild->Apply(shape);
6721 + for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next())
6723 + TopoDS_Face face = TopoDS::Face(exp0.Current());
6725 + GProp_GProps system;
6726 + BRepGProp::SurfaceProperties(face, system);
6727 + surfacecont += system.Mass();
6731 + std::cout << "Starting geometry healing procedure (tolerance: " << tolerance << ")" << std::endl
6732 + << "-----------------------------------" << std::endl;
6735 + std::cout << std::endl << "- repairing faces" << std::endl;
6737 + Handle(ShapeFix_Face) sff;
6738 + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
6739 + rebuild->Apply(shape);
6742 + for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next())
6744 + // Variable to hold the colour (if there exists one) of
6745 + // the current face being processed
6746 + Quantity_Color face_colour;
6748 + TopoDS_Face face = TopoDS::Face (exp0.Current());
6750 + if(face_colours.IsNull()
6751 + || (!(face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour))))
6753 + // Set the default face colour to green (Netgen Standard)
6754 + // if no colour has been defined for the face
6755 + face_colour = Quantity_Color(0.0,1.0,0.0,Quantity_TOC_RGB);
6758 + sff = new ShapeFix_Face (face);
6759 + sff->FixAddNaturalBoundMode() = Standard_True;
6760 + sff->FixSmallAreaWireMode() = Standard_True;
6763 + if(sff->Status(ShapeExtend_DONE1) ||
6764 + sff->Status(ShapeExtend_DONE2) ||
6765 + sff->Status(ShapeExtend_DONE3) ||
6766 + sff->Status(ShapeExtend_DONE4) ||
6767 + sff->Status(ShapeExtend_DONE5))
6769 + std::cout << "repaired face " << fmap.FindIndex(face) << " ";
6770 + if(sff->Status(ShapeExtend_DONE1))
6771 + std::cout << "(some wires are fixed)" <<std::endl;
6772 + else if(sff->Status(ShapeExtend_DONE2))
6773 + std::cout << "(orientation of wires fixed)" <<std::endl;
6774 + else if(sff->Status(ShapeExtend_DONE3))
6775 + std::cout << "(missing seam added)" <<std::endl;
6776 + else if(sff->Status(ShapeExtend_DONE4))
6777 + std::cout << "(small area wire removed)" <<std::endl;
6778 + else if(sff->Status(ShapeExtend_DONE5))
6779 + std::cout << "(natural bounds added)" <<std::endl;
6780 + TopoDS_Face newface = sff->Face();
6782 + rebuild->Replace(face, newface);
6785 + // Set the original colour of the face to the newly created
6786 + // face (after the healing process)
6787 + face = TopoDS::Face (exp0.Current());
6788 + face_colours->SetColor(face,face_colour,XCAFDoc_ColorSurf);
6790 + shape = rebuild->Apply(shape);
6795 + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
6796 + rebuild->Apply(shape);
6797 + for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
6799 + TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
6800 + if ( BRep_Tool::Degenerated(edge) )
6801 + rebuild->Remove(edge);
6803 + shape = rebuild->Apply(shape);
6807 + if (fixsmalledges)
6809 + std::cout << std::endl << "- fixing small edges" << std::endl;
6811 + Handle(ShapeFix_Wire) sfw;
6812 + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
6813 + rebuild->Apply(shape);
6816 + for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next())
6818 + TopoDS_Face face = TopoDS::Face(exp0.Current());
6820 + for (exp1.Init (face, TopAbs_WIRE); exp1.More(); exp1.Next())
6822 + TopoDS_Wire oldwire = TopoDS::Wire(exp1.Current());
6823 + sfw = new ShapeFix_Wire (oldwire, face ,tolerance);
6824 + sfw->ModifyTopologyMode() = Standard_True;
6826 + sfw->ClosedWireMode() = Standard_True;
6828 + bool replace = false;
6830 + replace = sfw->FixReorder() || replace;
6832 + replace = sfw->FixConnected() || replace;
6836 + if (sfw->FixSmall (Standard_False, tolerance) && ! (sfw->StatusSmall(ShapeExtend_FAIL1) ||
6837 + sfw->StatusSmall(ShapeExtend_FAIL2) ||
6838 + sfw->StatusSmall(ShapeExtend_FAIL3)))
6840 + std::cout << "Fixed small edge in wire " << wmap.FindIndex (oldwire) << std::endl;
6844 + else if (sfw->StatusSmall(ShapeExtend_FAIL1))
6845 + cerr << "Failed to fix small edge in wire " << wmap.FindIndex (oldwire)
6846 + << ", edge cannot be checked (no 3d curve and no pcurve)" << std::endl;
6847 + else if (sfw->StatusSmall(ShapeExtend_FAIL2))
6848 + cerr << "Failed to fix small edge in wire " << wmap.FindIndex (oldwire)
6849 + << ", edge is null-length and has different vertives at begin and end, and lockvtx is True or ModifiyTopologyMode is False" << std::endl;
6850 + else if (sfw->StatusSmall(ShapeExtend_FAIL3))
6851 + cerr << "Failed to fix small edge in wire " << wmap.FindIndex (oldwire)
6852 + << ", CdheckConnected has failed" << std::endl;
6854 + replace = sfw->FixEdgeCurves() || replace;
6856 + replace = sfw->FixDegenerated() || replace;
6858 + replace = sfw->FixSelfIntersection() || replace;
6860 + replace = sfw->FixLacking(Standard_True) || replace;
6864 + TopoDS_Wire newwire = sfw->Wire();
6865 + rebuild->Replace(oldwire, newwire);
6868 + //delete sfw; sfw = NULL;
6873 + shape = rebuild->Apply(shape);
6879 + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
6880 + rebuild->Apply(shape);
6882 + for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
6884 + TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
6885 + if (vmap.FindIndex(TopExp::FirstVertex (edge)) ==
6886 + vmap.FindIndex(TopExp::LastVertex (edge)))
6888 + GProp_GProps system;
6889 + BRepGProp::LinearProperties(edge, system);
6890 + if (system.Mass() < tolerance)
6892 + std::cout << "removing degenerated edge " << emap.FindIndex(edge)
6893 + << " from vertex " << vmap.FindIndex(TopExp::FirstVertex (edge))
6894 + << " to vertex " << vmap.FindIndex(TopExp::LastVertex (edge)) << std::endl;
6895 + rebuild->Remove(edge);
6899 + shape = rebuild->Apply(shape);
6901 + //delete rebuild; rebuild = NULL;
6907 + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
6908 + rebuild->Apply(shape);
6909 + for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
6911 + TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
6912 + if ( BRep_Tool::Degenerated(edge) )
6913 + rebuild->Remove(edge);
6915 + shape = rebuild->Apply(shape);
6921 + Handle(ShapeFix_Wireframe) sfwf = new ShapeFix_Wireframe;
6922 + sfwf->SetPrecision(tolerance);
6923 + sfwf->Load (shape);
6924 + sfwf->ModeDropSmallEdges() = Standard_True;
6926 + sfwf->SetPrecision(boundingbox.Diam());
6928 + if (sfwf->FixWireGaps())
6930 + std::cout << std::endl << "- fixing wire gaps" << std::endl;
6931 + if (sfwf->StatusWireGaps(ShapeExtend_OK)) std::cout << "no gaps found" << std::endl;
6932 + if (sfwf->StatusWireGaps(ShapeExtend_DONE1)) std::cout << "some 2D gaps fixed" << std::endl;
6933 + if (sfwf->StatusWireGaps(ShapeExtend_DONE2)) std::cout << "some 3D gaps fixed" << std::endl;
6934 + if (sfwf->StatusWireGaps(ShapeExtend_FAIL1)) std::cout << "failed to fix some 2D gaps" << std::endl;
6935 + if (sfwf->StatusWireGaps(ShapeExtend_FAIL2)) std::cout << "failed to fix some 3D gaps" << std::endl;
6938 + sfwf->SetPrecision(tolerance);
6942 + for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
6944 + TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
6945 + if ( BRep_Tool::Degenerated(edge) )
6946 + std::cout << "degenerated edge at position 4" << std::endl;
6952 + if (sfwf->FixSmallEdges())
6954 + std::cout << std::endl << "- fixing wire frames" << std::endl;
6955 + if (sfwf->StatusSmallEdges(ShapeExtend_OK)) std::cout << "no small edges found" << std::endl;
6956 + if (sfwf->StatusSmallEdges(ShapeExtend_DONE1)) std::cout << "some small edges fixed" << std::endl;
6957 + if (sfwf->StatusSmallEdges(ShapeExtend_FAIL1)) std::cout << "failed to fix some small edges" << std::endl;
6962 + shape = sfwf->Shape();
6964 + //delete sfwf; sfwf = NULL;
6965 + //delete rebuild; rebuild = NULL;
6974 + for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
6976 + TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
6977 + if ( BRep_Tool::Degenerated(edge) )
6978 + std::cout << "degenerated edge at position 5" << std::endl;
6985 + if (fixspotstripfaces)
6988 + std::cout << std::endl << "- fixing spot and strip faces" << std::endl;
6989 + Handle(ShapeFix_FixSmallFace) sffsm = new ShapeFix_FixSmallFace();
6990 + sffsm -> Init (shape);
6991 + sffsm -> SetPrecision (tolerance);
6992 + sffsm -> Perform();
6994 + shape = sffsm -> FixShape();
6995 + //delete sffsm; sffsm = NULL;
7000 + for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
7002 + TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
7003 + if ( BRep_Tool::Degenerated(edge) )
7004 + std::cout << "degenerated edge at position 6" << std::endl;
7012 + std::cout << std::endl << "- sewing faces" << std::endl;
7014 + BRepOffsetAPI_Sewing sewedObj(tolerance);
7016 + for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next())
7018 + TopoDS_Face face = TopoDS::Face (exp0.Current());
7019 + sewedObj.Add (face);
7022 + sewedObj.Perform();
7024 + if (!sewedObj.SewedShape().IsNull())
7025 + shape = sewedObj.SewedShape();
7027 + std::cout << " not possible";
7033 + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
7034 + rebuild->Apply(shape);
7035 + for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
7037 + TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
7038 + if ( BRep_Tool::Degenerated(edge) )
7039 + rebuild->Remove(edge);
7041 + shape = rebuild->Apply(shape);
7047 + std::cout << std::endl << "- making solids" << std::endl;
7049 + BRepBuilderAPI_MakeSolid ms;
7051 + for (exp0.Init(shape, TopAbs_SHELL); exp0.More(); exp0.Next())
7054 + ms.Add (TopoDS::Shell(exp0.Current()));
7059 + std::cout << " not possible (no shells)" << std::endl;
7063 + BRepCheck_Analyzer ba(ms);
7064 + if (ba.IsValid ())
7066 + Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
7068 + sfs->SetPrecision(tolerance);
7069 + sfs->SetMaxTolerance(tolerance);
7071 + shape = sfs->Shape();
7073 + for (exp0.Init(shape, TopAbs_SOLID); exp0.More(); exp0.Next())
7075 + TopoDS_Solid solid = TopoDS::Solid(exp0.Current());
7076 + TopoDS_Solid newsolid = solid;
7077 + BRepLib::OrientClosedSolid (newsolid);
7078 + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
7079 + // rebuild->Apply(shape);
7080 + rebuild->Replace(solid, newsolid);
7081 + TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_COMPSOLID);//, 1);
7082 + // TopoDS_Shape newshape = rebuild->Apply(shape);
7086 + //delete sfs; sfs = NULL;
7089 + std::cout << " not possible" << std::endl;
7095 + if (splitpartitions)
7097 + std::cout << "- running SALOME partition splitter" << std::endl;
7099 + TopExp_Explorer e2;
7100 + Partition_Spliter ps;
7103 + for (e2.Init (shape, TopAbs_SOLID);
7104 + e2.More(); e2.Next())
7107 + ps.AddShape (e2.Current());
7111 + shape = ps.Shape();
7113 + std::cout << " before: " << count << " solids" << std::endl;
7116 + for (e2.Init (shape, TopAbs_SOLID);
7117 + e2.More(); e2.Next()) count++;
7119 + std::cout << " after : " << count << " solids" << std::endl;
7127 + for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())
7129 + TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
7130 + if ( BRep_Tool::Degenerated(edge) )
7131 + std::cout << "degenerated edge at position 8" << std::endl;
7136 + double newsurfacecont = 0;
7139 + for (exp0.Init (shape, TopAbs_FACE); exp0.More(); exp0.Next())
7141 + TopoDS_Face face = TopoDS::Face(exp0.Current());
7142 + GProp_GProps system;
7143 + BRepGProp::SurfaceProperties(face, system);
7144 + newsurfacecont += system.Mass();
7148 + int nnrc = 0, nnrcs = 0,
7149 + nnrso = somap.Extent(),
7150 + nnrsh = shmap.Extent(),
7151 + nnrf = fmap.Extent(),
7152 + nnrw = wmap.Extent(),
7153 + nnre = emap.Extent(),
7154 + nnrv = vmap.Extent();
7156 + for (exp0.Init(shape, TopAbs_COMPOUND); exp0.More(); exp0.Next()) nnrc++;
7157 + for (exp0.Init(shape, TopAbs_COMPSOLID); exp0.More(); exp0.Next()) nnrcs++;
7159 + std::cout << "-----------------------------------" << std::endl;
7160 + std::cout << "Compounds : " << nnrc << " (" << nrc << ")" << std::endl;
7161 + std::cout << "Composite solids: " << nnrcs << " (" << nrcs << ")" << std::endl;
7162 + std::cout << "Solids : " << nnrso << " (" << nrso << ")" << std::endl;
7163 + std::cout << "Shells : " << nnrsh << " (" << nrsh << ")" << std::endl;
7164 + std::cout << "Wires : " << nnrw << " (" << nrw << ")" << std::endl;
7165 + std::cout << "Faces : " << nnrf << " (" << nrf << ")" << std::endl;
7166 + std::cout << "Edges : " << nnre << " (" << nre << ")" << std::endl;
7167 + std::cout << "Vertices : " << nnrv << " (" << nrv << ")" << std::endl;
7168 + std::cout << std::endl;
7169 + std::cout << "Totol surface area : " << newsurfacecont << " (" << surfacecont << ")" << std::endl;
7170 + std::cout << std::endl;
7176 + void OCCGeometry :: BuildFMap()
7185 + TopExp_Explorer exp0, exp1, exp2, exp3, exp4, exp5;
7187 + for (exp0.Init(shape, TopAbs_COMPOUND);
7188 + exp0.More(); exp0.Next())
7190 + TopoDS_Compound compound = TopoDS::Compound (exp0.Current());
7191 + (*testout) << "compound" << std::endl;
7193 + for (exp1.Init(compound, TopAbs_SHELL);
7194 + exp1.More(); exp1.Next())
7196 + (*testout) << "shell " << ++i << std::endl;
7200 + for (exp0.Init(shape, TopAbs_SOLID);
7201 + exp0.More(); exp0.Next())
7203 + TopoDS_Solid solid = TopoDS::Solid (exp0.Current());
7205 + if (somap.FindIndex(solid) < 1)
7207 + somap.Add (solid);
7209 + for (exp1.Init(solid, TopAbs_SHELL);
7210 + exp1.More(); exp1.Next())
7212 + TopoDS_Shell shell = TopoDS::Shell (exp1.Current());
7213 + if (shmap.FindIndex(shell) < 1)
7215 + shmap.Add (shell);
7217 + for (exp2.Init(shell, TopAbs_FACE);
7218 + exp2.More(); exp2.Next())
7220 + TopoDS_Face face = TopoDS::Face(exp2.Current());
7221 + if (fmap.FindIndex(face) < 1)
7224 + (*testout) << "face " << fmap.FindIndex(face) << " ";
7225 + (*testout) << ((face.Orientation() == TopAbs_REVERSED) ? "-" : "+") << ", ";
7226 + (*testout) << ((exp2.Current().Orientation() == TopAbs_REVERSED) ? "-" : "+") << std::endl;
7227 + for (exp3.Init(exp2.Current(), TopAbs_WIRE);
7228 + exp3.More(); exp3.Next())
7230 + TopoDS_Wire wire = TopoDS::Wire (exp3.Current());
7231 + if (wmap.FindIndex(wire) < 1)
7235 + for (exp4.Init(exp3.Current(), TopAbs_EDGE);
7236 + exp4.More(); exp4.Next())
7238 + TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
7239 + if (emap.FindIndex(edge) < 1)
7242 + for (exp5.Init(exp4.Current(), TopAbs_VERTEX);
7243 + exp5.More(); exp5.Next())
7245 + TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
7246 + if (vmap.FindIndex(vertex) < 1)
7247 + vmap.Add (vertex);
7261 + for (exp1.Init(shape, TopAbs_SHELL, TopAbs_SOLID); exp1.More(); exp1.Next())
7263 + TopoDS_Shell shell = TopoDS::Shell(exp1.Current());
7264 + if (shmap.FindIndex(shell) < 1)
7266 + shmap.Add (shell);
7268 + (*testout) << "shell " << shmap.FindIndex(shell) << " ";
7269 + (*testout) << ((shell.Orientation() == TopAbs_REVERSED) ? "-" : "+") << ", ";
7270 + (*testout) << ((exp1.Current().Orientation() == TopAbs_REVERSED) ? "-" : "+") << std::endl;
7272 + for (exp2.Init(shell, TopAbs_FACE); exp2.More(); exp2.Next())
7274 + TopoDS_Face face = TopoDS::Face(exp2.Current());
7275 + if (fmap.FindIndex(face) < 1)
7279 + for (exp3.Init(face, TopAbs_WIRE); exp3.More(); exp3.Next())
7281 + TopoDS_Wire wire = TopoDS::Wire (exp3.Current());
7282 + if (wmap.FindIndex(wire) < 1)
7286 + for (exp4.Init(wire, TopAbs_EDGE); exp4.More(); exp4.Next())
7288 + TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
7289 + if (emap.FindIndex(edge) < 1)
7292 + for (exp5.Init(edge, TopAbs_VERTEX); exp5.More(); exp5.Next())
7294 + TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
7295 + if (vmap.FindIndex(vertex) < 1)
7296 + vmap.Add (vertex);
7310 + for (exp2.Init(shape, TopAbs_FACE, TopAbs_SHELL); exp2.More(); exp2.Next())
7312 + TopoDS_Face face = TopoDS::Face(exp2.Current());
7313 + if (fmap.FindIndex(face) < 1)
7317 + for (exp3.Init(exp2.Current(), TopAbs_WIRE); exp3.More(); exp3.Next())
7319 + TopoDS_Wire wire = TopoDS::Wire (exp3.Current());
7320 + if (wmap.FindIndex(wire) < 1)
7324 + for (exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next())
7326 + TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
7327 + if (emap.FindIndex(edge) < 1)
7330 + for (exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next())
7332 + TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
7333 + if (vmap.FindIndex(vertex) < 1)
7334 + vmap.Add (vertex);
7346 + for (exp3.Init(shape, TopAbs_WIRE, TopAbs_FACE); exp3.More(); exp3.Next())
7348 + TopoDS_Wire wire = TopoDS::Wire (exp3.Current());
7349 + if (wmap.FindIndex(wire) < 1)
7353 + for (exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next())
7355 + TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
7356 + if (emap.FindIndex(edge) < 1)
7359 + for (exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next())
7361 + TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
7362 + if (vmap.FindIndex(vertex) < 1)
7363 + vmap.Add (vertex);
7373 + for (exp4.Init(shape, TopAbs_EDGE, TopAbs_WIRE); exp4.More(); exp4.Next())
7375 + TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
7376 + if (emap.FindIndex(edge) < 1)
7379 + for (exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next())
7381 + TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
7382 + if (vmap.FindIndex(vertex) < 1)
7383 + vmap.Add (vertex);
7391 + for (exp5.Init(shape, TopAbs_VERTEX, TopAbs_EDGE); exp5.More(); exp5.Next())
7393 + TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
7394 + if (vmap.FindIndex(vertex) < 1)
7395 + vmap.Add (vertex);
7401 + facemeshstatus.DeleteAll();
7402 + facemeshstatus.SetSize (fmap.Extent());
7403 + facemeshstatus = 0;
7405 + // Philippose - 15/01/2009
7406 + face_maxh.DeleteAll();
7407 + face_maxh.SetSize (fmap.Extent());
7408 + face_maxh = mparam.maxh;
7410 + // Philippose - 15/01/2010
7411 + face_maxh_modified.DeleteAll();
7412 + face_maxh_modified.SetSize(fmap.Extent());
7413 + face_maxh_modified = 0;
7416 + // Philippose - 17/01/2009
7417 + face_sel_status.DeleteAll();
7418 + face_sel_status.SetSize (fmap.Extent());
7419 + face_sel_status = 0;
7421 + fvispar.SetSize (fmap.Extent());
7422 + evispar.SetSize (emap.Extent());
7423 + vvispar.SetSize (vmap.Extent());
7425 + fsingular.SetSize (fmap.Extent());
7426 + esingular.SetSize (emap.Extent());
7427 + vsingular.SetSize (vmap.Extent());
7429 + fsingular = esingular = vsingular = false;
7434 + void OCCGeometry :: SewFaces ()
7436 + (*testout) << "Trying to sew faces ..." << std::endl;
7437 + std::cout << "Trying to sew faces ..." << flush;
7439 + BRepOffsetAPI_Sewing sewedObj(1);
7441 + for (int i = 1; i <= fmap.Extent(); i++)
7443 + TopoDS_Face face = TopoDS::Face (fmap(i));
7444 + sewedObj.Add (face);
7447 + sewedObj.Perform();
7449 + if (!sewedObj.SewedShape().IsNull())
7451 + shape = sewedObj.SewedShape();
7452 + std::cout << " done" << std::endl;
7455 + std::cout << " not possible";
7462 + void OCCGeometry :: MakeSolid ()
7464 + TopExp_Explorer exp0;
7466 + (*testout) << "Trying to build solids ..." << std::endl;
7467 + std::cout << "Trying to build solids ..." << flush;
7469 + BRepBuilderAPI_MakeSolid ms;
7471 + for (exp0.Init(shape, TopAbs_SHELL); exp0.More(); exp0.Next())
7474 + ms.Add (TopoDS::Shell(exp0.Current()));
7479 + std::cout << " not possible (no shells)" << std::endl;
7483 + BRepCheck_Analyzer ba(ms);
7484 + if (ba.IsValid ())
7486 + Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
7489 + sfs->SetPrecision(1e-5);
7490 + sfs->SetMaxTolerance(1e-5);
7494 + shape = sfs->Shape();
7496 + for (exp0.Init(shape, TopAbs_SOLID); exp0.More(); exp0.Next())
7498 + TopoDS_Solid solid = TopoDS::Solid(exp0.Current());
7499 + TopoDS_Solid newsolid = solid;
7500 + BRepLib::OrientClosedSolid (newsolid);
7501 + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
7502 + rebuild->Replace(solid, newsolid);
7504 + TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_SHAPE, 1);
7508 + std::cout << " done" << std::endl;
7511 + std::cout << " not possible" << std::endl;
7517 + void OCCGeometry :: BuildVisualizationMesh (double deflection)
7519 + std::cout << "Preparing visualization (deflection = " << deflection << ") ... " << flush;
7521 + BRepTools::Clean (shape);
7522 + // BRepMesh_IncrementalMesh::
7523 + BRepMesh_IncrementalMesh (shape, deflection, true);
7524 + std::cout << "done" << std::endl;
7530 + void OCCGeometry :: CalcBoundingBox ()
7533 + BRepBndLib::Add (shape, bb);
7535 + double x1,y1,z1,x2,y2,z2;
7536 + bb.Get (x1,y1,z1,x2,y2,z2);
7537 + Point<3> p1 = Point<3> (x1,y1,z1);
7538 + Point<3> p2 = Point<3> (x2,y2,z2);
7540 + (*testout) << "Bounding Box = [" << p1 << " - " << p2 << "]" << std::endl;
7541 + boundingbox = Box<3> (p1,p2);
7546 + // returns a projector and a classifier for the given surface
7547 + void OCCGeometry::GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
7548 + BRepTopAdaptor_FClass2d*& cls) const
7550 + //MSV: organize caching projector in the map
7551 + if (fprjmap.IsBound(surfi))
7553 + proj = fprjmap.Find(surfi);
7554 + cls = fclsmap.Find(surfi);
7558 + const TopoDS_Face& aFace = TopoDS::Face(fmap(surfi));
7559 + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
7560 + proj = new ShapeAnalysis_Surface(aSurf);
7561 + fprjmap.Bind(surfi, proj);
7562 + cls = new BRepTopAdaptor_FClass2d(aFace,Precision::Confusion());
7563 + fclsmap.Bind(surfi, cls);
7567 + // void OCCGeometry :: Project (int surfi, Point<3> & p) const
7568 + bool OCCGeometry :: Project (int surfi, Point<3> & p, double& u, double& v) const
7570 + static int cnt = 0;
7571 + if (++cnt % 1000 == 0) std::cout << "Project cnt = " << cnt << std::endl;
7573 + gp_Pnt pnt(p(0), p(1), p(2));
7575 + // -- Optimization: use cached projector and classifier
7577 + // Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
7578 + // Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
7579 + // gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
7580 + // suval.Coord( u, v);
7581 + // pnt = thesurf->Value( u, v );
7583 + Handle(ShapeAnalysis_Surface) proj;
7584 + BRepTopAdaptor_FClass2d *cls;
7585 + GetFaceTools(surfi, proj, cls);
7587 + gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion());
7588 + if (cls->Perform(p2d) == TopAbs_OUT)
7592 + pnt = proj->Value(p2d);
7595 + p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
7603 + bool OCCGeometry :: FastProject (int surfi, Point<3> & ap, double& u, double& v) const
7605 + gp_Pnt p(ap(0), ap(1), ap(2));
7607 + // -- Optimization: use cached projector and classifier
7608 + // Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
7610 + // gp_Pnt x = surface->Value (u,v);
7612 + // if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
7616 + // surface->D1(u,v,x,du,dv);
7622 + // double det, lambda, mu;
7629 + // det = Det3 (n.X(), du.X(), dv.X(),
7630 + // n.Y(), du.Y(), dv.Y(),
7631 + // n.Z(), du.Z(), dv.Z());
7633 + // if (det < 1e-15) return false;
7635 + // lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
7636 + // n.Y(), p.Y()-x.Y(), dv.Y(),
7637 + // n.Z(), p.Z()-x.Z(), dv.Z())/det;
7639 + // mu = Det3 (n.X(), du.X(), p.X()-x.X(),
7640 + // n.Y(), du.Y(), p.Y()-x.Y(),
7641 + // n.Z(), du.Z(), p.Z()-x.Z())/det;
7647 + // surface->D1(u,v,x,du,dv);
7649 + // } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
7651 + // // (*testout) << "FastProject count: " << count << std::endl;
7653 + // if (count == 50) return false;
7655 + // ap = Point<3> (x.X(), x.Y(), x.Z());
7656 + Handle(ShapeAnalysis_Surface) proj;
7657 + BRepTopAdaptor_FClass2d *cls;
7658 + GetFaceTools(surfi, proj, cls);
7660 + gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion());
7661 + if (cls->Perform(p2d) == TopAbs_OUT)
7663 + //std::cout << "Projection fails" << std::endl;
7667 + p = proj->Value(p2d);
7669 + ap = Point<3> (p.X(), p.Y(), p.Z());
7677 + void OCCGeometry :: WriteOCC_STL(char * filename)
7679 + std::cout << "writing stl..."; std::cout.flush();
7680 + StlAPI_Writer writer;
7681 + //writer.RelativeMode() = Standard_False;
7683 + //writer.SetDeflection(0.02);
7684 + writer.Write(shape,filename);
7686 + std::cout << "done" << std::endl;
7691 + // Philippose - 23/02/2009
7692 + /* Special IGES File load function including the ability
7693 + to extract individual surface colours via the extended
7694 + OpenCascade XDE and XCAF Feature set.
7696 + OCCGeometry *LoadOCC_IGES(const char *filename)
7698 + OCCGeometry *occgeo;
7699 + occgeo = new OCCGeometry;
7701 + // Initiate a dummy XCAF Application to handle the IGES XCAF Document
7702 + static Handle(XCAFApp_Application) dummy_app = XCAFApp_Application::GetApplication();
7704 + // Create an XCAF Document to contain the IGES file itself
7705 + Handle(TDocStd_Document) iges_doc;
7707 + // Check if a IGES File is already open under this handle, if so, close it to prevent
7708 + // Segmentation Faults when trying to create a new document
7709 + if(dummy_app->NbDocuments() > 0)
7711 + dummy_app->GetDocument(1,iges_doc);
7712 + dummy_app->Close(iges_doc);
7714 + dummy_app->NewDocument ("IGES-XCAF",iges_doc);
7716 + IGESCAFControl_Reader reader;
7718 + Standard_Integer stat = reader.ReadFile((char*)filename);
7720 + if(stat != IFSelect_RetDone)
7726 + // Enable transfer of colours
7727 + reader.SetColorMode(Standard_True);
7729 + reader.Transfer(iges_doc);
7731 + // Read in the shape(s) and the colours present in the IGES File
7732 + Handle(XCAFDoc_ShapeTool) iges_shape_contents = XCAFDoc_DocumentTool::ShapeTool(iges_doc->Main());
7733 + Handle(XCAFDoc_ColorTool) iges_colour_contents = XCAFDoc_DocumentTool::ColorTool(iges_doc->Main());
7735 + TDF_LabelSequence iges_shapes;
7736 + iges_shape_contents->GetShapes(iges_shapes);
7738 + // List out the available colours in the IGES File as Colour Names
7739 + TDF_LabelSequence all_colours;
7740 + iges_colour_contents->GetColors(all_colours);
7741 + PrintMessage(1,"Number of colours in IGES File: ",all_colours.Length());
7742 + for(int i = 1; i <= all_colours.Length(); i++)
7744 + Quantity_Color col;
7745 + stringstream col_rgb;
7746 + iges_colour_contents->GetColor(all_colours.Value(i),col);
7747 + col_rgb << " : (" << col.Red() << "," << col.Green() << "," << col.Blue() << ")";
7748 + PrintMessage(1, "Colour [", i, "] = ",col.StringName(col.Name()),col_rgb.str());
7752 + // For the IGES Reader, all the shapes can be exported as one compund shape
7753 + // using the "OneShape" member
7754 + occgeo->shape = reader.OneShape();
7755 + occgeo->face_colours = iges_colour_contents;
7756 + occgeo->changed = 1;
7757 + occgeo->BuildFMap();
7759 + occgeo->CalcBoundingBox();
7760 + PrintContents (occgeo);
7769 + // Philippose - 29/01/2009
7770 + /* Special STEP File load function including the ability
7771 + to extract individual surface colours via the extended
7772 + OpenCascade XDE and XCAF Feature set.
7774 + OCCGeometry * LoadOCC_STEP (const char * filename)
7776 + OCCGeometry * occgeo;
7777 + occgeo = new OCCGeometry;
7779 + // Initiate a dummy XCAF Application to handle the STEP XCAF Document
7780 + static Handle(XCAFApp_Application) dummy_app = XCAFApp_Application::GetApplication();
7782 + // Create an XCAF Document to contain the STEP file itself
7783 + Handle(TDocStd_Document) step_doc;
7785 + // Check if a STEP File is already open under this handle, if so, close it to prevent
7786 + // Segmentation Faults when trying to create a new document
7787 + if(dummy_app->NbDocuments() > 0)
7789 + dummy_app->GetDocument(1,step_doc);
7790 + dummy_app->Close(step_doc);
7792 + dummy_app->NewDocument ("STEP-XCAF",step_doc);
7794 + STEPCAFControl_Reader reader;
7796 + // Enable transfer of colours
7797 + reader.SetColorMode(Standard_True);
7799 + Standard_Integer stat = reader.ReadFile((char*)filename);
7801 + if(stat != IFSelect_RetDone)
7807 + reader.Transfer(step_doc);
7809 + // Read in the shape(s) and the colours present in the STEP File
7810 + Handle(XCAFDoc_ShapeTool) step_shape_contents = XCAFDoc_DocumentTool::ShapeTool(step_doc->Main());
7811 + Handle(XCAFDoc_ColorTool) step_colour_contents = XCAFDoc_DocumentTool::ColorTool(step_doc->Main());
7813 + TDF_LabelSequence step_shapes;
7814 + step_shape_contents->GetShapes(step_shapes);
7816 + // List out the available colours in the STEP File as Colour Names
7817 + TDF_LabelSequence all_colours;
7818 + step_colour_contents->GetColors(all_colours);
7819 + PrintMessage(1,"Number of colours in STEP File: ",all_colours.Length());
7820 + for(int i = 1; i <= all_colours.Length(); i++)
7822 + Quantity_Color col;
7823 + stringstream col_rgb;
7824 + step_colour_contents->GetColor(all_colours.Value(i),col);
7825 + col_rgb << " : (" << col.Red() << "," << col.Green() << "," << col.Blue() << ")";
7826 + PrintMessage(1, "Colour [", i, "] = ",col.StringName(col.Name()),col_rgb.str());
7830 + // For the STEP File Reader in OCC, the 1st Shape contains the entire
7831 + // compound geometry as one shape
7832 + occgeo->shape = step_shape_contents->GetShape(step_shapes.Value(1));
7833 + occgeo->face_colours = step_colour_contents;
7834 + occgeo->changed = 1;
7835 + occgeo->BuildFMap();
7837 + occgeo->CalcBoundingBox();
7838 + PrintContents (occgeo);
7846 + OCCGeometry *LoadOCC_BREP (const char *filename)
7848 + OCCGeometry * occgeo;
7849 + occgeo = new OCCGeometry;
7851 + BRep_Builder aBuilder;
7852 + Standard_Boolean result = BRepTools::Read(occgeo->shape, const_cast<char*> (filename),aBuilder);
7860 + // Philippose - 23/02/2009
7861 + // Fixed a bug in the OpenCascade XDE Colour handling when
7862 + // opening BREP Files, since BREP Files have no colour data.
7863 + // Hence, the face_colours Handle needs to be created as a NULL handle.
7864 + occgeo->face_colours = Handle(XCAFDoc_ColorTool)();
7865 + occgeo->face_colours.Nullify();
7866 + occgeo->changed = 1;
7867 + occgeo->BuildFMap();
7869 + occgeo->CalcBoundingBox();
7870 + PrintContents (occgeo);
7876 + void OCCGeometry :: Save (string sfilename) const
7878 + const char * filename = sfilename.c_str();
7879 + if (strlen(filename) < 4)
7880 + throw NgException ("illegal filename");
7882 + if (strcmp (&filename[strlen(filename)-3], "igs") == 0)
7884 + IGESControl_Writer writer("millimeters", 1);
7885 + writer.AddShape (shape);
7886 + writer.Write (filename);
7888 + else if (strcmp (&filename[strlen(filename)-3], "stp") == 0)
7890 + STEPControl_Writer writer;
7891 + writer.Transfer (shape, STEPControl_AsIs);
7892 + writer.Write (filename);
7894 + else if (strcmp (&filename[strlen(filename)-3], "stl") == 0)
7896 + StlAPI_Writer writer;
7897 + writer.ASCIIMode() = Standard_True;
7898 + writer.Write (shape, filename);
7900 + else if (strcmp (&filename[strlen(filename)-4], "stlb") == 0)
7902 + StlAPI_Writer writer;
7903 + writer.ASCIIMode() = Standard_False;
7904 + writer.Write (shape, filename);
7910 + const char * shapesname[] =
7911 + {" ", "CompSolids", "Solids", "Shells",
7913 + "Faces", "Wires", "Edges", "Vertices"};
7915 + const char * shapename[] =
7916 + {" ", "CompSolid", "Solid", "Shell",
7917 + "Face", "Wire", "Edge", "Vertex"};
7919 + const char * orientationstring[] =
7925 + void OCCGeometry :: RecursiveTopologyTree (const TopoDS_Shape & sh,
7926 + stringstream & str,
7927 + TopAbs_ShapeEnum l,
7929 + const char * lname)
7931 + if (l > TopAbs_VERTEX) return;
7933 + TopExp_Explorer e;
7938 + e.Init(sh, l, TopAbs_ShapeEnum(l-1));
7942 + for (; e.More(); e.Next())
7946 + stringstream lname2;
7947 + lname2 << lname << "/" << shapename[l] << count;
7948 + str << lname2.str() << " ";
7950 + switch (e.Current().ShapeType())
7952 + case TopAbs_SOLID:
7953 + count2 = somap.FindIndex(TopoDS::Solid(e.Current())); break;
7954 + case TopAbs_SHELL:
7955 + count2 = shmap.FindIndex(TopoDS::Shell(e.Current())); break;
7957 + count2 = fmap.FindIndex(TopoDS::Face(e.Current())); break;
7959 + count2 = wmap.FindIndex(TopoDS::Wire(e.Current())); break;
7961 + count2 = emap.FindIndex(TopoDS::Edge(e.Current())); break;
7962 + case TopAbs_VERTEX:
7963 + count2 = vmap.FindIndex(TopoDS::Vertex(e.Current())); break;
7965 + std::cout << "RecursiveTopologyTree: Case " << e.Current().ShapeType() << " not handeled" << std::endl;
7968 + int nrsubshapes = 0;
7970 + if (l <= TopAbs_WIRE)
7972 + TopExp_Explorer e2;
7973 + for (e2.Init (e.Current(), TopAbs_ShapeEnum (l+1));
7974 + e2.More(); e2.Next())
7978 + str << "{" << shapename[l] << " " << count2;
7980 + if (l <= TopAbs_EDGE)
7982 + str << " (" << orientationstring[e.Current().Orientation()];
7983 + if (nrsubshapes != 0) str << ", " << nrsubshapes;
7989 + RecursiveTopologyTree (e.Current(), str, TopAbs_ShapeEnum (l+1),
7990 + false, (char*)lname2.str().c_str());
7998 + void OCCGeometry :: GetTopologyTree (stringstream & str)
8000 + std::cout << "Building topology tree ... " << flush;
8001 + RecursiveTopologyTree (shape, str, TopAbs_COMPSOLID, false, "CompSolids");
8002 + RecursiveTopologyTree (shape, str, TopAbs_SOLID, true, "FreeSolids");
8003 + RecursiveTopologyTree (shape, str, TopAbs_SHELL, true, "FreeShells");
8004 + RecursiveTopologyTree (shape, str, TopAbs_FACE, true, "FreeFaces");
8005 + RecursiveTopologyTree (shape, str, TopAbs_WIRE, true, "FreeWires");
8006 + RecursiveTopologyTree (shape, str, TopAbs_EDGE, true, "FreeEdges");
8007 + RecursiveTopologyTree (shape, str, TopAbs_VERTEX, true, "FreeVertices");
8009 + // std::cout << "done" << std::endl;
8015 + void OCCGeometry :: CheckIrregularEntities(stringstream & str)
8017 + ShapeAnalysis_CheckSmallFace csm;
8019 + csm.SetTolerance (1e-6);
8021 + TopTools_DataMapOfShapeListOfShape mapEdges;
8022 + ShapeAnalysis_DataMapOfShapeListOfReal mapParam;
8023 + TopoDS_Compound theAllVert;
8025 + int spotfaces = 0;
8026 + int stripsupportfaces = 0;
8027 + int singlestripfaces = 0;
8028 + int stripfaces = 0;
8029 + int facessplitbyvertices = 0;
8030 + int stretchedpinfaces = 0;
8031 + int smoothpinfaces = 0;
8032 + int twistedfaces = 0;
8033 + // int edgessamebutnotidentified = 0;
8035 + std::cout << "checking faces ... " << flush;
8038 + for (i = 1; i <= fmap.Extent(); i++)
8040 + TopoDS_Face face = TopoDS::Face (fmap(i));
8041 + TopoDS_Edge e1, e2;
8043 + if (csm.CheckSpotFace (face))
8046 + str << "SpotFace {Spot face} ";
8048 + (*testout) << "Face " << i << " is a spot face" << std::endl;
8049 + str << "SpotFace/Face" << i << " ";
8050 + str << "{Face " << i << " } ";
8053 + if (csm.IsStripSupport (face))
8055 + if (!stripsupportfaces++)
8056 + str << "StripSupportFace {Strip support face} ";
8058 + (*testout) << "Face " << i << " has strip support" << std::endl;
8059 + str << "StripSupportFace/Face" << i << " ";
8060 + str << "{Face " << i << " } ";
8063 + if (csm.CheckSingleStrip(face, e1, e2))
8065 + if (!singlestripfaces++)
8066 + str << "SingleStripFace {Single strip face} ";
8068 + (*testout) << "Face " << i << " is a single strip (edge " << emap.FindIndex(e1)
8069 + << " and edge " << emap.FindIndex(e2) << " are identical)" << std::endl;
8070 + str << "SingleStripFace/Face" << i << " ";
8071 + str << "{Face " << i << " (edge " << emap.FindIndex(e1)
8072 + << " and edge " << emap.FindIndex(e2) << " are identical)} ";
8075 + if (csm.CheckStripFace(face, e1, e2))
8077 + if (!stripfaces++)
8078 + str << "StripFace {Strip face} ";
8080 + (*testout) << "Face " << i << " is a strip (edge " << emap.FindIndex(e1)
8081 + << " and edge " << emap.FindIndex(e2)
8082 + << " are identical)" << std::endl;
8083 + str << "StripFace/Face" << i << " ";
8084 + str << "{Face " << i << " (edge " << emap.FindIndex(e1)
8085 + << " and edge " << emap.FindIndex(e2) << " are identical)} ";
8088 + if (int count = csm.CheckSplittingVertices(face, mapEdges, mapParam, theAllVert))
8090 + if (!facessplitbyvertices++)
8091 + str << "FaceSplitByVertices {Face split by vertices} ";
8093 + (*testout) << "Face " << i << " is split by " << count
8094 + << " vertex/vertices " << std::endl;
8095 + str << "FaceSplitByVertices/Face" << i << " ";
8096 + str << "{Face " << i << " (split by " << count << "vertex/vertices)} ";
8099 + int whatrow, sens;
8100 + if (int type = csm.CheckPin (face, whatrow, sens))
8104 + if (!smoothpinfaces++)
8105 + str << "SmoothPinFace {Smooth pin face} ";
8107 + (*testout) << "Face " << i << " is a smooth pin" << std::endl;
8108 + str << "SmoothPinFace/Face" << i << " ";
8109 + str << "{Face " << i << " } ";
8113 + if (!stretchedpinfaces++)
8114 + str << "StretchedPinFace {Stretched pin face} ";
8116 + (*testout) << "Face " << i << " is a streched pin" << std::endl;
8117 + str << "StretchedPinFace/Face" << i << " ";
8118 + str << "{Face " << i << " } ";
8122 + double paramu, paramv;
8123 + if (csm.CheckTwisted (face, paramu, paramv))
8125 + if (!twistedfaces++)
8126 + str << "TwistedFace {Twisted face} ";
8128 + (*testout) << "Face " << i << " is twisted" << std::endl;
8129 + str << "TwistedFace/Face" << i << " ";
8130 + str << "{Face " << i << " } ";
8134 + std::cout << "done" << std::endl;
8135 + std::cout << "checking edges ... " << flush;
8139 + Array <double> edgeLengths;
8140 + Array <int> order;
8141 + edgeLengths.SetSize (emap.Extent());
8142 + order.SetSize (emap.Extent());
8144 + for (i = 1; i <= emap.Extent(); i++)
8146 + TopoDS_Edge edge1 = TopoDS::Edge (emap(i));
8147 + GProp_GProps system;
8148 + BRepGProp::LinearProperties(edge1, system);
8149 + edgeLengths[i-1] = system.Mass();
8152 + Sort (edgeLengths, order);
8154 + str << "ShortestEdges {Shortest edges} ";
8155 + for (i = 1; i <= min(20, emap.Extent()); i++)
8157 + str << "ShortestEdges/Edge" << i;
8158 + str << " {Edge " << order[i-1] << " (L=" << edgeLengths[order[i-1]-1] << ")} ";
8163 + std::cout << "done" << std::endl;
8169 + void OCCGeometry :: GetUnmeshedFaceInfo (stringstream & str)
8171 + for (int i = 1; i <= fmap.Extent(); i++)
8173 + if (facemeshstatus[i-1] == -1)
8174 + str << "Face" << i << " {Face " << i << " } ";
8182 + void OCCGeometry :: GetNotDrawableFaces (stringstream & str)
8184 + for (int i = 1; i <= fmap.Extent(); i++)
8186 + if (!fvispar[i-1].IsDrawable())
8187 + str << "Face" << i << " {Face " << i << " } ";
8195 + bool OCCGeometry :: ErrorInSurfaceMeshing ()
8197 + for (int i = 1; i <= fmap.Extent(); i++)
8198 + if (facemeshstatus[i-1] == -1)
8207 + int OCCGeometry :: GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
8208 + int perfstepsstart, int perfstepsend)
8210 + return OCCGenerateMesh (*this, mesh, mparam, perfstepsstart, perfstepsend);
8216 + const Refinement & OCCGeometry :: GetRefinement () const
8218 + return * new OCCRefinementSurfaces (*this);
8224 + OCCParameters :: OCCParameters()
8226 + resthcloseedgefac = 1;
8227 + resthcloseedgeenable = 1;
8228 + resthminedgelen = 0.001;
8229 + resthminedgelenenable = 1;
8235 + void OCCParameters :: Print(ostream & ost) const
8237 + ost << "OCC Parameters:" << std::endl
8238 + << "close edges: " << resthcloseedgeenable
8239 + << ", fac = " << resthcloseedgefac << std::endl
8240 + << "minimum edge length: " << resthminedgelenenable
8241 + << ", min len = " << resthminedgelen << std::endl;
8247 + OCCParameters occparam;
8253 --- netgen_ref/libsrc/occ/occgeom.hpp
8254 +++ netgen/libsrc/occ/occgeom.hpp
8256 -#ifndef FILE_OCCGEOM
8257 -#define FILE_OCCGEOM
8259 -/* *************************************************************************/
8260 -/* File: occgeom.hpp */
8261 -/* Author: Robert Gaisbauer */
8262 -/* Date: 26. May 03 */
8263 -/* *************************************************************************/
8267 -#include <meshing.hpp>
8269 -#include "BRep_Tool.hxx"
8270 -#include "Geom_Curve.hxx"
8271 -#include "Geom2d_Curve.hxx"
8272 -#include "Geom_Surface.hxx"
8273 -#include "GeomAPI_ProjectPointOnSurf.hxx"
8274 -#include "GeomAPI_ProjectPointOnCurve.hxx"
8275 -#include "BRepTools.hxx"
8276 -#include "TopExp.hxx"
8277 -#include "BRepBuilderAPI_MakeVertex.hxx"
8278 -#include "BRepBuilderAPI_MakeShell.hxx"
8279 -#include "BRepBuilderAPI_MakeSolid.hxx"
8280 -#include "BRepOffsetAPI_Sewing.hxx"
8281 -#include "BRepLProp_SLProps.hxx"
8282 -#include "BRepAdaptor_Surface.hxx"
8283 -#include "Poly_Triangulation.hxx"
8284 -#include "Poly_Array1OfTriangle.hxx"
8285 -#include "TColgp_Array1OfPnt2d.hxx"
8286 -#include "Poly_Triangle.hxx"
8287 -#include "GProp_GProps.hxx"
8288 -#include "BRepGProp.hxx"
8289 -#include "Geom_Surface.hxx"
8290 -#include "TopExp.hxx"
8291 -#include "gp_Pnt.hxx"
8292 -#include "TopoDS.hxx"
8293 -#include "TopoDS_Solid.hxx"
8294 -#include "TopExp_Explorer.hxx"
8295 -#include "TopTools_ListIteratorOfListOfShape.hxx"
8296 -#include "BRep_Tool.hxx"
8297 -#include "Geom_Curve.hxx"
8298 -#include "Geom2d_Curve.hxx"
8299 -#include "Geom_Surface.hxx"
8300 -#include "GeomAPI_ProjectPointOnSurf.hxx"
8301 -#include "GeomAPI_ProjectPointOnCurve.hxx"
8302 -#include "TopoDS_Wire.hxx"
8303 -#include "BRepTools_WireExplorer.hxx"
8304 -#include "BRepTools.hxx"
8305 -#include "TopTools_IndexedMapOfShape.hxx"
8306 -#include "TopExp.hxx"
8307 -#include "BRepBuilderAPI_MakeVertex.hxx"
8308 -#include "BRepBuilderAPI_MakeShell.hxx"
8309 -#include "BRepBuilderAPI_MakeSolid.hxx"
8310 -#include "BRepOffsetAPI_Sewing.hxx"
8311 -#include "BRepLProp_CLProps.hxx"
8312 -#include "BRepLProp_SLProps.hxx"
8313 -#include "BRepAdaptor_Surface.hxx"
8314 -#include "BRepAdaptor_Curve.hxx"
8315 -#include "Poly_Triangulation.hxx"
8316 -#include "Poly_Array1OfTriangle.hxx"
8317 -#include "TColgp_Array1OfPnt2d.hxx"
8318 -#include "Poly_Triangle.hxx"
8319 -#include "GProp_GProps.hxx"
8320 -#include "BRepGProp.hxx"
8321 -#include "TopoDS_Shape.hxx"
8322 -#include "TopoDS_Face.hxx"
8323 -#include "IGESToBRep_Reader.hxx"
8324 -#include "Interface_Static.hxx"
8325 -#include "GeomAPI_ExtremaCurveCurve.hxx"
8326 -#include "Standard_ErrorHandler.hxx"
8327 -#include "Standard_Failure.hxx"
8328 -#include "ShapeUpgrade_ShellSewing.hxx"
8329 -#include "ShapeFix_Shape.hxx"
8330 -#include "ShapeFix_Wireframe.hxx"
8331 -#include "BRepMesh.hxx"
8332 -#include "BRepMesh_IncrementalMesh.hxx"
8333 -#include "BRepBndLib.hxx"
8334 -#include "Bnd_Box.hxx"
8335 -#include "ShapeAnalysis.hxx"
8336 -#include "ShapeBuild_ReShape.hxx"
8339 -// Philippose - 29/01/2009
8340 -// OpenCascade XDE Support
8341 -// Include support for OpenCascade XDE Features
8342 -#include "TDocStd_Document.hxx"
8343 -#include "Quantity_Color.hxx"
8344 -#include "XCAFApp_Application.hxx"
8345 -#include "XCAFDoc_ShapeTool.hxx"
8346 -#include "XCAFDoc_Color.hxx"
8347 -#include "XCAFDoc_ColorTool.hxx"
8348 -#include "XCAFDoc_ColorType.hxx"
8349 -#include "XCAFDoc_LayerTool.hxx"
8350 -#include "XCAFDoc_DimTolTool.hxx"
8351 -#include "XCAFDoc_MaterialTool.hxx"
8352 -#include "XCAFDoc_DocumentTool.hxx"
8353 -#include "TDF_Label.hxx"
8354 -#include "TDF_LabelSequence.hxx"
8355 -#include "STEPCAFControl_Reader.hxx"
8356 -#include "STEPCAFControl_Writer.hxx"
8357 -#include "IGESCAFControl_Reader.hxx"
8358 -#include "IGESCAFControl_Writer.hxx"
8360 -#include "IGESControl_Reader.hxx"
8361 -#include "STEPControl_Reader.hxx"
8362 -#include "IGESControl_Writer.hxx"
8363 -#include "STEPControl_Writer.hxx"
8365 -#include "StlAPI_Writer.hxx"
8366 -#include "STEPControl_StepModelType.hxx"
8370 -#include "occmeshsurf.hpp"
8372 - extern DLL_HEADER MeshingParameters mparam;
8374 -#define PROJECTION_TOLERANCE 1e-10
8376 -#define ENTITYISVISIBLE 1
8377 -#define ENTITYISHIGHLIGHTED 2
8378 -#define ENTITYISDRAWABLE 4
8380 -#define OCCGEOMETRYVISUALIZATIONNOCHANGE 0
8381 -#define OCCGEOMETRYVISUALIZATIONFULLCHANGE 1 // Compute transformation matrices and redraw
8382 -#define OCCGEOMETRYVISUALIZATIONHALFCHANGE 2 // Redraw
8386 - class EntityVisualizationCode
8392 - EntityVisualizationCode()
8393 - { code = ENTITYISVISIBLE + !ENTITYISHIGHLIGHTED + ENTITYISDRAWABLE;}
8396 - { return code & ENTITYISVISIBLE;}
8398 - int IsHighlighted ()
8399 - { return code & ENTITYISHIGHLIGHTED;}
8402 - { return code & ENTITYISDRAWABLE;}
8405 - { code |= ENTITYISVISIBLE;}
8408 - { code &= ~ENTITYISVISIBLE;}
8411 - { code |= ENTITYISHIGHLIGHTED;}
8414 - { code &= ~ENTITYISHIGHLIGHTED;}
8416 - void SetDrawable ()
8417 - { code |= ENTITYISDRAWABLE;}
8419 - void SetNotDrawable ()
8420 - { code &= ~ENTITYISDRAWABLE;}
8430 - double Dist (Line l);
8437 - inline double Det3 (double a00, double a01, double a02,
8438 - double a10, double a11, double a12,
8439 - double a20, double a21, double a22)
8441 - return a00*a11*a22 + a01*a12*a20 + a10*a21*a02 - a20*a11*a02 - a10*a01*a22 - a21*a12*a00;
8447 - class OCCGeometry : public NetgenGeometry
8452 - TopoDS_Shape shape;
8453 - TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap;
8454 - Array<bool> fsingular, esingular, vsingular;
8455 - Box<3> boundingbox;
8457 - // Philippose - 29/01/2009
8458 - // OpenCascade XDE Support
8459 - // XCAF Handle to make the face colours available to the rest of
8461 - Handle_XCAFDoc_ColorTool face_colours;
8463 - mutable int changed;
8464 - Array<int> facemeshstatus;
8466 - // Philippose - 15/01/2009
8467 - // Maximum mesh size for a given face
8468 - // (Used to explicitly define mesh size limits on individual faces)
8469 - Array<double> face_maxh;
8471 - // Philippose - 14/01/2010
8472 - // Boolean array to detect whether a face has been explicitly modified
8473 - // by the user or not
8474 - Array<bool> face_maxh_modified;
8476 - // Philippose - 15/01/2009
8477 - // Indicates which faces have been selected by the user in geometry mode
8478 - // (Currently handles only selection of one face at a time, but an array would
8479 - // help to extend this to multiple faces)
8480 - Array<bool> face_sel_status;
8482 - Array<EntityVisualizationCode> fvispar, evispar, vvispar;
8485 - bool fixsmalledges;
8486 - bool fixspotstripfaces;
8489 - bool splitpartitions;
8502 - virtual void Save (string filename) const;
8507 - Box<3> GetBoundingBox()
8508 - { return boundingbox;}
8511 - { return somap.Extent();}
8513 - // Philippose - 17/01/2009
8514 - // Total number of faces in the geometry
8516 - { return fmap.Extent();}
8519 - { center = boundingbox.Center();}
8524 - void Project (int surfi, Point<3> & p) const;
8525 - bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
8527 - OCCSurface GetSurface (int surfi)
8529 - cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;
8530 - return OCCSurface (TopoDS::Face(fmap(surfi)), PLANESPACE);
8533 - void CalcBoundingBox ();
8534 - void BuildVisualizationMesh (double deflection);
8536 - void RecursiveTopologyTree (const TopoDS_Shape & sh,
8537 - stringstream & str,
8538 - TopAbs_ShapeEnum l,
8540 - const char * lname);
8542 - void GetTopologyTree (stringstream & str);
8544 - void PrintNrShapes ();
8546 - void CheckIrregularEntities (stringstream & str);
8552 - void HealGeometry();
8554 - // Philippose - 15/01/2009
8555 - // Sets the maximum mesh size for a given face
8556 - // (Note: Local mesh size limited by the global max mesh size)
8557 - void SetFaceMaxH(int facenr, double faceh)
8559 - if((facenr> 0) && (facenr <= fmap.Extent()))
8561 - face_maxh[facenr-1] = min(mparam.maxh,faceh);
8563 - // Philippose - 14/01/2010
8564 - // If the face maxh is greater than or equal to the
8565 - // current global maximum, then identify the face as
8566 - // not explicitly controlled by the user any more
8567 - if(faceh >= mparam.maxh)
8569 - face_maxh_modified[facenr-1] = 0;
8573 - face_maxh_modified[facenr-1] = 1;
8578 - // Philippose - 15/01/2009
8579 - // Returns the local mesh size of a given face
8580 - double GetFaceMaxH(int facenr)
8582 - if((facenr> 0) && (facenr <= fmap.Extent()))
8584 - return face_maxh[facenr-1];
8592 - // Philippose - 14/01/2010
8593 - // Returns the flag whether the given face
8594 - // has a mesh size controlled by the user or not
8595 - bool GetFaceMaxhModified(int facenr)
8597 - return face_maxh_modified[facenr-1];
8600 - // Philippose - 17/01/2009
8601 - // Returns the index of the currently selected face
8602 - int SelectedFace()
8606 - for(i = 1; i <= fmap.Extent(); i++)
8608 - if(face_sel_status[i-1])
8617 - // Philippose - 17/01/2009
8618 - // Sets the currently selected face
8619 - void SetSelectedFace(int facenr)
8621 - face_sel_status = 0;
8623 - if((facenr >= 1) && (facenr <= fmap.Extent()))
8625 - face_sel_status[facenr-1] = 1;
8629 - void LowLightAll()
8631 - for (int i = 1; i <= fmap.Extent(); i++)
8632 - fvispar[i-1].Lowlight();
8633 - for (int i = 1; i <= emap.Extent(); i++)
8634 - evispar[i-1].Lowlight();
8635 - for (int i = 1; i <= vmap.Extent(); i++)
8636 - vvispar[i-1].Lowlight();
8639 - void GetUnmeshedFaceInfo (stringstream & str);
8640 - void GetNotDrawableFaces (stringstream & str);
8641 - bool ErrorInSurfaceMeshing ();
8643 - void WriteOCC_STL(char * filename);
8645 - virtual int GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
8646 - int perfstepsstart, int perfstepsend);
8648 - virtual const Refinement & GetRefinement () const;
8653 - class OCCParameters
8657 - /// Factor for meshing close edges
8658 - double resthcloseedgefac;
8661 - /// Enable / Disable detection of close edges
8662 - int resthcloseedgeenable;
8665 - /// Minimum edge length to be used for dividing edges to mesh points
8666 - double resthminedgelen;
8669 - /// Enable / Disable use of the minimum edge length (by default use 1e-4)
8670 - int resthminedgelenenable;
8673 - Default Constructor for the OpenCascade
8674 - Mesh generation parameter set
8680 - Dump all the OpenCascade specific meshing parameters
8683 - void Print (ostream & ost) const;
8687 - void PrintContents (OCCGeometry * geom);
8689 - OCCGeometry * LoadOCC_IGES (const char * filename);
8690 - OCCGeometry * LoadOCC_STEP (const char * filename);
8691 - OCCGeometry * LoadOCC_BREP (const char * filename);
8693 - extern OCCParameters occparam;
8696 - // Philippose - 31.09.2009
8697 - // External access to the mesh generation functions within the OCC
8698 - // subsystem (Not sure if this is the best way to implement this....!!)
8699 - extern int OCCGenerateMesh (OCCGeometry & occgeometry, Mesh*& mesh,
8700 - MeshingParameters & mparam,
8701 - int perfstepsstart, int perfstepsend);
8703 - extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh);
8705 - extern void OCCMeshSurface (OCCGeometry & geom, Mesh & mesh, int perfstepsend);
8707 - extern void OCCFindEdges (OCCGeometry & geom, Mesh & mesh);
8713 +#ifndef FILE_OCCGEOM
8714 +#define FILE_OCCGEOM
8716 +/* *************************************************************************/
8717 +/* File: occgeom.hpp */
8718 +/* Author: Robert Gaisbauer */
8719 +/* Date: 26. May 03 */
8720 +/* *************************************************************************/
8724 +#include <myadt.hpp>
8725 +#include <iostream>
8727 +#include <meshing.hpp>
8729 +#include "BRep_Tool.hxx"
8730 +#include "Geom_Curve.hxx"
8731 +#include "Geom2d_Curve.hxx"
8732 +#include "Geom_Surface.hxx"
8733 +// #include "GeomAPI_ProjectPointOnSurf.hxx"
8734 +// #include "GeomAPI_ProjectPointOnCurve.hxx"
8735 +#include "BRepTools.hxx"
8736 +#include "TopExp.hxx"
8737 +#include "BRepBuilderAPI_MakeVertex.hxx"
8738 +#include "BRepBuilderAPI_MakeShell.hxx"
8739 +#include "BRepBuilderAPI_MakeSolid.hxx"
8740 +#include "BRepOffsetAPI_Sewing.hxx"
8741 +#include "BRepLProp_SLProps.hxx"
8742 +#include "BRepAdaptor_Surface.hxx"
8743 +#include "Poly_Triangulation.hxx"
8744 +#include "Poly_Array1OfTriangle.hxx"
8745 +#include "TColgp_Array1OfPnt2d.hxx"
8746 +#include "Poly_Triangle.hxx"
8747 +#include "GProp_GProps.hxx"
8748 +#include "BRepGProp.hxx"
8749 +#include "Geom_Surface.hxx"
8750 +#include "TopExp.hxx"
8751 +#include "gp_Pnt.hxx"
8752 +#include "TopoDS.hxx"
8753 +#include "TopoDS_Solid.hxx"
8754 +#include "TopExp_Explorer.hxx"
8755 +#include "TopTools_ListIteratorOfListOfShape.hxx"
8756 +#include "BRep_Tool.hxx"
8757 +#include "Geom_Curve.hxx"
8758 +#include "Geom2d_Curve.hxx"
8759 +#include "Geom_Surface.hxx"
8760 +// #include "GeomAPI_ProjectPointOnSurf.hxx"
8761 +// #include "GeomAPI_ProjectPointOnCurve.hxx"
8762 +#include "TopoDS_Wire.hxx"
8763 +#include "BRepTools_WireExplorer.hxx"
8764 +#include "BRepTools.hxx"
8765 +#include "TopTools_IndexedMapOfShape.hxx"
8766 +#include "TopExp.hxx"
8767 +#include "BRepBuilderAPI_MakeVertex.hxx"
8768 +#include "BRepBuilderAPI_MakeShell.hxx"
8769 +#include "BRepBuilderAPI_MakeSolid.hxx"
8770 +#include "BRepOffsetAPI_Sewing.hxx"
8771 +#include "BRepLProp_CLProps.hxx"
8772 +#include "BRepLProp_SLProps.hxx"
8773 +#include "BRepAdaptor_Surface.hxx"
8774 +#include "BRepAdaptor_Curve.hxx"
8775 +#include "Poly_Triangulation.hxx"
8776 +#include "Poly_Array1OfTriangle.hxx"
8777 +#include "TColgp_Array1OfPnt2d.hxx"
8778 +#include "Poly_Triangle.hxx"
8779 +#include "GProp_GProps.hxx"
8780 +#include "BRepGProp.hxx"
8781 +#include "TopoDS_Shape.hxx"
8782 +#include "TopoDS_Face.hxx"
8783 +#include "IGESToBRep_Reader.hxx"
8784 +#include "Interface_Static.hxx"
8785 +#include "GeomAPI_ExtremaCurveCurve.hxx"
8786 +//#include "Standard_ErrorHandler.hxx"
8787 +#include "Standard_Failure.hxx"
8788 +#include "ShapeUpgrade_ShellSewing.hxx"
8789 +#include "ShapeFix_Shape.hxx"
8790 +#include "ShapeFix_Wireframe.hxx"
8791 +#include <Standard_Version.hxx>
8792 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) <= 0x060702
8793 +// porting to OCCT6.7.3
8794 +#include "BRepMesh.hxx"
8796 +#include "BRepMesh_IncrementalMesh.hxx"
8797 +#include "BRepBndLib.hxx"
8798 +#include "Bnd_Box.hxx"
8799 +#include "ShapeAnalysis.hxx"
8800 +#include "ShapeBuild_ReShape.hxx"
8802 +// -- Optimization: to use cached projector and classifier
8803 +#include <NCollection_DataMap.hxx>
8804 +class ShapeAnalysis_Surface;
8805 +class BRepTopAdaptor_FClass2d;
8807 +// Philippose - 29/01/2009
8808 +// OpenCascade XDE Support
8809 +// Include support for OpenCascade XDE Features
8810 +#include "TDocStd_Document.hxx"
8811 +#include "Quantity_Color.hxx"
8812 +#include "XCAFApp_Application.hxx"
8813 +#include "XCAFDoc_ShapeTool.hxx"
8814 +#include "XCAFDoc_Color.hxx"
8815 +#include "XCAFDoc_ColorTool.hxx"
8816 +#include "XCAFDoc_ColorType.hxx"
8817 +#include "XCAFDoc_LayerTool.hxx"
8818 +#include "XCAFDoc_DimTolTool.hxx"
8819 +#include "XCAFDoc_MaterialTool.hxx"
8820 +#include "XCAFDoc_DocumentTool.hxx"
8821 +#include "TDF_Label.hxx"
8822 +#include "TDF_LabelSequence.hxx"
8823 +#include "STEPCAFControl_Reader.hxx"
8824 +#include "STEPCAFControl_Writer.hxx"
8825 +#include "IGESCAFControl_Reader.hxx"
8826 +#include "IGESCAFControl_Writer.hxx"
8828 +#include "IGESControl_Reader.hxx"
8829 +#include "STEPControl_Reader.hxx"
8830 +#include "IGESControl_Writer.hxx"
8831 +#include "STEPControl_Writer.hxx"
8833 +#include "StlAPI_Writer.hxx"
8834 +#include "STEPControl_StepModelType.hxx"
8838 +#include "occmeshsurf.hpp"
8840 + DLL_HEADER extern MeshingParameters mparam;
8842 +#define PROJECTION_TOLERANCE 1e-10
8844 +#define ENTITYISVISIBLE 1
8845 +#define ENTITYISHIGHLIGHTED 2
8846 +#define ENTITYISDRAWABLE 4
8848 +#define OCCGEOMETRYVISUALIZATIONNOCHANGE 0
8849 +#define OCCGEOMETRYVISUALIZATIONFULLCHANGE 1 // Compute transformation matrices and redraw
8850 +#define OCCGEOMETRYVISUALIZATIONHALFCHANGE 2 // Redraw
8854 + class EntityVisualizationCode
8860 + EntityVisualizationCode()
8861 + { code = ENTITYISVISIBLE + !ENTITYISHIGHLIGHTED + ENTITYISDRAWABLE;}
8864 + { return code & ENTITYISVISIBLE;}
8866 + int IsHighlighted ()
8867 + { return code & ENTITYISHIGHLIGHTED;}
8870 + { return code & ENTITYISDRAWABLE;}
8873 + { code |= ENTITYISVISIBLE;}
8876 + { code &= ~ENTITYISVISIBLE;}
8879 + { code |= ENTITYISHIGHLIGHTED;}
8882 + { code &= ~ENTITYISHIGHLIGHTED;}
8884 + void SetDrawable ()
8885 + { code |= ENTITYISDRAWABLE;}
8887 + void SetNotDrawable ()
8888 + { code &= ~ENTITYISDRAWABLE;}
8898 + double Dist (Line l);
8905 + inline double Det3 (double a00, double a01, double a02,
8906 + double a10, double a11, double a12,
8907 + double a20, double a21, double a22)
8909 + return a00*a11*a22 + a01*a12*a20 + a10*a21*a02 - a20*a11*a02 - a10*a01*a22 - a21*a12*a00;
8915 + class DLL_HEADER OCCGeometry : public NetgenGeometry
8918 + // -- Optimization: to use cached projector and classifier
8919 + mutable NCollection_DataMap<int,Handle(ShapeAnalysis_Surface)> fprjmap;
8920 + mutable NCollection_DataMap<int,BRepTopAdaptor_FClass2d*> fclsmap;
8923 + TopoDS_Shape shape;
8924 + TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap;
8925 + Array<bool> fsingular, esingular, vsingular;
8926 + Box<3> boundingbox;
8928 + // Philippose - 29/01/2009
8929 + // OpenCascade XDE Support
8930 + // XCAF Handle to make the face colours available to the rest of
8932 + Handle(XCAFDoc_ColorTool) face_colours;
8934 + mutable int changed;
8935 + Array<int> facemeshstatus;
8937 + // Philippose - 15/01/2009
8938 + // Maximum mesh size for a given face
8939 + // (Used to explicitly define mesh size limits on individual faces)
8940 + Array<double> face_maxh;
8942 + // Philippose - 14/01/2010
8943 + // Boolean array to detect whether a face has been explicitly modified
8944 + // by the user or not
8945 + Array<bool> face_maxh_modified;
8947 + // Philippose - 15/01/2009
8948 + // Indicates which faces have been selected by the user in geometry mode
8949 + // (Currently handles only selection of one face at a time, but an array would
8950 + // help to extend this to multiple faces)
8951 + Array<bool> face_sel_status;
8953 + Array<EntityVisualizationCode> fvispar, evispar, vvispar;
8956 + bool fixsmalledges;
8957 + bool fixspotstripfaces;
8960 + bool splitpartitions;
8973 + virtual void Save (string filename) const;
8976 + ~OCCGeometry(); // -- to free cached projector and classifier
8980 + Box<3> GetBoundingBox()
8981 + { return boundingbox;}
8984 + { return somap.Extent();}
8986 + // Philippose - 17/01/2009
8987 + // Total number of faces in the geometry
8989 + { return fmap.Extent();}
8992 + { center = boundingbox.Center();}
8997 + // void Project (int surfi, Point<3> & p) const; -- optimization
8998 + bool Project (int surfi, Point<3> & p, double& u, double& v) const;
8999 + bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
9001 + // -- Optimization: to use cached projector and classifier
9002 + void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
9003 + BRepTopAdaptor_FClass2d*& cls) const;
9005 + OCCSurface GetSurface (int surfi)
9007 + std::cout << "OCCGeometry::GetSurface using PLANESPACE" << std::endl;
9008 + return OCCSurface (TopoDS::Face(fmap(surfi)), PLANESPACE);
9011 + void CalcBoundingBox ();
9012 + void BuildVisualizationMesh (double deflection);
9014 + void RecursiveTopologyTree (const TopoDS_Shape & sh,
9015 + stringstream & str,
9016 + TopAbs_ShapeEnum l,
9018 + const char * lname);
9020 + void GetTopologyTree (stringstream & str);
9022 + void PrintNrShapes ();
9024 + void CheckIrregularEntities (stringstream & str);
9030 + void HealGeometry();
9032 + // Philippose - 15/01/2009
9033 + // Sets the maximum mesh size for a given face
9034 + // (Note: Local mesh size limited by the global max mesh size)
9035 + void SetFaceMaxH(int facenr, double faceh)
9037 + if((facenr> 0) && (facenr <= fmap.Extent()))
9039 + face_maxh[facenr-1] = min(mparam.maxh,faceh);
9041 + // Philippose - 14/01/2010
9042 + // If the face maxh is greater than or equal to the
9043 + // current global maximum, then identify the face as
9044 + // not explicitly controlled by the user any more
9045 + if(faceh >= mparam.maxh)
9047 + face_maxh_modified[facenr-1] = 0;
9051 + face_maxh_modified[facenr-1] = 1;
9056 + // Philippose - 15/01/2009
9057 + // Returns the local mesh size of a given face
9058 + double GetFaceMaxH(int facenr)
9060 + if((facenr> 0) && (facenr <= fmap.Extent()))
9062 + return face_maxh[facenr-1];
9070 + // Philippose - 14/01/2010
9071 + // Returns the flag whether the given face
9072 + // has a mesh size controlled by the user or not
9073 + bool GetFaceMaxhModified(int facenr)
9075 + return face_maxh_modified[facenr-1];
9078 + // Philippose - 17/01/2009
9079 + // Returns the index of the currently selected face
9080 + int SelectedFace()
9084 + for(i = 1; i <= fmap.Extent(); i++)
9086 + if(face_sel_status[i-1])
9095 + // Philippose - 17/01/2009
9096 + // Sets the currently selected face
9097 + void SetSelectedFace(int facenr)
9099 + face_sel_status = 0;
9101 + if((facenr >= 1) && (facenr <= fmap.Extent()))
9103 + face_sel_status[facenr-1] = 1;
9107 + void LowLightAll()
9109 + for (int i = 1; i <= fmap.Extent(); i++)
9110 + fvispar[i-1].Lowlight();
9111 + for (int i = 1; i <= emap.Extent(); i++)
9112 + evispar[i-1].Lowlight();
9113 + for (int i = 1; i <= vmap.Extent(); i++)
9114 + vvispar[i-1].Lowlight();
9117 + void GetUnmeshedFaceInfo (stringstream & str);
9118 + void GetNotDrawableFaces (stringstream & str);
9119 + bool ErrorInSurfaceMeshing ();
9121 + void WriteOCC_STL(char * filename);
9123 + virtual int GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
9124 + int perfstepsstart, int perfstepsend);
9126 + virtual const Refinement & GetRefinement () const;
9131 + class DLL_HEADER OCCParameters
9135 + /// Factor for meshing close edges
9136 + double resthcloseedgefac;
9139 + /// Enable / Disable detection of close edges
9140 + int resthcloseedgeenable;
9143 + /// Minimum edge length to be used for dividing edges to mesh points
9144 + double resthminedgelen;
9147 + /// Enable / Disable use of the minimum edge length (by default use 1e-4)
9148 + int resthminedgelenenable;
9151 + Default Constructor for the OpenCascade
9152 + Mesh generation parameter set
9158 + Dump all the OpenCascade specific meshing parameters
9161 + void Print (ostream & ost) const;
9165 + void PrintContents (OCCGeometry * geom);
9167 + OCCGeometry * LoadOCC_IGES (const char * filename);
9168 + OCCGeometry * LoadOCC_STEP (const char * filename);
9169 + OCCGeometry * LoadOCC_BREP (const char * filename);
9171 + extern DLL_HEADER OCCParameters occparam;
9174 + // Philippose - 31.09.2009
9175 + // External access to the mesh generation functions within the OCC
9176 + // subsystem (Not sure if this is the best way to implement this....!!)
9177 + extern DLL_HEADER int OCCGenerateMesh (OCCGeometry & occgeometry, Mesh*& mesh,
9178 + MeshingParameters & mparam,
9179 + int perfstepsstart, int perfstepsend);
9181 + extern DLL_HEADER void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh);
9183 + extern DLL_HEADER void OCCMeshSurface (OCCGeometry & geom, Mesh & mesh, int perfstepsend);
9185 + extern DLL_HEADER void OCCFindEdges (OCCGeometry & geom, Mesh & mesh);
9192 +++ netgen/libsrc/occ/occgeom.hpp.orig
9194 +#ifndef FILE_OCCGEOM
9195 +#define FILE_OCCGEOM
9197 +/* *************************************************************************/
9198 +/* File: occgeom.hpp */
9199 +/* Author: Robert Gaisbauer */
9200 +/* Date: 26. May 03 */
9201 +/* *************************************************************************/
9205 +#include <meshing.hpp>
9207 +#include "BRep_Tool.hxx"
9208 +#include "Geom_Curve.hxx"
9209 +#include "Geom2d_Curve.hxx"
9210 +#include "Geom_Surface.hxx"
9211 +#include "GeomAPI_ProjectPointOnSurf.hxx"
9212 +#include "GeomAPI_ProjectPointOnCurve.hxx"
9213 +#include "BRepTools.hxx"
9214 +#include "TopExp.hxx"
9215 +#include "BRepBuilderAPI_MakeVertex.hxx"
9216 +#include "BRepBuilderAPI_MakeShell.hxx"
9217 +#include "BRepBuilderAPI_MakeSolid.hxx"
9218 +#include "BRepOffsetAPI_Sewing.hxx"
9219 +#include "BRepLProp_SLProps.hxx"
9220 +#include "BRepAdaptor_Surface.hxx"
9221 +#include "Poly_Triangulation.hxx"
9222 +#include "Poly_Array1OfTriangle.hxx"
9223 +#include "TColgp_Array1OfPnt2d.hxx"
9224 +#include "Poly_Triangle.hxx"
9225 +#include "GProp_GProps.hxx"
9226 +#include "BRepGProp.hxx"
9227 +#include "Geom_Surface.hxx"
9228 +#include "TopExp.hxx"
9229 +#include "gp_Pnt.hxx"
9230 +#include "TopoDS.hxx"
9231 +#include "TopoDS_Solid.hxx"
9232 +#include "TopExp_Explorer.hxx"
9233 +#include "TopTools_ListIteratorOfListOfShape.hxx"
9234 +#include "BRep_Tool.hxx"
9235 +#include "Geom_Curve.hxx"
9236 +#include "Geom2d_Curve.hxx"
9237 +#include "Geom_Surface.hxx"
9238 +#include "GeomAPI_ProjectPointOnSurf.hxx"
9239 +#include "GeomAPI_ProjectPointOnCurve.hxx"
9240 +#include "TopoDS_Wire.hxx"
9241 +#include "BRepTools_WireExplorer.hxx"
9242 +#include "BRepTools.hxx"
9243 +#include "TopTools_IndexedMapOfShape.hxx"
9244 +#include "TopExp.hxx"
9245 +#include "BRepBuilderAPI_MakeVertex.hxx"
9246 +#include "BRepBuilderAPI_MakeShell.hxx"
9247 +#include "BRepBuilderAPI_MakeSolid.hxx"
9248 +#include "BRepOffsetAPI_Sewing.hxx"
9249 +#include "BRepLProp_CLProps.hxx"
9250 +#include "BRepLProp_SLProps.hxx"
9251 +#include "BRepAdaptor_Surface.hxx"
9252 +#include "BRepAdaptor_Curve.hxx"
9253 +#include "Poly_Triangulation.hxx"
9254 +#include "Poly_Array1OfTriangle.hxx"
9255 +#include "TColgp_Array1OfPnt2d.hxx"
9256 +#include "Poly_Triangle.hxx"
9257 +#include "GProp_GProps.hxx"
9258 +#include "BRepGProp.hxx"
9259 +#include "TopoDS_Shape.hxx"
9260 +#include "TopoDS_Face.hxx"
9261 +#include "IGESToBRep_Reader.hxx"
9262 +#include "Interface_Static.hxx"
9263 +#include "GeomAPI_ExtremaCurveCurve.hxx"
9264 +#include "Standard_ErrorHandler.hxx"
9265 +#include "Standard_Failure.hxx"
9266 +#include "ShapeUpgrade_ShellSewing.hxx"
9267 +#include "ShapeFix_Shape.hxx"
9268 +#include "ShapeFix_Wireframe.hxx"
9269 +#include "BRepMesh.hxx"
9270 +#include "BRepMesh_IncrementalMesh.hxx"
9271 +#include "BRepBndLib.hxx"
9272 +#include "Bnd_Box.hxx"
9273 +#include "ShapeAnalysis.hxx"
9274 +#include "ShapeBuild_ReShape.hxx"
9277 +// Philippose - 29/01/2009
9278 +// OpenCascade XDE Support
9279 +// Include support for OpenCascade XDE Features
9280 +#include "TDocStd_Document.hxx"
9281 +#include "Quantity_Color.hxx"
9282 +#include "XCAFApp_Application.hxx"
9283 +#include "XCAFDoc_ShapeTool.hxx"
9284 +#include "XCAFDoc_Color.hxx"
9285 +#include "XCAFDoc_ColorTool.hxx"
9286 +#include "XCAFDoc_ColorType.hxx"
9287 +#include "XCAFDoc_LayerTool.hxx"
9288 +#include "XCAFDoc_DimTolTool.hxx"
9289 +#include "XCAFDoc_MaterialTool.hxx"
9290 +#include "XCAFDoc_DocumentTool.hxx"
9291 +#include "TDF_Label.hxx"
9292 +#include "TDF_LabelSequence.hxx"
9293 +#include "STEPCAFControl_Reader.hxx"
9294 +#include "STEPCAFControl_Writer.hxx"
9295 +#include "IGESCAFControl_Reader.hxx"
9296 +#include "IGESCAFControl_Writer.hxx"
9298 +#include "IGESControl_Reader.hxx"
9299 +#include "STEPControl_Reader.hxx"
9300 +#include "IGESControl_Writer.hxx"
9301 +#include "STEPControl_Writer.hxx"
9303 +#include "StlAPI_Writer.hxx"
9304 +#include "STEPControl_StepModelType.hxx"
9308 +#include "occmeshsurf.hpp"
9310 + extern DLL_HEADER MeshingParameters mparam;
9312 +#define PROJECTION_TOLERANCE 1e-10
9314 +#define ENTITYISVISIBLE 1
9315 +#define ENTITYISHIGHLIGHTED 2
9316 +#define ENTITYISDRAWABLE 4
9318 +#define OCCGEOMETRYVISUALIZATIONNOCHANGE 0
9319 +#define OCCGEOMETRYVISUALIZATIONFULLCHANGE 1 // Compute transformation matrices and redraw
9320 +#define OCCGEOMETRYVISUALIZATIONHALFCHANGE 2 // Redraw
9324 + class EntityVisualizationCode
9330 + EntityVisualizationCode()
9331 + { code = ENTITYISVISIBLE + !ENTITYISHIGHLIGHTED + ENTITYISDRAWABLE;}
9334 + { return code & ENTITYISVISIBLE;}
9336 + int IsHighlighted ()
9337 + { return code & ENTITYISHIGHLIGHTED;}
9340 + { return code & ENTITYISDRAWABLE;}
9343 + { code |= ENTITYISVISIBLE;}
9346 + { code &= ~ENTITYISVISIBLE;}
9349 + { code |= ENTITYISHIGHLIGHTED;}
9352 + { code &= ~ENTITYISHIGHLIGHTED;}
9354 + void SetDrawable ()
9355 + { code |= ENTITYISDRAWABLE;}
9357 + void SetNotDrawable ()
9358 + { code &= ~ENTITYISDRAWABLE;}
9368 + double Dist (Line l);
9375 + inline double Det3 (double a00, double a01, double a02,
9376 + double a10, double a11, double a12,
9377 + double a20, double a21, double a22)
9379 + return a00*a11*a22 + a01*a12*a20 + a10*a21*a02 - a20*a11*a02 - a10*a01*a22 - a21*a12*a00;
9385 + class OCCGeometry : public NetgenGeometry
9390 + TopoDS_Shape shape;
9391 + TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap;
9392 + Array<bool> fsingular, esingular, vsingular;
9393 + Box<3> boundingbox;
9395 + // Philippose - 29/01/2009
9396 + // OpenCascade XDE Support
9397 + // XCAF Handle to make the face colours available to the rest of
9399 + Handle_XCAFDoc_ColorTool face_colours;
9401 + mutable int changed;
9402 + Array<int> facemeshstatus;
9404 + // Philippose - 15/01/2009
9405 + // Maximum mesh size for a given face
9406 + // (Used to explicitly define mesh size limits on individual faces)
9407 + Array<double> face_maxh;
9409 + // Philippose - 14/01/2010
9410 + // Boolean array to detect whether a face has been explicitly modified
9411 + // by the user or not
9412 + Array<bool> face_maxh_modified;
9414 + // Philippose - 15/01/2009
9415 + // Indicates which faces have been selected by the user in geometry mode
9416 + // (Currently handles only selection of one face at a time, but an array would
9417 + // help to extend this to multiple faces)
9418 + Array<bool> face_sel_status;
9420 + Array<EntityVisualizationCode> fvispar, evispar, vvispar;
9423 + bool fixsmalledges;
9424 + bool fixspotstripfaces;
9427 + bool splitpartitions;
9440 + virtual void Save (string filename) const;
9445 + Box<3> GetBoundingBox()
9446 + { return boundingbox;}
9449 + { return somap.Extent();}
9451 + // Philippose - 17/01/2009
9452 + // Total number of faces in the geometry
9454 + { return fmap.Extent();}
9457 + { center = boundingbox.Center();}
9462 + void Project (int surfi, Point<3> & p) const;
9463 + bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
9465 + OCCSurface GetSurface (int surfi)
9467 + cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;
9468 + return OCCSurface (TopoDS::Face(fmap(surfi)), PLANESPACE);
9471 + void CalcBoundingBox ();
9472 + void BuildVisualizationMesh (double deflection);
9474 + void RecursiveTopologyTree (const TopoDS_Shape & sh,
9475 + stringstream & str,
9476 + TopAbs_ShapeEnum l,
9478 + const char * lname);
9480 + void GetTopologyTree (stringstream & str);
9482 + void PrintNrShapes ();
9484 + void CheckIrregularEntities (stringstream & str);
9490 + void HealGeometry();
9492 + // Philippose - 15/01/2009
9493 + // Sets the maximum mesh size for a given face
9494 + // (Note: Local mesh size limited by the global max mesh size)
9495 + void SetFaceMaxH(int facenr, double faceh)
9497 + if((facenr> 0) && (facenr <= fmap.Extent()))
9499 + face_maxh[facenr-1] = min(mparam.maxh,faceh);
9501 + // Philippose - 14/01/2010
9502 + // If the face maxh is greater than or equal to the
9503 + // current global maximum, then identify the face as
9504 + // not explicitly controlled by the user any more
9505 + if(faceh >= mparam.maxh)
9507 + face_maxh_modified[facenr-1] = 0;
9511 + face_maxh_modified[facenr-1] = 1;
9516 + // Philippose - 15/01/2009
9517 + // Returns the local mesh size of a given face
9518 + double GetFaceMaxH(int facenr)
9520 + if((facenr> 0) && (facenr <= fmap.Extent()))
9522 + return face_maxh[facenr-1];
9530 + // Philippose - 14/01/2010
9531 + // Returns the flag whether the given face
9532 + // has a mesh size controlled by the user or not
9533 + bool GetFaceMaxhModified(int facenr)
9535 + return face_maxh_modified[facenr-1];
9538 + // Philippose - 17/01/2009
9539 + // Returns the index of the currently selected face
9540 + int SelectedFace()
9544 + for(i = 1; i <= fmap.Extent(); i++)
9546 + if(face_sel_status[i-1])
9555 + // Philippose - 17/01/2009
9556 + // Sets the currently selected face
9557 + void SetSelectedFace(int facenr)
9559 + face_sel_status = 0;
9561 + if((facenr >= 1) && (facenr <= fmap.Extent()))
9563 + face_sel_status[facenr-1] = 1;
9567 + void LowLightAll()
9569 + for (int i = 1; i <= fmap.Extent(); i++)
9570 + fvispar[i-1].Lowlight();
9571 + for (int i = 1; i <= emap.Extent(); i++)
9572 + evispar[i-1].Lowlight();
9573 + for (int i = 1; i <= vmap.Extent(); i++)
9574 + vvispar[i-1].Lowlight();
9577 + void GetUnmeshedFaceInfo (stringstream & str);
9578 + void GetNotDrawableFaces (stringstream & str);
9579 + bool ErrorInSurfaceMeshing ();
9581 + void WriteOCC_STL(char * filename);
9583 + virtual int GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
9584 + int perfstepsstart, int perfstepsend);
9586 + virtual const Refinement & GetRefinement () const;
9591 + class OCCParameters
9595 + /// Factor for meshing close edges
9596 + double resthcloseedgefac;
9599 + /// Enable / Disable detection of close edges
9600 + int resthcloseedgeenable;
9603 + /// Minimum edge length to be used for dividing edges to mesh points
9604 + double resthminedgelen;
9607 + /// Enable / Disable use of the minimum edge length (by default use 1e-4)
9608 + int resthminedgelenenable;
9611 + Default Constructor for the OpenCascade
9612 + Mesh generation parameter set
9618 + Dump all the OpenCascade specific meshing parameters
9621 + void Print (ostream & ost) const;
9625 + void PrintContents (OCCGeometry * geom);
9627 + OCCGeometry * LoadOCC_IGES (const char * filename);
9628 + OCCGeometry * LoadOCC_STEP (const char * filename);
9629 + OCCGeometry * LoadOCC_BREP (const char * filename);
9631 + extern OCCParameters occparam;
9634 + // Philippose - 31.09.2009
9635 + // External access to the mesh generation functions within the OCC
9636 + // subsystem (Not sure if this is the best way to implement this....!!)
9637 + extern int OCCGenerateMesh (OCCGeometry & occgeometry, Mesh*& mesh,
9638 + MeshingParameters & mparam,
9639 + int perfstepsstart, int perfstepsend);
9641 + extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh);
9643 + extern void OCCMeshSurface (OCCGeometry & geom, Mesh & mesh, int perfstepsend);
9645 + extern void OCCFindEdges (OCCGeometry & geom, Mesh & mesh);
9651 --- netgen_ref/libsrc/occ/occmeshsurf.cpp
9652 +++ netgen/libsrc/occ/occmeshsurf.cpp
9654 #include <meshing.hpp>
9655 #include <GeomLProp_SLProps.hxx>
9656 #include <ShapeAnalysis_Surface.hxx>
9657 +#include <GeomAPI_ProjectPointOnCurve.hxx> // -- moved here from occgeom.hpp
9666 + else if ( lprop.IsNormalDefined() )
9668 n(0)=lprop.Normal().X();
9669 n(1)=lprop.Normal().Y();
9670 n(2)=lprop.Normal().Z();
9679 (*testout) << "u " << geominfo.u << " v " << geominfo.v
9680 << " du " << lprop.D1U().X() << " "<< lprop.D1U().Y() << " "<< lprop.D1U().Z()
9681 - << " dv " << lprop.D1V().X() << " "<< lprop.D1V().Y() << " "<< lprop.D1V().Z() << endl;
9682 + << " dv " << lprop.D1V().X() << " "<< lprop.D1V().Y() << " "<< lprop.D1V().Z() << std::endl;
9687 if (orient == TopAbs_REVERSED) n = -1*n;
9688 - // (*testout) << "GetNormalVector" << endl;
9689 + // (*testout) << "GetNormalVector" << std::endl;
9697 - //cout << "p1 = " << p1 << endl;
9698 - //cout << "p2 = " << p2 << endl;
9699 + //std::cout << "p1 = " << p1 << std::endl;
9700 + //std::cout << "p2 = " << p2 << std::endl;
9702 GetNormalVector (p1, geominfo1, ez);
9706 ey = Cross (ez, ex);
9708 - //cout << "ex " << ex << " ey " << ey << " ez " << ez << endl;
9709 + //std::cout << "ex " << ex << " ey " << ey << " ez " << ez << std::endl;
9714 D1(0,1) = dv.X(); D1(1,1) = dv.Y(); D1(2,1) = dv.Z();
9717 - (*testout) << "DefineTangentialPlane" << endl
9718 - << "---------------------" << endl;
9719 - (*testout) << "D1 = " << endl << D1 << endl;
9720 + (*testout) << "DefineTangentialPlane" << std::endl
9721 + << "---------------------" << std::endl;
9722 + (*testout) << "D1 = " << std::endl << D1 << std::endl;
9725 Transpose (D1, D1T);
9730 - (*testout) << "zone = -1 for " << p3d << " 2D: " << pplane << " n " << n << " nmid " << nmid << endl;
9731 + (*testout) << "zone = -1 for " << p3d << " 2D: " << pplane << " n " << n << " nmid " << nmid << std::endl;
9732 glob_testout = true;
9733 GetNormalVector (p3d, geominfo, n);
9734 glob_testout = false;
9738 pplane = Point<2>(geominfo.u, geominfo.v);
9739 - // (*testout) << "(u,v) = " << geominfo.u << ", " << geominfo.v << endl;
9740 + // (*testout) << "(u,v) = " << geominfo.u << ", " << geominfo.v << std::endl;
9741 pplane = Point<2> (1/h * (Amatinv * (pplane-psp1)));
9742 // pplane = Point<2> (h * (Amatinv * (pplane-psp1)));
9743 // pplane = Point<2> (1/h * ((pplane-psp1)));
9744 @@ -297,11 +301,11 @@
9746 if (projecttype == PLANESPACE)
9748 - // cout << "2d : " << pplane << endl;
9749 + // std::cout << "2d : " << pplane << std::endl;
9750 p3d = p1 + (h * pplane(0)) * ex + (h * pplane(1)) * ey;
9751 - // cout << "3d : " << p3d << endl;
9752 + // std::cout << "3d : " << p3d << std::endl;
9754 - // cout << "proj : " << p3d << endl;
9755 + // std::cout << "proj : " << p3d << std::endl;
9759 @@ -321,11 +325,11 @@
9760 void OCCSurface :: Project (Point<3> & p, PointGeomInfo & gi)
9762 // static int cnt = 0;
9763 - // if (cnt++ % 1000 == 0) cout << "********************************************** OCCSurfce :: Project, cnt = " << cnt << endl;
9764 + // if (cnt++ % 1000 == 0) std::cout << "********************************************** OCCSurfce :: Project, cnt = " << cnt << std::endl;
9766 gp_Pnt pnt(p(0), p(1), p(2));
9768 - //(*testout) << "pnt = " << pnt.X() << ", " << pnt.Y() << ", " << pnt.Z() << endl;
9769 + //(*testout) << "pnt = " << pnt.X() << ", " << pnt.Y() << ", " << pnt.Z() << std::endl;
9775 if (!proj.NbPoints())
9777 - cout << "Project Point on Surface FAIL" << endl;
9778 + std::cout << "Project Point on Surface FAIL" << std::endl;
9779 throw UVBoundsException();
9782 @@ -343,13 +347,13 @@
9786 - cout << "NP = " << proj.NbPoints() << endl;
9787 + std::cout << "NP = " << proj.NbPoints() << std::endl;
9789 for (int i = 1; i <= proj.NbPoints(); i++)
9791 gp_Pnt pnt2 = proj.Point(i);
9792 Point<3> p2 = Point<3> (pnt2.X(), pnt2.Y(), pnt2.Z());
9793 - cout << i << ". p = " << p2 << ", dist = " << (p2-p).Length() << endl;
9794 + std::cout << i << ". p = " << p2 << ", dist = " << (p2-p).Length() << std::endl;
9800 pnt = occface->Value( u, v );
9802 - //(*testout) << "pnt(proj) = " << pnt.X() << ", " << pnt.Y() << ", " << pnt.Z() << endl;
9803 + //(*testout) << "pnt(proj) = " << pnt.X() << ", " << pnt.Y() << ", " << pnt.Z() << std::endl;
9807 @@ -434,23 +438,33 @@
9809 void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const
9811 - geometry.Project (surfind, p);
9812 + // geometry.Project (surfind, p); -- signature of Project() changed for optimization
9814 + geometry.Project (surfind, p, u, v);
9818 int MeshOptimize2dOCCSurfaces :: ProjectPointGI (INDEX surfind, Point<3> & p, PointGeomInfo & gi) const
9822 + //double u = gi.u;
9823 + //double v = gi.v;
9826 - if (geometry.FastProject (surfind, hp, u, v))
9828 + // -- u and v are computed by FastProject() and Project(), no need to call CalcPointGeomInfo()
9829 + // if (geometry.FastProject (surfind, hp, u, v))
9834 + // ProjectPoint (surfind, p);
9835 + // return CalcPointGeomInfo (surfind, gi, p);
9837 + if (gi.trignum > 0)
9838 + ok = geometry.FastProject (surfind, hp, gi.u, gi.v);
9840 + ok = geometry.Project (surfind, hp, gi.u, gi.v);
9844 - ProjectPoint (surfind, p);
9845 - return CalcPointGeomInfo (surfind, gi, p);
9851 GetNormalVector(INDEX surfind, const Point<3> & p, Vec<3> & n) const
9853 // static int cnt = 0;
9854 - // if (cnt++ % 1000 == 0) cout << "GetNV cnt = " << cnt << endl;
9855 + // if (cnt++ % 1000 == 0) std::cout << "GetNV cnt = " << cnt << std::endl;
9858 gp_Pnt pnt(p(0), p(1), p(2));
9861 if (proj.NbPoints() < 1)
9863 - cout << "ERROR: OCCSurface :: GetNormalVector: GeomAPI_ProjectPointOnSurf failed!"
9865 - cout << p << endl;
9866 + std::cout << "ERROR: OCCSurface :: GetNormalVector: GeomAPI_ProjectPointOnSurf failed!"
9868 + std::cout << p << std::endl;
9875 if (!occface->IsCNu (1) || !occface->IsCNv (1))
9876 - (*testout) << "SurfOpt: Differentiation FAIL" << endl;
9877 + (*testout) << "SurfOpt: Differentiation FAIL" << std::endl;
9880 n = Cross (Vec3d(du.X(), du.Y(), du.Z()),
9883 if (proj.NbPoints() < 1)
9885 - cout << "ERROR: OCCSurface :: GetNormalVector: GeomAPI_ProjectPointOnSurf failed!"
9887 - cout << p << endl;
9888 + std::cout << "ERROR: OCCSurface :: GetNormalVector: GeomAPI_ProjectPointOnSurf failed!"
9890 + std::cout << p << std::endl;
9896 if (!geometry.FastProject (surfi, hnewp, u, v))
9898 - // cout << "Fast projection to surface fails! Using OCC projection" << endl;
9899 - geometry.Project (surfi, hnewp);
9900 + // std::cout << "Fast projection to surface fails! Using OCC projection" << std::endl;
9901 + // geometry.Project (surfi, hnewp); -- Project() changed for optimization
9902 + geometry.Project (surfi, hnewp, u, v);
9911 + }//; -- to compile with -Wall -pedantic
9914 void OCCRefinementSurfaces ::
9915 @@ -708,24 +723,29 @@
9916 hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
9920 + }//; -- to compile with -Wall -pedantic
9923 void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi) const
9926 - geometry.Project (surfi, p);
9928 + //geometry.Project (surfi, p);
9931 + geometry.Project (surfi, p, u, v);
9933 + }//; -- to compile with -Wall -pedantic
9935 void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) const
9938 if (!geometry.FastProject (surfi, p, gi.u, gi.v))
9940 - cout << "Fast projection to surface fails! Using OCC projection" << endl;
9941 - geometry.Project (surfi, p);
9942 + std::cout << "Fast projection to surface fails! Using OCC projection" << std::endl;
9944 + geometry.Project (surfi, p, u, v);
9951 --- netgen_ref/libsrc/occ/occmeshsurf.hpp
9952 +++ netgen/libsrc/occ/occmeshsurf.hpp
9957 -class OCCRefinementSurfaces : public Refinement
9958 +class DLL_HEADER OCCRefinementSurfaces : public Refinement
9960 const OCCGeometry & geometry;
9962 --- netgen_ref/libsrc/occ/occpkg.cpp
9963 +++ netgen/libsrc/occ/occpkg.cpp
9964 @@ -1,1024 +1,1024 @@
9967 -#include <mystdlib.h>
9968 -#include <myadt.hpp>
9969 -#include <linalg.hpp>
9971 -#include <occgeom.hpp>
9974 -#include <incvis.hpp>
9975 -#include <visual.hpp>
9977 -#include "../meshing/bcfunctions.hpp"
9979 -#include "vsocc.hpp"
9982 -extern "C" int Ng_occ_Init (Tcl_Interp * interp);
9988 - extern AutoPtr<NetgenGeometry> ng_geometry;
9989 - extern AutoPtr<Mesh> mesh;
9991 - char * err_needsoccgeometry = (char*) "This operation needs an OCC geometry";
9992 - extern char * err_needsmesh;
9993 - extern char * err_jobrunning;
9998 - class OCCGeometryRegister : public GeometryRegister
10001 - virtual NetgenGeometry * Load (string filename) const;
10002 - virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
10004 - virtual void SetParameters (Tcl_Interp * interp)
10006 - occparam.resthcloseedgefac =
10007 - atof (Tcl_GetVar (interp, "::stloptions.resthcloseedgefac", 0));
10008 - occparam.resthcloseedgeenable =
10009 - atoi (Tcl_GetVar (interp, "::stloptions.resthcloseedgeenable", 0));
10010 - occparam.resthminedgelen =
10011 - atof (Tcl_GetVar (interp, "::stloptions.resthminedgelen", 0));
10012 - occparam.resthminedgelenenable =
10013 - atoi (Tcl_GetVar (interp, "::stloptions.resthminedgelenenable", 0));
10020 - int Ng_SetOCCVisParameters (ClientData clientData,
10021 - Tcl_Interp * interp,
10022 - int argc, tcl_const char *argv[])
10024 -#ifdef OCCGEOMETRY
10026 - OCCGeometry * occgeometry = dynamic_cast<OCCGeometry*> (ng_geometry.Ptr());
10028 - showvolume = atoi (Tcl_GetVar (interp, "::occoptions.showvolumenr", 0));
10031 - if (showvolume != vispar.occshowvolumenr)
10033 - if (showvolume < 0 || showvolume > occgeometry->NrSolids())
10036 - sprintf (buf, "%5i", vispar.occshowvolumenr);
10037 - Tcl_SetVar (interp, "::occoptions.showvolumenr", buf, 0);
10041 - vispar.occshowvolumenr = showvolume;
10043 - occgeometry -> changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10049 - temp = atoi (Tcl_GetVar (interp, "::occoptions.visproblemfaces", 0));
10051 - if ((bool) temp != vispar.occvisproblemfaces)
10053 - vispar.occvisproblemfaces = temp;
10055 - occgeometry -> changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10058 - vispar.occshowsurfaces = atoi (Tcl_GetVar (interp, "::occoptions.showsurfaces", 0));
10059 - vispar.occshowedges = atoi (Tcl_GetVar (interp, "::occoptions.showedges", 0));
10060 - vispar.occzoomtohighlightedentity = atoi (Tcl_GetVar (interp, "::occoptions.zoomtohighlightedentity", 0));
10061 - vispar.occdeflection = pow(10.0,-1-atof (Tcl_GetVar (interp, "::occoptions.deflection", 0)));
10070 - vispar.ACISshowfaces = atoi (Tcl_GetVar (interp, "::occoptions.showsurfaces", 0));
10071 - vispar.ACISshowedges = atoi (Tcl_GetVar (interp, "::occoptions.showedges", 0));
10072 - vispar.ACISshowsolidnr = atoi (Tcl_GetVar (interp, "::occoptions.showsolidnr", 0));
10073 - vispar.ACISshowsolidnr2 = atoi (Tcl_GetVar (interp, "::occoptions.showsolidnr2", 0));
10085 - int Ng_GetOCCData (ClientData clientData,
10086 - Tcl_Interp * interp,
10087 - int argc, tcl_const char *argv[])
10089 -#ifdef OCCGEOMETRY
10090 - OCCGeometry * occgeometry = dynamic_cast<OCCGeometry*> (ng_geometry.Ptr());
10092 - static char buf[1000];
10094 - stringstream str;
10098 - if (strcmp (argv[1], "getentities") == 0)
10102 - occgeometry->GetTopologyTree(str);
10107 - Tcl_SetResult (interp, (char*)str.str().c_str(), TCL_VOLATILE);
10115 - int Ng_OCCCommand (ClientData clientData,
10116 - Tcl_Interp * interp,
10117 - int argc, tcl_const char *argv[])
10119 -#ifdef OCCGEOMETRY
10120 - OCCGeometry * occgeometry = dynamic_cast<OCCGeometry*> (ng_geometry.Ptr());
10122 - stringstream str;
10125 - if (strcmp (argv[1], "isoccgeometryloaded") == 0)
10128 - str << "1 " << flush;
10129 - else str << "0 " << flush;
10131 - Tcl_SetResult (interp, (char*)str.str().c_str(), TCL_VOLATILE);
10135 - if (strcmp (argv[1], "buildvisualizationmesh") == 0)
10137 - occgeometry->BuildVisualizationMesh(vispar.occdeflection);
10138 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10140 - if (strcmp (argv[1], "mesherror") == 0)
10142 - if (occgeometry->ErrorInSurfaceMeshing())
10147 - if (strcmp (argv[1], "sewfaces") == 0)
10149 - cout << "Before operation:" << endl;
10150 - occgeometry->PrintNrShapes();
10151 - occgeometry->SewFaces();
10152 - occgeometry->BuildFMap();
10153 - cout << endl << "After operation:" << endl;
10154 - occgeometry->PrintNrShapes();
10155 - occgeometry->BuildVisualizationMesh(vispar.occdeflection);
10156 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10158 - if (strcmp (argv[1], "makesolid") == 0)
10160 - cout << "Before operation:" << endl;
10161 - occgeometry->PrintNrShapes();
10162 - occgeometry->MakeSolid();
10163 - occgeometry->BuildFMap();
10164 - cout << endl << "After operation:" << endl;
10165 - occgeometry->PrintNrShapes();
10166 - occgeometry->BuildVisualizationMesh(vispar.occdeflection);
10167 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10169 - if (strcmp (argv[1], "upgradetopology") == 0)
10171 - cout << "Before operation:" << endl;
10172 - occgeometry->PrintNrShapes();
10173 - occgeometry->SewFaces();
10174 - occgeometry->MakeSolid();
10175 - occgeometry->BuildFMap();
10176 - cout << endl << "After operation:" << endl;
10177 - occgeometry->PrintNrShapes();
10178 - occgeometry->BuildVisualizationMesh(vispar.occdeflection);
10179 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10181 - if (strcmp (argv[1], "shapehealing") == 0)
10183 - occgeometry->tolerance =
10184 - atof (Tcl_GetVar (interp, "::occoptions.tolerance", 0));
10185 - occgeometry->fixsmalledges =
10186 - atoi (Tcl_GetVar (interp, "::occoptions.fixsmalledges", 0));
10187 - occgeometry->fixspotstripfaces =
10188 - atoi (Tcl_GetVar (interp, "::occoptions.fixspotstripfaces", 0));
10189 - occgeometry->sewfaces =
10190 - atoi (Tcl_GetVar (interp, "::occoptions.sewfaces", 0));
10191 - occgeometry->makesolids =
10192 - atoi (Tcl_GetVar (interp, "::occoptions.makesolids", 0));
10193 - occgeometry->splitpartitions =
10194 - atoi (Tcl_GetVar (interp, "::occoptions.splitpartitions", 0));
10196 - // cout << "Before operation:" << endl;
10197 - // occgeometry->PrintNrShapes();
10198 - occgeometry->HealGeometry();
10199 - occgeometry->BuildFMap();
10200 - // cout << endl << "After operation:" << endl;
10201 - // occgeometry->PrintNrShapes();
10202 - occgeometry->BuildVisualizationMesh(vispar.occdeflection);
10203 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10207 - if (strcmp (argv[1], "highlightentity") == 0)
10209 - if (strcmp (argv[2], "Face") == 0)
10211 - int nr = atoi (argv[3]);
10212 - occgeometry->LowLightAll();
10214 - occgeometry->fvispar[nr-1].Highlight();
10215 - if (vispar.occzoomtohighlightedentity)
10216 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONFULLCHANGE;
10218 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10220 - if (strcmp (argv[2], "Shell") == 0)
10222 - int nr = atoi (argv[3]);
10223 - occgeometry->LowLightAll();
10225 - TopExp_Explorer exp;
10226 - for (exp.Init (occgeometry->shmap(nr), TopAbs_FACE);
10227 - exp.More(); exp.Next())
10229 - int i = occgeometry->fmap.FindIndex (TopoDS::Face(exp.Current()));
10230 - occgeometry->fvispar[i-1].Highlight();
10232 - if (vispar.occzoomtohighlightedentity)
10233 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONFULLCHANGE;
10235 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10237 - if (strcmp (argv[2], "Solid") == 0)
10239 - int nr = atoi (argv[3]);
10240 - occgeometry->LowLightAll();
10242 - TopExp_Explorer exp;
10243 - for (exp.Init (occgeometry->somap(nr), TopAbs_FACE);
10244 - exp.More(); exp.Next())
10246 - int i = occgeometry->fmap.FindIndex (TopoDS::Face(exp.Current()));
10247 - occgeometry->fvispar[i-1].Highlight();
10249 - if (vispar.occzoomtohighlightedentity)
10250 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONFULLCHANGE;
10252 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10255 - if (strcmp (argv[2], "CompSolid") == 0)
10257 - int nr = atoi (argv[3]);
10258 - occgeometry->LowLightAll();
10260 - TopExp_Explorer exp;
10261 - for (exp.Init (occgeometry->cmap(nr), TopAbs_FACE);
10262 - exp.More(); exp.Next())
10264 - int i = occgeometry->fmap.FindIndex (TopoDS::Face(exp.Current()));
10265 - occgeometry->fvispar[i-1].Highlight();
10267 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10271 - if (strcmp (argv[2], "Edge") == 0)
10273 - int nr = atoi (argv[3]);
10274 - occgeometry->LowLightAll();
10276 - occgeometry->evispar[nr-1].Highlight();
10277 - if (vispar.occzoomtohighlightedentity)
10278 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONFULLCHANGE;
10280 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10282 - if (strcmp (argv[2], "Wire") == 0)
10284 - int nr = atoi (argv[3]);
10285 - occgeometry->LowLightAll();
10287 - TopExp_Explorer exp;
10288 - for (exp.Init (occgeometry->wmap(nr), TopAbs_EDGE);
10289 - exp.More(); exp.Next())
10291 - int i = occgeometry->emap.FindIndex (TopoDS::Edge(exp.Current()));
10292 - occgeometry->evispar[i-1].Highlight();
10294 - if (vispar.occzoomtohighlightedentity)
10295 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONFULLCHANGE;
10297 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10300 - if (strcmp (argv[2], "Vertex") == 0)
10302 - int nr = atoi (argv[3]);
10303 - occgeometry->LowLightAll();
10305 - occgeometry->vvispar[nr-1].Highlight();
10306 - if (vispar.occzoomtohighlightedentity)
10307 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONFULLCHANGE;
10309 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10316 - if (strcmp (argv[1], "show") == 0)
10318 - int nr = atoi (argv[3]);
10319 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10321 - if (strcmp (argv[2], "Face") == 0)
10323 - occgeometry->fvispar[nr-1].Show();
10325 - if (strcmp (argv[2], "Shell") == 0)
10327 - TopExp_Explorer exp;
10328 - for (exp.Init (occgeometry->shmap(nr), TopAbs_FACE);
10329 - exp.More(); exp.Next())
10331 - int i = occgeometry->fmap.FindIndex (TopoDS::Face(exp.Current()));
10332 - occgeometry->fvispar[i-1].Show();
10335 - if (strcmp (argv[2], "Solid") == 0)
10337 - TopExp_Explorer exp;
10338 - for (exp.Init (occgeometry->somap(nr), TopAbs_FACE);
10339 - exp.More(); exp.Next())
10341 - int i = occgeometry->fmap.FindIndex (TopoDS::Face(exp.Current()));
10342 - occgeometry->fvispar[i-1].Show();
10345 - if (strcmp (argv[2], "Edge") == 0)
10347 - occgeometry->evispar[nr-1].Show();
10349 - if (strcmp (argv[2], "Wire") == 0)
10351 - TopExp_Explorer exp;
10352 - for (exp.Init (occgeometry->wmap(nr), TopAbs_EDGE);
10353 - exp.More(); exp.Next())
10355 - int i = occgeometry->emap.FindIndex (TopoDS::Edge(exp.Current()));
10356 - occgeometry->evispar[i-1].Show();
10362 - if (strcmp (argv[1], "hide") == 0)
10364 - int nr = atoi (argv[3]);
10365 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10367 - if (strcmp (argv[2], "Face") == 0)
10369 - occgeometry->fvispar[nr-1].Hide();
10371 - if (strcmp (argv[2], "Shell") == 0)
10373 - TopExp_Explorer exp;
10374 - for (exp.Init (occgeometry->shmap(nr), TopAbs_FACE);
10375 - exp.More(); exp.Next())
10377 - int i = occgeometry->fmap.FindIndex (TopoDS::Face(exp.Current()));
10378 - occgeometry->fvispar[i-1].Hide();
10381 - if (strcmp (argv[2], "Solid") == 0)
10383 - TopExp_Explorer exp;
10384 - for (exp.Init (occgeometry->somap(nr), TopAbs_FACE);
10385 - exp.More(); exp.Next())
10387 - int i = occgeometry->fmap.FindIndex (TopoDS::Face(exp.Current()));
10388 - occgeometry->fvispar[i-1].Hide();
10391 - if (strcmp (argv[2], "Edge") == 0)
10393 - occgeometry->evispar[nr-1].Hide();
10395 - if (strcmp (argv[2], "Wire") == 0)
10397 - TopExp_Explorer exp;
10398 - for (exp.Init (occgeometry->wmap(nr), TopAbs_EDGE);
10399 - exp.More(); exp.Next())
10401 - int i = occgeometry->emap.FindIndex (TopoDS::Edge(exp.Current()));
10402 - occgeometry->evispar[i-1].Hide();
10409 - if (strcmp (argv[1], "findsmallentities") == 0)
10411 - stringstream str("");
10412 - occgeometry->CheckIrregularEntities(str);
10413 - Tcl_SetResult (interp, (char*)str.str().c_str(), TCL_VOLATILE);
10415 - if (strcmp (argv[1], "getunmeshedfaceinfo") == 0)
10417 - occgeometry->GetUnmeshedFaceInfo(str);
10418 - Tcl_SetResult (interp, (char*)str.str().c_str(), TCL_VOLATILE);
10420 - if (strcmp (argv[1], "getnotdrawablefaces") == 0)
10422 - occgeometry->GetNotDrawableFaces(str);
10423 - Tcl_SetResult (interp, (char*)str.str().c_str(), TCL_VOLATILE);
10425 - if (strcmp (argv[1], "redrawstatus") == 0)
10427 - int i = atoi (argv[2]);
10428 - occgeometry->changed = i;
10430 - if (strcmp (argv[1], "swaporientation") == 0)
10432 - IGESControl_Writer writer("millimeters", 1);
10433 - writer.AddShape (occgeometry->shape);
10434 - writer.Write ("1.igs");
10436 - int nr = atoi (argv[3]);
10438 - // const_cast<TopoDS_Shape&> (occgeometry->fmap(nr)).Reverse();
10440 - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
10441 - rebuild->Apply(occgeometry->shape);
10445 - // if (strcmp (argv[2], "CompSolid") == 0) sh = occgeometry->cmap(nr);
10446 - if (strcmp (argv[2], "Solid") == 0) sh = occgeometry->somap(nr);
10447 - if (strcmp (argv[2], "Shell") == 0) sh = occgeometry->shmap(nr);
10448 - if (strcmp (argv[2], "Face") == 0) sh = occgeometry->fmap(nr);
10449 - if (strcmp (argv[2], "Wire") == 0) sh = occgeometry->wmap(nr);
10450 - if (strcmp (argv[2], "Edge") == 0) sh = occgeometry->emap(nr);
10452 - rebuild->Replace(sh, sh.Reversed(), Standard_False);
10454 - TopoDS_Shape newshape = rebuild->Apply(occgeometry->shape, TopAbs_SHELL, 1);
10455 - occgeometry->shape = newshape;
10457 - occgeometry->BuildFMap();
10458 - occgeometry->BuildVisualizationMesh();
10459 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10462 - if (strcmp (argv[1], "marksingular") == 0)
10464 - int nr = atoi (argv[3]);
10465 - cout << "marking " << argv[2] << " " << nr << endl;
10466 - char buf[2]; buf[0] = '0'; buf[1] = 0;
10467 - bool sing = false;
10468 - if (strcmp (argv[2], "Face") == 0)
10469 - sing = occgeometry->fsingular[nr-1] = !occgeometry->fsingular[nr-1];
10470 - if (strcmp (argv[2], "Edge") == 0)
10471 - sing = occgeometry->esingular[nr-1] = !occgeometry->esingular[nr-1];
10472 - if (strcmp (argv[2], "Vertex") == 0)
10473 - sing = occgeometry->vsingular[nr-1] = !occgeometry->vsingular[nr-1];
10475 - if (sing) buf[0] = '1';
10477 - Tcl_SetVar (interp, "::ismarkedsingular", buf, 0);
10479 - stringstream str;
10480 - occgeometry->GetTopologyTree (str);
10482 - char* cstr = (char*)str.str().c_str();
10484 - (*testout) << cstr << endl;
10486 - char helpstr[1000];
10488 - while (strchr (cstr, '}'))
10490 - strncpy (helpstr, cstr+2, strlen(strchr(cstr+2, '}')));
10491 - (*testout) << "***" << cstr << "***" << endl;
10492 - cstr = strchr (cstr, '}');
10504 -#ifdef OCCGEOMETRY
10506 - void OCCConstructGeometry (OCCGeometry & geom);
10508 - int Ng_OCCConstruction (ClientData clientData,
10509 - Tcl_Interp * interp,
10510 - int argc, tcl_const char *argv[])
10513 - OCCConstructGeometry (*occgeometry);
10522 - // Philippose - 30/01/2009
10523 - // TCL interface function for the Local Face Mesh size
10524 - // definition functionality
10525 - int Ng_SurfaceMeshSize (ClientData clientData,
10526 - Tcl_Interp * interp,
10527 - int argc, tcl_const char *argv[])
10529 -#ifdef OCCGEOMETRY
10531 - static char buf[100];
10535 - Tcl_SetResult (interp, (char *)"Ng_SurfaceMeshSize needs arguments", TCL_STATIC);
10536 - return TCL_ERROR;
10539 - OCCGeometry * occgeometry = dynamic_cast<OCCGeometry*> (ng_geometry.Ptr());
10540 - if (!occgeometry)
10542 - Tcl_SetResult (interp, (char *)"Ng_SurfaceMeshSize currently supports only OCC (STEP/IGES) Files", TCL_STATIC);
10543 - return TCL_ERROR;
10546 - // Update the face mesh sizes to reflect the global maximum mesh size
10547 - for(int i = 1; i <= occgeometry->NrFaces(); i++)
10549 - if(!occgeometry->GetFaceMaxhModified(i))
10551 - occgeometry->SetFaceMaxH(i, mparam.maxh);
10555 - if (strcmp (argv[1], "setsurfms") == 0)
10557 - int facenr = atoi (argv[2]);
10558 - double surfms = atof (argv[3]);
10559 - if (occgeometry && facenr >= 1 && facenr <= occgeometry->NrFaces())
10560 - occgeometry->SetFaceMaxH(facenr, surfms);
10564 - if (strcmp (argv[1], "setall") == 0)
10566 - double surfms = atof (argv[2]);
10569 - int nrFaces = occgeometry->NrFaces();
10570 - for (int i = 1; i <= nrFaces; i++)
10571 - occgeometry->SetFaceMaxH(i, surfms);
10575 - if (strcmp (argv[1], "getsurfms") == 0)
10577 - int facenr = atoi (argv[2]);
10578 - if (occgeometry && facenr >= 1 && facenr <= occgeometry->NrFaces())
10580 - sprintf (buf, "%5.2f", occgeometry->GetFaceMaxH(facenr));
10584 - sprintf (buf, "%5.2f", mparam.maxh);
10586 - Tcl_SetResult (interp, buf, TCL_STATIC);
10589 - if (strcmp (argv[1], "getactive") == 0)
10591 - sprintf (buf, "%d", occgeometry->SelectedFace());
10592 - Tcl_SetResult (interp, buf, TCL_STATIC);
10595 - if (strcmp (argv[1], "setactive") == 0)
10597 - int facenr = atoi (argv[2]);
10598 - if (occgeometry && facenr >= 1 && facenr <= occgeometry->NrFaces())
10600 - occgeometry->SetSelectedFace (facenr);
10602 - occgeometry->LowLightAll();
10603 - occgeometry->fvispar[facenr-1].Highlight();
10604 - occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
10608 - if (strcmp (argv[1], "getnfd") == 0)
10611 - sprintf (buf, "%d", occgeometry->NrFaces());
10613 - sprintf (buf, "0");
10614 - Tcl_SetResult (interp, buf, TCL_STATIC);
10617 -#else // No OCCGEOMETRY
10619 - Tcl_SetResult (interp, (char *)"Ng_SurfaceMeshSize currently supports only OCC (STEP/IGES) Files", TCL_STATIC);
10620 - return TCL_ERROR;
10622 -#endif // OCCGEOMETRY
10627 - // Philippose - 25/07/2010
10628 - // TCL interface function for extracting and eventually
10629 - // setting or editing the current colours present in the mesh
10630 - int Ng_CurrentFaceColours (ClientData clientData,
10631 - Tcl_Interp * interp,
10632 - int argc, tcl_const char *argv[])
10636 - Tcl_SetResult (interp, (char *)"Ng_GetCurrentFaceColours needs arguments", TCL_STATIC);
10637 - return TCL_ERROR;
10642 - Tcl_SetResult (interp, (char *)"Ng_GetCurrentFaceColours: Valid netgen mesh required...please mesh the Geometry first", TCL_STATIC);
10643 - return TCL_ERROR;
10646 - if(strcmp(argv[1], "getcolours") == 0)
10648 - stringstream outVar;
10649 - Array<Vec3d> face_colours;
10650 - GetFaceColours(*mesh, face_colours);
10652 - for(int i = 0; i < face_colours.Size();i++)
10654 - outVar << "{ " << face_colours[i].X(1)
10655 - << " " << face_colours[i].X(2)
10656 - << " " << face_colours[i].X(3)
10660 - tcl_const char * valuevar = argv[2];
10661 - Tcl_SetVar (interp, valuevar, (char*)outVar.str().c_str(), 0);
10664 - if(strcmp(argv[1], "showalso") == 0)
10666 - Array<Vec3d> face_colours;
10667 - GetFaceColours(*mesh,face_colours);
10669 - int colourind = atoi (argv[2]);
10671 - for(int i = 1; i <= mesh->GetNFD(); i++)
10673 - Array<SurfaceElementIndex> surfElems;
10674 - mesh->GetSurfaceElementsOfFace(i,surfElems);
10676 - if(ColourMatch(face_colours[colourind],mesh->GetFaceDescriptor(i).SurfColour()))
10678 - for(int j = 0; j < surfElems.Size(); j++)
10680 - mesh->SurfaceElement(surfElems[j]).Visible(1);
10685 - mesh->SetNextTimeStamp();
10688 - if(strcmp(argv[1], "hidealso") == 0)
10690 - Array<Vec3d> face_colours;
10691 - GetFaceColours(*mesh,face_colours);
10693 - int colourind = atoi (argv[2]);
10695 - for(int i = 1; i <= mesh->GetNFD(); i++)
10697 - Array<SurfaceElementIndex> surfElems;
10698 - mesh->GetSurfaceElementsOfFace(i,surfElems);
10700 - if(ColourMatch(face_colours[colourind],mesh->GetFaceDescriptor(i).SurfColour()))
10702 - for(int j = 0; j < surfElems.Size(); j++)
10704 - mesh->SurfaceElement(surfElems[j]).Visible(0);
10709 - mesh->SetNextTimeStamp();
10712 - if(strcmp(argv[1], "showonly") == 0)
10714 - Array<Vec3d> face_colours;
10715 - GetFaceColours(*mesh,face_colours);
10717 - int colourind = atoi (argv[2]);
10719 - for(int i = 1; i <= mesh->GetNFD(); i++)
10721 - Array<SurfaceElementIndex> surfElems;
10722 - mesh->GetSurfaceElementsOfFace(i,surfElems);
10724 - if(ColourMatch(face_colours[colourind],mesh->GetFaceDescriptor(i).SurfColour()))
10726 - for(int j = 0; j < surfElems.Size(); j++)
10728 - mesh->SurfaceElement(surfElems[j]).Visible(1);
10733 - for(int j = 0; j < surfElems.Size(); j++)
10735 - mesh->SurfaceElement(surfElems[j]).Visible(0);
10740 - mesh->SetNextTimeStamp();
10743 - if(strcmp(argv[1], "hideonly") == 0)
10745 - Array<Vec3d> face_colours;
10746 - GetFaceColours(*mesh,face_colours);
10748 - int colourind = atoi (argv[2]);
10750 - for(int i = 1; i <= mesh->GetNFD(); i++)
10752 - Array<SurfaceElementIndex> surfElems;
10753 - mesh->GetSurfaceElementsOfFace(i,surfElems);
10755 - if(ColourMatch(face_colours[colourind],mesh->GetFaceDescriptor(i).SurfColour()))
10757 - for(int j = 0; j < surfElems.Size(); j++)
10759 - mesh->SurfaceElement(surfElems[j]).Visible(0);
10764 - for(int j = 0; j < surfElems.Size(); j++)
10766 - mesh->SurfaceElement(surfElems[j]).Visible(1);
10771 - mesh->SetNextTimeStamp();
10774 - if(strcmp(argv[1], "showall") == 0)
10776 - for(int i = 1; i <= mesh->GetNSE(); i++)
10778 - mesh->SurfaceElement(i).Visible(1);
10781 - mesh->SetNextTimeStamp();
10784 - if(strcmp(argv[1], "hideall") == 0)
10786 - for(int i = 1; i <= mesh->GetNSE(); i++)
10788 - mesh->SurfaceElement(i).Visible(0);
10791 - mesh->SetNextTimeStamp();
10800 - // Philippose - 10/03/2009
10801 - // TCL interface function for the Automatic Colour-based
10802 - // definition of boundary conditions for OCC Geometry
10803 - int Ng_AutoColourBcProps (ClientData clientData,
10804 - Tcl_Interp * interp,
10805 - int argc, tcl_const char *argv[])
10809 - Tcl_SetResult (interp, (char *)"Ng_AutoColourBcProps needs arguments", TCL_STATIC);
10810 - return TCL_ERROR;
10815 - Tcl_SetResult (interp, (char *)"Ng_AutoColourBcProps: Valid netgen mesh required...please mesh the Geometry first", TCL_STATIC);
10816 - return TCL_ERROR;
10819 - if(strcmp(argv[1], "auto") == 0)
10821 - AutoColourBcProps(*mesh, 0);
10824 - if(strcmp(argv[1], "profile") == 0)
10826 - AutoColourBcProps(*mesh, argv[2]);
10833 - int Ng_SetOCCParameters (ClientData clientData,
10834 - Tcl_Interp * interp,
10835 - int argc, tcl_const char *argv[])
10837 - OCCGeometryRegister reg;
10838 - reg.SetParameters (interp);
10840 - occparam.resthcloseedgefac =
10841 - atof (Tcl_GetVar (interp, "::stloptions.resthcloseedgefac", 0));
10843 - occparam.resthcloseedgeenable =
10844 - atoi (Tcl_GetVar (interp, "::stloptions.resthcloseedgeenable", 0));
10852 - NetgenGeometry * OCCGeometryRegister :: Load (string filename) const
10854 - const char * lgfilename = filename.c_str();
10858 - if (strcmp (&cfilename[strlen(cfilename)-3], "geo") == 0)
10860 - PrintMessage (1, "Load OCCG geometry file ", cfilename);
10862 - extern OCCGeometry * ParseOCCG (istream & istr);
10864 - ifstream infile(cfilename);
10866 - OCCGeometry * hgeom = ParseOCCG (infile);
10868 - throw NgException ("geo-file should start with 'algebraic3d'");
10870 - hgeom -> FindIdenticSurfaces(1e-8 * hgeom->MaxSize());
10876 - if ((strcmp (&lgfilename[strlen(lgfilename)-4], "iges") == 0) ||
10877 - (strcmp (&lgfilename[strlen(lgfilename)-3], "igs") == 0) ||
10878 - (strcmp (&lgfilename[strlen(lgfilename)-3], "IGS") == 0) ||
10879 - (strcmp (&lgfilename[strlen(lgfilename)-4], "IGES") == 0))
10881 - PrintMessage (1, "Load IGES geometry file ", lgfilename);
10882 - OCCGeometry * occgeometry = LoadOCC_IGES (lgfilename);
10883 - return occgeometry;
10886 - else if ((strcmp (&lgfilename[strlen(lgfilename)-4], "step") == 0) ||
10887 - (strcmp (&lgfilename[strlen(lgfilename)-3], "stp") == 0) ||
10888 - (strcmp (&lgfilename[strlen(lgfilename)-3], "STP") == 0) ||
10889 - (strcmp (&lgfilename[strlen(lgfilename)-4], "STEP") == 0))
10891 - PrintMessage (1, "Load STEP geometry file ", lgfilename);
10892 - OCCGeometry * occgeometry = LoadOCC_STEP (lgfilename);
10893 - return occgeometry;
10895 - else if ((strcmp (&lgfilename[strlen(lgfilename)-4], "brep") == 0) ||
10896 - (strcmp (&lgfilename[strlen(lgfilename)-4], "Brep") == 0) ||
10897 - (strcmp (&lgfilename[strlen(lgfilename)-4], "BREP") == 0))
10899 - PrintMessage (1, "Load BREP geometry file ", lgfilename);
10900 - OCCGeometry * occgeometry = LoadOCC_BREP (lgfilename);
10901 - return occgeometry;
10908 - static VisualSceneOCCGeometry vsoccgeom;
10910 - VisualScene * OCCGeometryRegister :: GetVisualScene (const NetgenGeometry * geom) const
10912 - OCCGeometry * geometry = dynamic_cast<OCCGeometry*> (ng_geometry.Ptr());
10915 - vsoccgeom.SetGeometry (geometry);
10916 - return &vsoccgeom;
10927 -using namespace netgen;
10929 -int Ng_occ_Init (Tcl_Interp * interp)
10931 - geometryregister.Append (new OCCGeometryRegister);
10934 - Tcl_CreateCommand (interp, "Ng_SetOCCVisParameters",
10935 - Ng_SetOCCVisParameters,
10936 - (ClientData)NULL,
10937 - (Tcl_CmdDeleteProc*) NULL);
10939 - Tcl_CreateCommand (interp, "Ng_GetOCCData",
10941 - (ClientData)NULL,
10942 - (Tcl_CmdDeleteProc*) NULL);
10945 -#ifdef OCCGEOMETRY
10946 - Tcl_CreateCommand (interp, "Ng_OCCConstruction",
10947 - Ng_OCCConstruction,
10948 - (ClientData)NULL,
10949 - (Tcl_CmdDeleteProc*) NULL);
10953 - Tcl_CreateCommand (interp, "Ng_OCCCommand",
10955 - (ClientData)NULL,
10956 - (Tcl_CmdDeleteProc*) NULL);
10959 - Tcl_CreateCommand (interp, "Ng_SetOCCParameters", Ng_SetOCCParameters,
10960 - (ClientData)NULL,
10961 - (Tcl_CmdDeleteProc*) NULL);
10965 - // Philippose - 30/01/2009
10966 - // Register the TCL Interface Command for local face mesh size
10968 - Tcl_CreateCommand (interp, "Ng_SurfaceMeshSize", Ng_SurfaceMeshSize,
10969 - (ClientData)NULL,
10970 - (Tcl_CmdDeleteProc*) NULL);
10972 - Tcl_CreateCommand (interp, "Ng_AutoColourBcProps", Ng_AutoColourBcProps,
10973 - (ClientData)NULL,
10974 - (Tcl_CmdDeleteProc*) NULL);
10976 - // Philippose - 25/07/2010
10977 - // Register the TCL Interface Command for handling the face colours
10978 - // present in the mesh
10979 - Tcl_CreateCommand(interp, "Ng_CurrentFaceColours", Ng_CurrentFaceColours,
10980 - (ClientData)NULL,
10981 - (Tcl_CmdDeleteProc*) NULL);
10989 +#ifdef OCCGEOMETRY
10991 +#include <mystdlib.h>
10992 +#include <myadt.hpp>
10993 +#include <linalg.hpp>
10994 +#include <csg.hpp>
10995 +#include <occgeom.hpp>
10998 +#include <incvis.hpp>
10999 +#include <visual.hpp>
11001 +#include "../meshing/bcfunctions.hpp"
11003 +#include "vsocc.hpp"
11006 +extern "C" int Ng_occ_Init (Tcl_Interp * interp);
11012 + extern AutoPtr<NetgenGeometry> ng_geometry;
11013 + extern AutoPtr<Mesh> mesh;
11015 + char * err_needsoccgeometry = (char*) "This operation needs an OCC geometry";
11016 + extern char * err_needsmesh;
11017 + extern char * err_jobrunning;
11022 + class OCCGeometryRegister : public GeometryRegister
11025 + virtual NetgenGeometry * Load (string filename) const;
11026 + virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
11028 + virtual void SetParameters (Tcl_Interp * interp)
11030 + occparam.resthcloseedgefac =
11031 + atof (Tcl_GetVar (interp, "::stloptions.resthcloseedgefac", 0));
11032 + occparam.resthcloseedgeenable =
11033 + atoi (Tcl_GetVar (interp, "::stloptions.resthcloseedgeenable", 0));
11034 + occparam.resthminedgelen =
11035 + atof (Tcl_GetVar (interp, "::stloptions.resthminedgelen", 0));
11036 + occparam.resthminedgelenenable =
11037 + atoi (Tcl_GetVar (interp, "::stloptions.resthminedgelenenable", 0));
11044 + int Ng_SetOCCVisParameters (ClientData clientData,
11045 + Tcl_Interp * interp,
11046 + int argc, tcl_const char *argv[])
11048 +#ifdef OCCGEOMETRY
11050 + OCCGeometry * occgeometry = dynamic_cast<OCCGeometry*> (ng_geometry.Ptr());
11052 + showvolume = atoi (Tcl_GetVar (interp, "::occoptions.showvolumenr", 0));
11055 + if (showvolume != vispar.occshowvolumenr)
11057 + if (showvolume < 0 || showvolume > occgeometry->NrSolids())
11060 + sprintf (buf, "%5i", vispar.occshowvolumenr);
11061 + Tcl_SetVar (interp, "::occoptions.showvolumenr", buf, 0);
11065 + vispar.occshowvolumenr = showvolume;
11067 + occgeometry -> changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11073 + temp = atoi (Tcl_GetVar (interp, "::occoptions.visproblemfaces", 0));
11075 + if ((bool) temp != vispar.occvisproblemfaces)
11077 + vispar.occvisproblemfaces = temp;
11079 + occgeometry -> changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11082 + vispar.occshowsurfaces = atoi (Tcl_GetVar (interp, "::occoptions.showsurfaces", 0));
11083 + vispar.occshowedges = atoi (Tcl_GetVar (interp, "::occoptions.showedges", 0));
11084 + vispar.occzoomtohighlightedentity = atoi (Tcl_GetVar (interp, "::occoptions.zoomtohighlightedentity", 0));
11085 + vispar.occdeflection = pow(10.0,-1-atof (Tcl_GetVar (interp, "::occoptions.deflection", 0)));
11094 + vispar.ACISshowfaces = atoi (Tcl_GetVar (interp, "::occoptions.showsurfaces", 0));
11095 + vispar.ACISshowedges = atoi (Tcl_GetVar (interp, "::occoptions.showedges", 0));
11096 + vispar.ACISshowsolidnr = atoi (Tcl_GetVar (interp, "::occoptions.showsolidnr", 0));
11097 + vispar.ACISshowsolidnr2 = atoi (Tcl_GetVar (interp, "::occoptions.showsolidnr2", 0));
11109 + int Ng_GetOCCData (ClientData clientData,
11110 + Tcl_Interp * interp,
11111 + int argc, tcl_const char *argv[])
11113 +#ifdef OCCGEOMETRY
11114 + OCCGeometry * occgeometry = dynamic_cast<OCCGeometry*> (ng_geometry.Ptr());
11116 + static char buf[1000];
11118 + stringstream str;
11122 + if (strcmp (argv[1], "getentities") == 0)
11126 + occgeometry->GetTopologyTree(str);
11131 + Tcl_SetResult (interp, (char*)str.str().c_str(), TCL_VOLATILE);
11139 + int Ng_OCCCommand (ClientData clientData,
11140 + Tcl_Interp * interp,
11141 + int argc, tcl_const char *argv[])
11143 +#ifdef OCCGEOMETRY
11144 + OCCGeometry * occgeometry = dynamic_cast<OCCGeometry*> (ng_geometry.Ptr());
11146 + stringstream str;
11149 + if (strcmp (argv[1], "isoccgeometryloaded") == 0)
11152 + str << "1 " << flush;
11153 + else str << "0 " << flush;
11155 + Tcl_SetResult (interp, (char*)str.str().c_str(), TCL_VOLATILE);
11159 + if (strcmp (argv[1], "buildvisualizationmesh") == 0)
11161 + occgeometry->BuildVisualizationMesh(vispar.occdeflection);
11162 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11164 + if (strcmp (argv[1], "mesherror") == 0)
11166 + if (occgeometry->ErrorInSurfaceMeshing())
11171 + if (strcmp (argv[1], "sewfaces") == 0)
11173 + cout << "Before operation:" << endl;
11174 + occgeometry->PrintNrShapes();
11175 + occgeometry->SewFaces();
11176 + occgeometry->BuildFMap();
11177 + cout << endl << "After operation:" << endl;
11178 + occgeometry->PrintNrShapes();
11179 + occgeometry->BuildVisualizationMesh(vispar.occdeflection);
11180 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11182 + if (strcmp (argv[1], "makesolid") == 0)
11184 + cout << "Before operation:" << endl;
11185 + occgeometry->PrintNrShapes();
11186 + occgeometry->MakeSolid();
11187 + occgeometry->BuildFMap();
11188 + cout << endl << "After operation:" << endl;
11189 + occgeometry->PrintNrShapes();
11190 + occgeometry->BuildVisualizationMesh(vispar.occdeflection);
11191 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11193 + if (strcmp (argv[1], "upgradetopology") == 0)
11195 + cout << "Before operation:" << endl;
11196 + occgeometry->PrintNrShapes();
11197 + occgeometry->SewFaces();
11198 + occgeometry->MakeSolid();
11199 + occgeometry->BuildFMap();
11200 + cout << endl << "After operation:" << endl;
11201 + occgeometry->PrintNrShapes();
11202 + occgeometry->BuildVisualizationMesh(vispar.occdeflection);
11203 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11205 + if (strcmp (argv[1], "shapehealing") == 0)
11207 + occgeometry->tolerance =
11208 + atof (Tcl_GetVar (interp, "::occoptions.tolerance", 0));
11209 + occgeometry->fixsmalledges =
11210 + atoi (Tcl_GetVar (interp, "::occoptions.fixsmalledges", 0));
11211 + occgeometry->fixspotstripfaces =
11212 + atoi (Tcl_GetVar (interp, "::occoptions.fixspotstripfaces", 0));
11213 + occgeometry->sewfaces =
11214 + atoi (Tcl_GetVar (interp, "::occoptions.sewfaces", 0));
11215 + occgeometry->makesolids =
11216 + atoi (Tcl_GetVar (interp, "::occoptions.makesolids", 0));
11217 + occgeometry->splitpartitions =
11218 + atoi (Tcl_GetVar (interp, "::occoptions.splitpartitions", 0));
11220 + // cout << "Before operation:" << endl;
11221 + // occgeometry->PrintNrShapes();
11222 + occgeometry->HealGeometry();
11223 + occgeometry->BuildFMap();
11224 + // cout << endl << "After operation:" << endl;
11225 + // occgeometry->PrintNrShapes();
11226 + occgeometry->BuildVisualizationMesh(vispar.occdeflection);
11227 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11231 + if (strcmp (argv[1], "highlightentity") == 0)
11233 + if (strcmp (argv[2], "Face") == 0)
11235 + int nr = atoi (argv[3]);
11236 + occgeometry->LowLightAll();
11238 + occgeometry->fvispar[nr-1].Highlight();
11239 + if (vispar.occzoomtohighlightedentity)
11240 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONFULLCHANGE;
11242 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11244 + if (strcmp (argv[2], "Shell") == 0)
11246 + int nr = atoi (argv[3]);
11247 + occgeometry->LowLightAll();
11249 + TopExp_Explorer exp;
11250 + for (exp.Init (occgeometry->shmap(nr), TopAbs_FACE);
11251 + exp.More(); exp.Next())
11253 + int i = occgeometry->fmap.FindIndex (TopoDS::Face(exp.Current()));
11254 + occgeometry->fvispar[i-1].Highlight();
11256 + if (vispar.occzoomtohighlightedentity)
11257 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONFULLCHANGE;
11259 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11261 + if (strcmp (argv[2], "Solid") == 0)
11263 + int nr = atoi (argv[3]);
11264 + occgeometry->LowLightAll();
11266 + TopExp_Explorer exp;
11267 + for (exp.Init (occgeometry->somap(nr), TopAbs_FACE);
11268 + exp.More(); exp.Next())
11270 + int i = occgeometry->fmap.FindIndex (TopoDS::Face(exp.Current()));
11271 + occgeometry->fvispar[i-1].Highlight();
11273 + if (vispar.occzoomtohighlightedentity)
11274 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONFULLCHANGE;
11276 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11279 + if (strcmp (argv[2], "CompSolid") == 0)
11281 + int nr = atoi (argv[3]);
11282 + occgeometry->LowLightAll();
11284 + TopExp_Explorer exp;
11285 + for (exp.Init (occgeometry->cmap(nr), TopAbs_FACE);
11286 + exp.More(); exp.Next())
11288 + int i = occgeometry->fmap.FindIndex (TopoDS::Face(exp.Current()));
11289 + occgeometry->fvispar[i-1].Highlight();
11291 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11295 + if (strcmp (argv[2], "Edge") == 0)
11297 + int nr = atoi (argv[3]);
11298 + occgeometry->LowLightAll();
11300 + occgeometry->evispar[nr-1].Highlight();
11301 + if (vispar.occzoomtohighlightedentity)
11302 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONFULLCHANGE;
11304 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11306 + if (strcmp (argv[2], "Wire") == 0)
11308 + int nr = atoi (argv[3]);
11309 + occgeometry->LowLightAll();
11311 + TopExp_Explorer exp;
11312 + for (exp.Init (occgeometry->wmap(nr), TopAbs_EDGE);
11313 + exp.More(); exp.Next())
11315 + int i = occgeometry->emap.FindIndex (TopoDS::Edge(exp.Current()));
11316 + occgeometry->evispar[i-1].Highlight();
11318 + if (vispar.occzoomtohighlightedentity)
11319 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONFULLCHANGE;
11321 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11324 + if (strcmp (argv[2], "Vertex") == 0)
11326 + int nr = atoi (argv[3]);
11327 + occgeometry->LowLightAll();
11329 + occgeometry->vvispar[nr-1].Highlight();
11330 + if (vispar.occzoomtohighlightedentity)
11331 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONFULLCHANGE;
11333 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11340 + if (strcmp (argv[1], "show") == 0)
11342 + int nr = atoi (argv[3]);
11343 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11345 + if (strcmp (argv[2], "Face") == 0)
11347 + occgeometry->fvispar[nr-1].Show();
11349 + if (strcmp (argv[2], "Shell") == 0)
11351 + TopExp_Explorer exp;
11352 + for (exp.Init (occgeometry->shmap(nr), TopAbs_FACE);
11353 + exp.More(); exp.Next())
11355 + int i = occgeometry->fmap.FindIndex (TopoDS::Face(exp.Current()));
11356 + occgeometry->fvispar[i-1].Show();
11359 + if (strcmp (argv[2], "Solid") == 0)
11361 + TopExp_Explorer exp;
11362 + for (exp.Init (occgeometry->somap(nr), TopAbs_FACE);
11363 + exp.More(); exp.Next())
11365 + int i = occgeometry->fmap.FindIndex (TopoDS::Face(exp.Current()));
11366 + occgeometry->fvispar[i-1].Show();
11369 + if (strcmp (argv[2], "Edge") == 0)
11371 + occgeometry->evispar[nr-1].Show();
11373 + if (strcmp (argv[2], "Wire") == 0)
11375 + TopExp_Explorer exp;
11376 + for (exp.Init (occgeometry->wmap(nr), TopAbs_EDGE);
11377 + exp.More(); exp.Next())
11379 + int i = occgeometry->emap.FindIndex (TopoDS::Edge(exp.Current()));
11380 + occgeometry->evispar[i-1].Show();
11386 + if (strcmp (argv[1], "hide") == 0)
11388 + int nr = atoi (argv[3]);
11389 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11391 + if (strcmp (argv[2], "Face") == 0)
11393 + occgeometry->fvispar[nr-1].Hide();
11395 + if (strcmp (argv[2], "Shell") == 0)
11397 + TopExp_Explorer exp;
11398 + for (exp.Init (occgeometry->shmap(nr), TopAbs_FACE);
11399 + exp.More(); exp.Next())
11401 + int i = occgeometry->fmap.FindIndex (TopoDS::Face(exp.Current()));
11402 + occgeometry->fvispar[i-1].Hide();
11405 + if (strcmp (argv[2], "Solid") == 0)
11407 + TopExp_Explorer exp;
11408 + for (exp.Init (occgeometry->somap(nr), TopAbs_FACE);
11409 + exp.More(); exp.Next())
11411 + int i = occgeometry->fmap.FindIndex (TopoDS::Face(exp.Current()));
11412 + occgeometry->fvispar[i-1].Hide();
11415 + if (strcmp (argv[2], "Edge") == 0)
11417 + occgeometry->evispar[nr-1].Hide();
11419 + if (strcmp (argv[2], "Wire") == 0)
11421 + TopExp_Explorer exp;
11422 + for (exp.Init (occgeometry->wmap(nr), TopAbs_EDGE);
11423 + exp.More(); exp.Next())
11425 + int i = occgeometry->emap.FindIndex (TopoDS::Edge(exp.Current()));
11426 + occgeometry->evispar[i-1].Hide();
11433 + if (strcmp (argv[1], "findsmallentities") == 0)
11435 + stringstream str("");
11436 + occgeometry->CheckIrregularEntities(str);
11437 + Tcl_SetResult (interp, (char*)str.str().c_str(), TCL_VOLATILE);
11439 + if (strcmp (argv[1], "getunmeshedfaceinfo") == 0)
11441 + occgeometry->GetUnmeshedFaceInfo(str);
11442 + Tcl_SetResult (interp, (char*)str.str().c_str(), TCL_VOLATILE);
11444 + if (strcmp (argv[1], "getnotdrawablefaces") == 0)
11446 + occgeometry->GetNotDrawableFaces(str);
11447 + Tcl_SetResult (interp, (char*)str.str().c_str(), TCL_VOLATILE);
11449 + if (strcmp (argv[1], "redrawstatus") == 0)
11451 + int i = atoi (argv[2]);
11452 + occgeometry->changed = i;
11454 + if (strcmp (argv[1], "swaporientation") == 0)
11456 + IGESControl_Writer writer("millimeters", 1);
11457 + writer.AddShape (occgeometry->shape);
11458 + writer.Write ("1.igs");
11460 + int nr = atoi (argv[3]);
11462 + // const_cast<TopoDS_Shape&> (occgeometry->fmap(nr)).Reverse();
11464 + Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
11465 + rebuild->Apply(occgeometry->shape);
11469 + // if (strcmp (argv[2], "CompSolid") == 0) sh = occgeometry->cmap(nr);
11470 + if (strcmp (argv[2], "Solid") == 0) sh = occgeometry->somap(nr);
11471 + if (strcmp (argv[2], "Shell") == 0) sh = occgeometry->shmap(nr);
11472 + if (strcmp (argv[2], "Face") == 0) sh = occgeometry->fmap(nr);
11473 + if (strcmp (argv[2], "Wire") == 0) sh = occgeometry->wmap(nr);
11474 + if (strcmp (argv[2], "Edge") == 0) sh = occgeometry->emap(nr);
11476 + rebuild->Replace(sh, sh.Reversed());
11478 + TopoDS_Shape newshape = rebuild->Apply(occgeometry->shape, TopAbs_SHELL, 1);
11479 + occgeometry->shape = newshape;
11481 + occgeometry->BuildFMap();
11482 + occgeometry->BuildVisualizationMesh();
11483 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11486 + if (strcmp (argv[1], "marksingular") == 0)
11488 + int nr = atoi (argv[3]);
11489 + cout << "marking " << argv[2] << " " << nr << endl;
11490 + char buf[2]; buf[0] = '0'; buf[1] = 0;
11491 + bool sing = false;
11492 + if (strcmp (argv[2], "Face") == 0)
11493 + sing = occgeometry->fsingular[nr-1] = !occgeometry->fsingular[nr-1];
11494 + if (strcmp (argv[2], "Edge") == 0)
11495 + sing = occgeometry->esingular[nr-1] = !occgeometry->esingular[nr-1];
11496 + if (strcmp (argv[2], "Vertex") == 0)
11497 + sing = occgeometry->vsingular[nr-1] = !occgeometry->vsingular[nr-1];
11499 + if (sing) buf[0] = '1';
11501 + Tcl_SetVar (interp, "::ismarkedsingular", buf, 0);
11503 + stringstream str;
11504 + occgeometry->GetTopologyTree (str);
11506 + char* cstr = (char*)str.str().c_str();
11508 + (*testout) << cstr << endl;
11510 + char helpstr[1000];
11512 + while (strchr (cstr, '}'))
11514 + strncpy (helpstr, cstr+2, strlen(strchr(cstr+2, '}')));
11515 + (*testout) << "***" << cstr << "***" << endl;
11516 + cstr = strchr (cstr, '}');
11528 +#ifdef OCCGEOMETRY
11530 + void OCCConstructGeometry (OCCGeometry & geom);
11532 + int Ng_OCCConstruction (ClientData clientData,
11533 + Tcl_Interp * interp,
11534 + int argc, tcl_const char *argv[])
11537 + OCCConstructGeometry (*occgeometry);
11546 + // Philippose - 30/01/2009
11547 + // TCL interface function for the Local Face Mesh size
11548 + // definition functionality
11549 + int Ng_SurfaceMeshSize (ClientData clientData,
11550 + Tcl_Interp * interp,
11551 + int argc, tcl_const char *argv[])
11553 +#ifdef OCCGEOMETRY
11555 + static char buf[100];
11559 + Tcl_SetResult (interp, (char *)"Ng_SurfaceMeshSize needs arguments", TCL_STATIC);
11560 + return TCL_ERROR;
11563 + OCCGeometry * occgeometry = dynamic_cast<OCCGeometry*> (ng_geometry.Ptr());
11564 + if (!occgeometry)
11566 + Tcl_SetResult (interp, (char *)"Ng_SurfaceMeshSize currently supports only OCC (STEP/IGES) Files", TCL_STATIC);
11567 + return TCL_ERROR;
11570 + // Update the face mesh sizes to reflect the global maximum mesh size
11571 + for(int i = 1; i <= occgeometry->NrFaces(); i++)
11573 + if(!occgeometry->GetFaceMaxhModified(i))
11575 + occgeometry->SetFaceMaxH(i, mparam.maxh);
11579 + if (strcmp (argv[1], "setsurfms") == 0)
11581 + int facenr = atoi (argv[2]);
11582 + double surfms = atof (argv[3]);
11583 + if (occgeometry && facenr >= 1 && facenr <= occgeometry->NrFaces())
11584 + occgeometry->SetFaceMaxH(facenr, surfms);
11588 + if (strcmp (argv[1], "setall") == 0)
11590 + double surfms = atof (argv[2]);
11593 + int nrFaces = occgeometry->NrFaces();
11594 + for (int i = 1; i <= nrFaces; i++)
11595 + occgeometry->SetFaceMaxH(i, surfms);
11599 + if (strcmp (argv[1], "getsurfms") == 0)
11601 + int facenr = atoi (argv[2]);
11602 + if (occgeometry && facenr >= 1 && facenr <= occgeometry->NrFaces())
11604 + sprintf (buf, "%5.2f", occgeometry->GetFaceMaxH(facenr));
11608 + sprintf (buf, "%5.2f", mparam.maxh);
11610 + Tcl_SetResult (interp, buf, TCL_STATIC);
11613 + if (strcmp (argv[1], "getactive") == 0)
11615 + sprintf (buf, "%d", occgeometry->SelectedFace());
11616 + Tcl_SetResult (interp, buf, TCL_STATIC);
11619 + if (strcmp (argv[1], "setactive") == 0)
11621 + int facenr = atoi (argv[2]);
11622 + if (occgeometry && facenr >= 1 && facenr <= occgeometry->NrFaces())
11624 + occgeometry->SetSelectedFace (facenr);
11626 + occgeometry->LowLightAll();
11627 + occgeometry->fvispar[facenr-1].Highlight();
11628 + occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
11632 + if (strcmp (argv[1], "getnfd") == 0)
11635 + sprintf (buf, "%d", occgeometry->NrFaces());
11637 + sprintf (buf, "0");
11638 + Tcl_SetResult (interp, buf, TCL_STATIC);
11641 +#else // No OCCGEOMETRY
11643 + Tcl_SetResult (interp, (char *)"Ng_SurfaceMeshSize currently supports only OCC (STEP/IGES) Files", TCL_STATIC);
11644 + return TCL_ERROR;
11646 +#endif // OCCGEOMETRY
11651 + // Philippose - 25/07/2010
11652 + // TCL interface function for extracting and eventually
11653 + // setting or editing the current colours present in the mesh
11654 + int Ng_CurrentFaceColours (ClientData clientData,
11655 + Tcl_Interp * interp,
11656 + int argc, tcl_const char *argv[])
11660 + Tcl_SetResult (interp, (char *)"Ng_GetCurrentFaceColours needs arguments", TCL_STATIC);
11661 + return TCL_ERROR;
11666 + Tcl_SetResult (interp, (char *)"Ng_GetCurrentFaceColours: Valid netgen mesh required...please mesh the Geometry first", TCL_STATIC);
11667 + return TCL_ERROR;
11670 + if(strcmp(argv[1], "getcolours") == 0)
11672 + stringstream outVar;
11673 + Array<Vec3d> face_colours;
11674 + GetFaceColours(*mesh, face_colours);
11676 + for(int i = 0; i < face_colours.Size();i++)
11678 + outVar << "{ " << face_colours[i].X(1)
11679 + << " " << face_colours[i].X(2)
11680 + << " " << face_colours[i].X(3)
11684 + tcl_const char * valuevar = argv[2];
11685 + Tcl_SetVar (interp, valuevar, (char*)outVar.str().c_str(), 0);
11688 + if(strcmp(argv[1], "showalso") == 0)
11690 + Array<Vec3d> face_colours;
11691 + GetFaceColours(*mesh,face_colours);
11693 + int colourind = atoi (argv[2]);
11695 + for(int i = 1; i <= mesh->GetNFD(); i++)
11697 + Array<SurfaceElementIndex> surfElems;
11698 + mesh->GetSurfaceElementsOfFace(i,surfElems);
11700 + if(ColourMatch(face_colours[colourind],mesh->GetFaceDescriptor(i).SurfColour()))
11702 + for(int j = 0; j < surfElems.Size(); j++)
11704 + mesh->SurfaceElement(surfElems[j]).Visible(1);
11709 + mesh->SetNextTimeStamp();
11712 + if(strcmp(argv[1], "hidealso") == 0)
11714 + Array<Vec3d> face_colours;
11715 + GetFaceColours(*mesh,face_colours);
11717 + int colourind = atoi (argv[2]);
11719 + for(int i = 1; i <= mesh->GetNFD(); i++)
11721 + Array<SurfaceElementIndex> surfElems;
11722 + mesh->GetSurfaceElementsOfFace(i,surfElems);
11724 + if(ColourMatch(face_colours[colourind],mesh->GetFaceDescriptor(i).SurfColour()))
11726 + for(int j = 0; j < surfElems.Size(); j++)
11728 + mesh->SurfaceElement(surfElems[j]).Visible(0);
11733 + mesh->SetNextTimeStamp();
11736 + if(strcmp(argv[1], "showonly") == 0)
11738 + Array<Vec3d> face_colours;
11739 + GetFaceColours(*mesh,face_colours);
11741 + int colourind = atoi (argv[2]);
11743 + for(int i = 1; i <= mesh->GetNFD(); i++)
11745 + Array<SurfaceElementIndex> surfElems;
11746 + mesh->GetSurfaceElementsOfFace(i,surfElems);
11748 + if(ColourMatch(face_colours[colourind],mesh->GetFaceDescriptor(i).SurfColour()))
11750 + for(int j = 0; j < surfElems.Size(); j++)
11752 + mesh->SurfaceElement(surfElems[j]).Visible(1);
11757 + for(int j = 0; j < surfElems.Size(); j++)
11759 + mesh->SurfaceElement(surfElems[j]).Visible(0);
11764 + mesh->SetNextTimeStamp();
11767 + if(strcmp(argv[1], "hideonly") == 0)
11769 + Array<Vec3d> face_colours;
11770 + GetFaceColours(*mesh,face_colours);
11772 + int colourind = atoi (argv[2]);
11774 + for(int i = 1; i <= mesh->GetNFD(); i++)
11776 + Array<SurfaceElementIndex> surfElems;
11777 + mesh->GetSurfaceElementsOfFace(i,surfElems);
11779 + if(ColourMatch(face_colours[colourind],mesh->GetFaceDescriptor(i).SurfColour()))
11781 + for(int j = 0; j < surfElems.Size(); j++)
11783 + mesh->SurfaceElement(surfElems[j]).Visible(0);
11788 + for(int j = 0; j < surfElems.Size(); j++)
11790 + mesh->SurfaceElement(surfElems[j]).Visible(1);
11795 + mesh->SetNextTimeStamp();
11798 + if(strcmp(argv[1], "showall") == 0)
11800 + for(int i = 1; i <= mesh->GetNSE(); i++)
11802 + mesh->SurfaceElement(i).Visible(1);
11805 + mesh->SetNextTimeStamp();
11808 + if(strcmp(argv[1], "hideall") == 0)
11810 + for(int i = 1; i <= mesh->GetNSE(); i++)
11812 + mesh->SurfaceElement(i).Visible(0);
11815 + mesh->SetNextTimeStamp();
11824 + // Philippose - 10/03/2009
11825 + // TCL interface function for the Automatic Colour-based
11826 + // definition of boundary conditions for OCC Geometry
11827 + int Ng_AutoColourBcProps (ClientData clientData,
11828 + Tcl_Interp * interp,
11829 + int argc, tcl_const char *argv[])
11833 + Tcl_SetResult (interp, (char *)"Ng_AutoColourBcProps needs arguments", TCL_STATIC);
11834 + return TCL_ERROR;
11839 + Tcl_SetResult (interp, (char *)"Ng_AutoColourBcProps: Valid netgen mesh required...please mesh the Geometry first", TCL_STATIC);
11840 + return TCL_ERROR;
11843 + if(strcmp(argv[1], "auto") == 0)
11845 + AutoColourBcProps(*mesh, 0);
11848 + if(strcmp(argv[1], "profile") == 0)
11850 + AutoColourBcProps(*mesh, argv[2]);
11857 + int Ng_SetOCCParameters (ClientData clientData,
11858 + Tcl_Interp * interp,
11859 + int argc, tcl_const char *argv[])
11861 + OCCGeometryRegister reg;
11862 + reg.SetParameters (interp);
11864 + occparam.resthcloseedgefac =
11865 + atof (Tcl_GetVar (interp, "::stloptions.resthcloseedgefac", 0));
11867 + occparam.resthcloseedgeenable =
11868 + atoi (Tcl_GetVar (interp, "::stloptions.resthcloseedgeenable", 0));
11876 + NetgenGeometry * OCCGeometryRegister :: Load (string filename) const
11878 + const char * lgfilename = filename.c_str();
11882 + if (strcmp (&cfilename[strlen(cfilename)-3], "geo") == 0)
11884 + PrintMessage (1, "Load OCCG geometry file ", cfilename);
11886 + extern OCCGeometry * ParseOCCG (istream & istr);
11888 + ifstream infile(cfilename);
11890 + OCCGeometry * hgeom = ParseOCCG (infile);
11892 + throw NgException ("geo-file should start with 'algebraic3d'");
11894 + hgeom -> FindIdenticSurfaces(1e-8 * hgeom->MaxSize());
11900 + if ((strcmp (&lgfilename[strlen(lgfilename)-4], "iges") == 0) ||
11901 + (strcmp (&lgfilename[strlen(lgfilename)-3], "igs") == 0) ||
11902 + (strcmp (&lgfilename[strlen(lgfilename)-3], "IGS") == 0) ||
11903 + (strcmp (&lgfilename[strlen(lgfilename)-4], "IGES") == 0))
11905 + PrintMessage (1, "Load IGES geometry file ", lgfilename);
11906 + OCCGeometry * occgeometry = LoadOCC_IGES (lgfilename);
11907 + return occgeometry;
11910 + else if ((strcmp (&lgfilename[strlen(lgfilename)-4], "step") == 0) ||
11911 + (strcmp (&lgfilename[strlen(lgfilename)-3], "stp") == 0) ||
11912 + (strcmp (&lgfilename[strlen(lgfilename)-3], "STP") == 0) ||
11913 + (strcmp (&lgfilename[strlen(lgfilename)-4], "STEP") == 0))
11915 + PrintMessage (1, "Load STEP geometry file ", lgfilename);
11916 + OCCGeometry * occgeometry = LoadOCC_STEP (lgfilename);
11917 + return occgeometry;
11919 + else if ((strcmp (&lgfilename[strlen(lgfilename)-4], "brep") == 0) ||
11920 + (strcmp (&lgfilename[strlen(lgfilename)-4], "Brep") == 0) ||
11921 + (strcmp (&lgfilename[strlen(lgfilename)-4], "BREP") == 0))
11923 + PrintMessage (1, "Load BREP geometry file ", lgfilename);
11924 + OCCGeometry * occgeometry = LoadOCC_BREP (lgfilename);
11925 + return occgeometry;
11932 + static VisualSceneOCCGeometry vsoccgeom;
11934 + VisualScene * OCCGeometryRegister :: GetVisualScene (const NetgenGeometry * geom) const
11936 + OCCGeometry * geometry = dynamic_cast<OCCGeometry*> (ng_geometry.Ptr());
11939 + vsoccgeom.SetGeometry (geometry);
11940 + return &vsoccgeom;
11951 +using namespace netgen;
11953 +int Ng_occ_Init (Tcl_Interp * interp)
11955 + geometryregister.Append (new OCCGeometryRegister);
11958 + Tcl_CreateCommand (interp, "Ng_SetOCCVisParameters",
11959 + Ng_SetOCCVisParameters,
11960 + (ClientData)NULL,
11961 + (Tcl_CmdDeleteProc*) NULL);
11963 + Tcl_CreateCommand (interp, "Ng_GetOCCData",
11965 + (ClientData)NULL,
11966 + (Tcl_CmdDeleteProc*) NULL);
11969 +#ifdef OCCGEOMETRY
11970 + Tcl_CreateCommand (interp, "Ng_OCCConstruction",
11971 + Ng_OCCConstruction,
11972 + (ClientData)NULL,
11973 + (Tcl_CmdDeleteProc*) NULL);
11977 + Tcl_CreateCommand (interp, "Ng_OCCCommand",
11979 + (ClientData)NULL,
11980 + (Tcl_CmdDeleteProc*) NULL);
11983 + Tcl_CreateCommand (interp, "Ng_SetOCCParameters", Ng_SetOCCParameters,
11984 + (ClientData)NULL,
11985 + (Tcl_CmdDeleteProc*) NULL);
11989 + // Philippose - 30/01/2009
11990 + // Register the TCL Interface Command for local face mesh size
11992 + Tcl_CreateCommand (interp, "Ng_SurfaceMeshSize", Ng_SurfaceMeshSize,
11993 + (ClientData)NULL,
11994 + (Tcl_CmdDeleteProc*) NULL);
11996 + Tcl_CreateCommand (interp, "Ng_AutoColourBcProps", Ng_AutoColourBcProps,
11997 + (ClientData)NULL,
11998 + (Tcl_CmdDeleteProc*) NULL);
12000 + // Philippose - 25/07/2010
12001 + // Register the TCL Interface Command for handling the face colours
12002 + // present in the mesh
12003 + Tcl_CreateCommand(interp, "Ng_CurrentFaceColours", Ng_CurrentFaceColours,
12004 + (ClientData)NULL,
12005 + (Tcl_CmdDeleteProc*) NULL);
12013 --- netgen_ref/libsrc/occ/utilities.h
12014 +++ netgen/libsrc/occ/utilities.h
12018 #include <iostream>
12019 +#include <iomanip>
12021 // #include "SALOME_Log.hxx"
12023 --- netgen_ref/libsrc/stlgeom/Makefile.am
12024 +++ netgen/libsrc/stlgeom/Makefile.am
12026 AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include $(TCL_INCLUDES)
12029 -lib_LTLIBRARIES = libstl.la
12030 +noinst_LTLIBRARIES = libstl.la
12033 -lib_LTLIBRARIES += libstlvis.la
12034 +lib_LTLIBRARIES = libstlvis.la
12037 libstl_la_SOURCES = meshstlsurface.cpp stlgeom.cpp stlgeomchart.cpp \
12040 libstlvis_la_SOURCES = stlpkg.cpp vsstl.cpp
12041 libstlvis_la_LIBADD = libstl.la
12042 -libstl_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la
12043 # libstlvis_la_LIBADD = libstl.la $(top_builddir)/libsrc/linalg/libla.la
12045 --- netgen_ref/libsrc/stlgeom/stlgeom.cpp
12046 +++ netgen/libsrc/stlgeom/stlgeom.cpp
12047 @@ -250,7 +250,7 @@
12051 - cerr << "ERROR: stlgeom::Smoothnormals, nbt = 0" << endl;
12052 + std::cerr << "ERROR: stlgeom::Smoothnormals, nbt = 0" << std::endl;
12056 --- netgen_ref/libsrc/stlgeom/stlgeom.hpp
12057 +++ netgen/libsrc/stlgeom/stlgeom.hpp
12062 - extern DLL_HEADER MeshingParameters mparam;
12063 + DLL_HEADER extern MeshingParameters mparam;
12068 +++ netgen/nglib/CMakeLists.txt
12070 +# Copyright (C) 2016 OPEN CASCADE
12072 +# This library is free software; you can redistribute it and/or
12073 +# modify it under the terms of the GNU Lesser General Public
12074 +# License as published by the Free Software Foundation; either
12075 +# version 2.1 of the License, or (at your option) any later version.
12077 +# This library is distributed in the hope that it will be useful,
12078 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
12079 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12080 +# Lesser General Public License for more details.
12082 +# You should have received a copy of the GNU Lesser General Public
12083 +# License along with this library; if not, write to the Free Software
12084 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
12086 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
12088 +INCLUDE_DIRECTORIES(
12089 + ${CMAKE_CURRENT_SOURCE_DIR}
12090 + ${PROJECT_SOURCE_DIR}/libsrc/include
12091 + ${ZLIB_INCLUDE_DIRS}
12092 + ${CAS_INCLUDE_DIRS}
12098 + ${PROJECT_SOURCE_DIR}/libsrc/csg/algprim.cpp
12099 + ${PROJECT_SOURCE_DIR}/libsrc/csg/brick.cpp
12100 + ${PROJECT_SOURCE_DIR}/libsrc/csg/bspline2d.cpp
12101 + ${PROJECT_SOURCE_DIR}/libsrc/csg/csgeom.cpp
12102 + ${PROJECT_SOURCE_DIR}/libsrc/csg/csgparser.cpp
12103 + ${PROJECT_SOURCE_DIR}/libsrc/csg/curve2d.cpp
12104 + ${PROJECT_SOURCE_DIR}/libsrc/csg/edgeflw.cpp
12105 + ${PROJECT_SOURCE_DIR}/libsrc/csg/explicitcurve2d.cpp
12106 + ${PROJECT_SOURCE_DIR}/libsrc/csg/extrusion.cpp
12107 + ${PROJECT_SOURCE_DIR}/libsrc/csg/gencyl.cpp
12108 + ${PROJECT_SOURCE_DIR}/libsrc/csg/genmesh.cpp
12109 + ${PROJECT_SOURCE_DIR}/libsrc/csg/identify.cpp
12110 + ${PROJECT_SOURCE_DIR}/libsrc/csg/manifold.cpp
12111 + ${PROJECT_SOURCE_DIR}/libsrc/csg/meshsurf.cpp
12112 + ${PROJECT_SOURCE_DIR}/libsrc/csg/polyhedra.cpp
12113 + ${PROJECT_SOURCE_DIR}/libsrc/csg/revolution.cpp
12114 + ${PROJECT_SOURCE_DIR}/libsrc/csg/singularref.cpp
12115 + ${PROJECT_SOURCE_DIR}/libsrc/csg/solid.cpp
12116 + ${PROJECT_SOURCE_DIR}/libsrc/csg/specpoin.cpp
12117 + ${PROJECT_SOURCE_DIR}/libsrc/csg/spline3d.cpp
12118 + ${PROJECT_SOURCE_DIR}/libsrc/csg/surface.cpp
12119 + ${PROJECT_SOURCE_DIR}/libsrc/csg/triapprox.cpp)
12122 +SET(GENERAL_SOURCES
12123 + ${PROJECT_SOURCE_DIR}/libsrc/general/array.cpp
12124 + ${PROJECT_SOURCE_DIR}/libsrc/general/bitarray.cpp
12125 + ${PROJECT_SOURCE_DIR}/libsrc/general/dynamicmem.cpp
12126 + ${PROJECT_SOURCE_DIR}/libsrc/general/flags.cpp
12127 + ${PROJECT_SOURCE_DIR}/libsrc/general/hashtabl.cpp
12128 + ${PROJECT_SOURCE_DIR}/libsrc/general/mystring.cpp
12129 + ${PROJECT_SOURCE_DIR}/libsrc/general/ngexception.cpp
12130 + ${PROJECT_SOURCE_DIR}/libsrc/general/optmem.cpp
12131 + ${PROJECT_SOURCE_DIR}/libsrc/general/parthreads.cpp
12132 + ${PROJECT_SOURCE_DIR}/libsrc/general/profiler.cpp
12133 + ${PROJECT_SOURCE_DIR}/libsrc/general/seti.cpp
12134 + ${PROJECT_SOURCE_DIR}/libsrc/general/sort.cpp
12135 + ${PROJECT_SOURCE_DIR}/libsrc/general/spbita2d.cpp
12136 + ${PROJECT_SOURCE_DIR}/libsrc/general/symbolta.cpp
12137 + ${PROJECT_SOURCE_DIR}/libsrc/general/table.cpp
12138 + ${PROJECT_SOURCE_DIR}/libsrc/general/mpi_interface.cpp
12139 + ${PROJECT_SOURCE_DIR}/libsrc/general/gzstream.cpp)
12141 +FILE(GLOB GENERAL_INCLUDES "${PROJECT_SOURCE_DIR}/libsrc/general/*.hpp")
12142 +LIST(APPEND GENERAL_INCLUDES ${PROJECT_SOURCE_DIR}/libsrc/general/gzstream.h)
12145 +SET (GEOM2D_SOURCES
12146 + ${PROJECT_SOURCE_DIR}/libsrc/geom2d/genmesh2d.cpp
12147 + ${PROJECT_SOURCE_DIR}/libsrc/geom2d/geom2dmesh.cpp
12148 + ${PROJECT_SOURCE_DIR}/libsrc/geom2d/geometry2d.cpp)
12152 + ${PROJECT_SOURCE_DIR}/libsrc/gprim/adtree.cpp
12153 + ${PROJECT_SOURCE_DIR}/libsrc/gprim/geom2d.cpp
12154 + ${PROJECT_SOURCE_DIR}/libsrc/gprim/geom3d.cpp
12155 + ${PROJECT_SOURCE_DIR}/libsrc/gprim/geomfuncs.cpp
12156 + ${PROJECT_SOURCE_DIR}/libsrc/gprim/geomtest3d.cpp
12157 + ${PROJECT_SOURCE_DIR}/libsrc/gprim/transform3d.cpp
12158 + ${PROJECT_SOURCE_DIR}/libsrc/gprim/spline.cpp
12159 + ${PROJECT_SOURCE_DIR}/libsrc/gprim/splinegeometry.cpp)
12161 +FILE(GLOB GPRIM_INCLUDES "${PROJECT_SOURCE_DIR}/libsrc/gprim/*.hpp")
12164 +SET(INCLUDE_INCLUDES
12165 + ${PROJECT_SOURCE_DIR}/libsrc/include/nginterface.h
12166 + ${PROJECT_SOURCE_DIR}/libsrc/include/nginterface_v2.hpp
12167 + ${PROJECT_SOURCE_DIR}/libsrc/include/mystdlib.h
12168 + ${PROJECT_SOURCE_DIR}/libsrc/include/mydefs.hpp)
12171 +SET(INTERFACE_SOURCES
12172 + ${PROJECT_SOURCE_DIR}/libsrc/interface/nginterface.cpp
12173 + ${PROJECT_SOURCE_DIR}/libsrc/interface/nginterface_v2.cpp
12174 + ${PROJECT_SOURCE_DIR}/libsrc/interface/read_fnf_mesh.cpp
12175 + ${PROJECT_SOURCE_DIR}/libsrc/interface/readtetmesh.cpp
12176 + ${PROJECT_SOURCE_DIR}/libsrc/interface/readuser.cpp
12177 + ${PROJECT_SOURCE_DIR}/libsrc/interface/writeabaqus.cpp
12178 + ${PROJECT_SOURCE_DIR}/libsrc/interface/writediffpack.cpp
12179 + ${PROJECT_SOURCE_DIR}/libsrc/interface/writedolfin.cpp
12180 + ${PROJECT_SOURCE_DIR}/libsrc/interface/writeelmer.cpp
12181 + ${PROJECT_SOURCE_DIR}/libsrc/interface/writefeap.cpp
12182 + ${PROJECT_SOURCE_DIR}/libsrc/interface/writefluent.cpp
12183 + ${PROJECT_SOURCE_DIR}/libsrc/interface/writegmsh.cpp
12184 + ${PROJECT_SOURCE_DIR}/libsrc/interface/writejcm.cpp
12185 + ${PROJECT_SOURCE_DIR}/libsrc/interface/writepermas.cpp
12186 + ${PROJECT_SOURCE_DIR}/libsrc/interface/writetecplot.cpp
12187 + ${PROJECT_SOURCE_DIR}/libsrc/interface/writetet.cpp
12188 + ${PROJECT_SOURCE_DIR}/libsrc/interface/writetochnog.cpp
12189 + ${PROJECT_SOURCE_DIR}/libsrc/interface/writeuser.cpp
12190 + ${PROJECT_SOURCE_DIR}/libsrc/interface/wuchemnitz.cpp
12191 + ${PROJECT_SOURCE_DIR}/libsrc/interface/writegmsh2.cpp
12192 + ${PROJECT_SOURCE_DIR}/libsrc/interface/writeOpenFOAM15x.cpp)
12195 +SET (LINALG_SOURCES
12196 + ${PROJECT_SOURCE_DIR}/libsrc/linalg/densemat.cpp
12197 + ${PROJECT_SOURCE_DIR}/libsrc/linalg/polynomial.cpp
12198 + ${PROJECT_SOURCE_DIR}/libsrc/linalg/bfgs.cpp
12199 + ${PROJECT_SOURCE_DIR}/libsrc/linalg/linopt.cpp
12200 + ${PROJECT_SOURCE_DIR}/libsrc/linalg/linsearch.cpp)
12202 +FILE(GLOB LINALG_INCLUDES "${PROJECT_SOURCE_DIR}/libsrc/linalg/*.hpp")
12205 +SET(MESHING_SOURCES
12206 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/adfront2.cpp
12207 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/adfront3.cpp
12208 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/bisect.cpp
12209 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/boundarylayer.cpp
12210 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/clusters.cpp
12211 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/curvedelems.cpp
12212 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/delaunay.cpp
12213 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/delaunay2d.cpp
12214 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/geomsearch.cpp
12215 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/global.cpp
12216 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/hprefinement.cpp
12217 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/improve2.cpp
12218 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/improve2gen.cpp
12219 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/improve3.cpp
12220 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/localh.cpp
12221 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/meshclass.cpp
12222 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/meshfunc.cpp
12223 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/meshfunc2d.cpp
12224 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/meshing2.cpp
12225 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/meshing3.cpp
12226 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/meshtool.cpp
12227 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/meshtype.cpp
12228 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/msghandler.cpp
12229 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/netrule2.cpp
12230 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/netrule3.cpp
12231 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/parser2.cpp
12232 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/parser3.cpp
12233 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/prism2rls.cpp
12234 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/pyramid2rls.cpp
12235 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/pyramidrls.cpp
12236 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/quadrls.cpp
12237 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/refine.cpp
12238 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/ruler2.cpp
12239 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/ruler3.cpp
12240 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/secondorder.cpp
12241 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/smoothing2.5.cpp
12242 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/smoothing2.cpp
12243 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/smoothing3.cpp
12244 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/specials.cpp
12245 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/tetrarls.cpp
12246 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/topology.cpp
12247 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/triarls.cpp
12248 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/validate.cpp
12249 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/zrefine.cpp
12250 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/bcfunctions.cpp
12251 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/parallelmesh.cpp
12252 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/paralleltop.cpp
12253 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/paralleltop.hpp
12254 + ${PROJECT_SOURCE_DIR}/libsrc/meshing/basegeom.cpp)
12256 +FILE(GLOB MESHING_INCLUDES "${PROJECT_SOURCE_DIR}/libsrc/meshing/*.hpp")
12260 + ${PROJECT_SOURCE_DIR}/libsrc/occ/Partition_Inter2d.cxx
12261 + ${PROJECT_SOURCE_DIR}/libsrc/occ/Partition_Inter3d.cxx
12262 + ${PROJECT_SOURCE_DIR}/libsrc/occ/Partition_Loop.cxx
12263 + ${PROJECT_SOURCE_DIR}/libsrc/occ/Partition_Loop2d.cxx
12264 + ${PROJECT_SOURCE_DIR}/libsrc/occ/Partition_Loop3d.cxx
12265 + ${PROJECT_SOURCE_DIR}/libsrc/occ/Partition_Spliter.cxx
12266 + ${PROJECT_SOURCE_DIR}/libsrc/occ/occconstruction.cpp
12267 + ${PROJECT_SOURCE_DIR}/libsrc/occ/occgenmesh.cpp
12268 + ${PROJECT_SOURCE_DIR}/libsrc/occ/occgeom.cpp
12269 + ${PROJECT_SOURCE_DIR}/libsrc/occ/occmeshsurf.cpp)
12271 +SET(OCC_INCLUDES ${PROJECT_SOURCE_DIR}/libsrc/occ/occgeom.hpp ${PROJECT_SOURCE_DIR}/libsrc/occ/occmeshsurf.hpp)
12274 +SET(STLGEOM_SOURCES
12275 + ${PROJECT_SOURCE_DIR}/libsrc/stlgeom/meshstlsurface.cpp
12276 + ${PROJECT_SOURCE_DIR}/libsrc/stlgeom/stlgeom.cpp
12277 + ${PROJECT_SOURCE_DIR}/libsrc/stlgeom/stlgeomchart.cpp
12278 + ${PROJECT_SOURCE_DIR}/libsrc/stlgeom/stlgeommesh.cpp
12279 + ${PROJECT_SOURCE_DIR}/libsrc/stlgeom/stlline.cpp
12280 + ${PROJECT_SOURCE_DIR}/libsrc/stlgeom/stltool.cpp
12281 + ${PROJECT_SOURCE_DIR}/libsrc/stlgeom/stltopology.cpp)
12284 +SET(NGLIB_SOURCES nglib.cpp)
12285 +ADD_LIBRARY(nglib SHARED
12288 + ${GENERAL_SOURCES}
12290 + ${GEOM2D_SOURCES}
12291 + ${INTERFACE_SOURCES}
12292 + ${LINALG_SOURCES}
12293 + ${MESHING_SOURCES}
12295 + ${STLGEOM_SOURCES})
12297 +TARGET_LINK_LIBRARIES(nglib ${OCCLIBS} ${PLATFORM_LIBADD} ${ZLIB_LIBRARIES})
12298 +INSTALL(TARGETS nglib DESTINATION ${NETGEN_INSTALL_LIBS})
12301 +INSTALL(FILES ${GENERAL_INCLUDES}
12302 + ${INCLUDE_INCLUDES}
12303 + ${GPRIM_INCLUDES}
12304 + ${LINALG_INCLUDES}
12305 + ${MESHING_INCLUDES}
12308 + DESTINATION ${NETGEN_INSTALL_HEADERS})
12312 +SET(NG_VOL_SOURCES ng_vol.cpp)
12313 +ADD_EXECUTABLE(ng_vol ${NG_VOL_SOURCES})
12314 +TARGET_LINK_LIBRARIES(ng_vol nglib)
12315 +INSTALL(TARGETS ng_vol DESTINATION ${NETGEN_INSTALL_BINS})
12318 +SET(NG_STL_SOURCES ng_stl.cpp)
12319 +ADD_EXECUTABLE(ng_stl ${NG_STL_SOURCES})
12320 +TARGET_LINK_LIBRARIES(ng_stl nglib)
12321 +INSTALL(TARGETS ng_stl DESTINATION ${NETGEN_INSTALL_BINS})
12322 --- netgen_ref/nglib/Makefile.am
12323 +++ netgen/nglib/Makefile.am
12325 $(top_builddir)/libsrc/stlgeom/libstl.la \
12326 $(top_builddir)/libsrc/occ/libocc.la \
12327 $(top_builddir)/libsrc/meshing/libmesh.la \
12328 + $(top_builddir)/libsrc/general/libgen.la \
12329 + $(top_builddir)/libsrc/gprim/libgprim.la \
12330 + $(top_builddir)/libsrc/linalg/libla.la
12331 $(OCCLIBS) $(MPI_LIBS)
12333 libnglib_la_LDFLAGS = -avoid-version
12334 --- netgen_ref/nglib/nglib.cpp
12335 +++ netgen/nglib/nglib.cpp
12336 @@ -1,1242 +1,1243 @@
12337 -/**************************************************************************/
12338 -/* File: nglib.cpp */
12339 -/* Author: Joachim Schoeberl */
12340 -/* Date: 7. May. 2000 */
12341 -/**************************************************************************/
12345 - Interface to the netgen meshing kernel
12348 -#include <mystdlib.h>
12349 -#include <myadt.hpp>
12351 -#include <linalg.hpp>
12352 -#include <csg.hpp>
12353 -#include <stlgeom.hpp>
12354 -#include <geometry2d.hpp>
12355 -#include <meshing.hpp>
12356 -#include <../visualization/soldata.hpp>
12358 -#ifdef OCCGEOMETRY
12359 -#include <occgeom.hpp>
12362 -#include <nginterface.h>
12365 -namespace netgen {
12366 - extern void MeshFromSpline2D (SplineGeometry2d & geometry,
12368 - MeshingParameters & mp);
12378 - // int id = 0, ntasks = 1;
12379 - MPI_Comm mesh_comm;
12386 - int id = 0, ntasks = 1;
12392 -// should not be needed (occ currently requires it)
12393 -namespace netgen {
12394 -#include "../libsrc/visualization/vispar.hpp"
12395 - VisualizationParameters vispar;
12396 - VisualizationParameters :: VisualizationParameters() { ; }
12402 -#include "nglib.h"
12405 -using namespace netgen;
12407 -// constants and types:
12411 - // initialize, deconstruct Netgen library:
12412 - DLL_HEADER void Ng_Init ()
12416 - // netgen::testout->SetOutStream (new ofstream ("test.out"));
12417 - testout = new ofstream ("test.out");
12423 - // Clean-up functions before ending usage of nglib
12424 - DLL_HEADER void Ng_Exit ()
12432 - // Create a new netgen mesh object
12433 - DLL_HEADER Ng_Mesh * Ng_NewMesh ()
12435 - Mesh * mesh = new Mesh;
12436 - mesh->AddFaceDescriptor (FaceDescriptor (1, 1, 0, 1));
12437 - return (Ng_Mesh*)(void*)mesh;
12443 - // Delete an existing netgen mesh object
12444 - DLL_HEADER void Ng_DeleteMesh (Ng_Mesh * mesh)
12448 - // Delete the Mesh structures
12449 - ((Mesh*)mesh)->DeleteMesh();
12451 - // Now delete the Mesh class itself
12452 - delete (Mesh*)mesh;
12454 - // Set the Ng_Mesh pointer to NULL
12462 - // Save a netgen mesh in the native VOL format
12463 - DLL_HEADER void Ng_SaveMesh(Ng_Mesh * mesh, const char* filename)
12465 - ((Mesh*)mesh)->Save(filename);
12471 - // Load a netgen native VOL mesh from a given file
12472 - DLL_HEADER Ng_Mesh * Ng_LoadMesh(const char* filename)
12474 - Mesh * mesh = new Mesh;
12475 - mesh->Load(filename);
12476 - return ( (Ng_Mesh*)mesh );
12482 - // Merge another mesh file into the currently loaded one
12483 - DLL_HEADER Ng_Result Ng_MergeMesh( Ng_Mesh* mesh, const char* filename)
12485 - Ng_Result status = NG_OK;
12487 - ifstream infile(filename);
12488 - Mesh * m = (Mesh*)mesh;
12490 - if(!infile.good())
12492 - status = NG_FILE_NOT_FOUND;
12497 - status = NG_ERROR;
12500 - if(status == NG_OK)
12502 - const int num_pts = m->GetNP();
12503 - const int face_offset = m->GetNFD();
12505 - m->Merge(infile, face_offset);
12507 - if(m->GetNP() > num_pts)
12513 - status = NG_ERROR;
12523 - // Merge another mesh file into the currently loaded one
12524 - DLL_HEADER Ng_Result Ng_MergeMesh( Ng_Mesh* mesh1, Ng_Mesh* mesh2)
12532 - // Manually add a point to an existing mesh object
12533 - DLL_HEADER void Ng_AddPoint (Ng_Mesh * mesh, double * x)
12535 - Mesh * m = (Mesh*)mesh;
12536 - m->AddPoint (Point3d (x[0], x[1], x[2]));
12542 - // Manually add a surface element of a given type to an existing mesh object
12543 - DLL_HEADER void Ng_AddSurfaceElement (Ng_Mesh * mesh, Ng_Surface_Element_Type et,
12546 - Mesh * m = (Mesh*)mesh;
12547 - Element2d el (3);
12549 - el.PNum(1) = pi[0];
12550 - el.PNum(2) = pi[1];
12551 - el.PNum(3) = pi[2];
12552 - m->AddSurfaceElement (el);
12558 - // Manually add a volume element of a given type to an existing mesh object
12559 - DLL_HEADER void Ng_AddVolumeElement (Ng_Mesh * mesh, Ng_Volume_Element_Type et,
12562 - Mesh * m = (Mesh*)mesh;
12565 - el.PNum(1) = pi[0];
12566 - el.PNum(2) = pi[1];
12567 - el.PNum(3) = pi[2];
12568 - el.PNum(4) = pi[3];
12569 - m->AddVolumeElement (el);
12575 - // Obtain the number of points in the mesh
12576 - DLL_HEADER int Ng_GetNP (Ng_Mesh * mesh)
12578 - return ((Mesh*)mesh) -> GetNP();
12584 - // Obtain the number of surface elements in the mesh
12585 - DLL_HEADER int Ng_GetNSE (Ng_Mesh * mesh)
12587 - return ((Mesh*)mesh) -> GetNSE();
12593 - // Obtain the number of volume elements in the mesh
12594 - DLL_HEADER int Ng_GetNE (Ng_Mesh * mesh)
12596 - return ((Mesh*)mesh) -> GetNE();
12602 - // Return point coordinates of a given point index in the mesh
12603 - DLL_HEADER void Ng_GetPoint (Ng_Mesh * mesh, int num, double * x)
12605 - const Point3d & p = ((Mesh*)mesh)->Point(num);
12614 - // Return the surface element at a given index "pi"
12615 - DLL_HEADER Ng_Surface_Element_Type
12616 - Ng_GetSurfaceElement (Ng_Mesh * mesh, int num, int * pi)
12618 - const Element2d & el = ((Mesh*)mesh)->SurfaceElement(num);
12619 - for (int i = 1; i <= el.GetNP(); i++)
12620 - pi[i-1] = el.PNum(i);
12621 - Ng_Surface_Element_Type et;
12622 - switch (el.GetNP())
12624 - case 3: et = NG_TRIG; break;
12625 - case 4: et = NG_QUAD; break;
12627 - switch (el.GetNV())
12629 - case 3: et = NG_TRIG6; break;
12630 - case 4: et = NG_QUAD6; break;
12632 - et = NG_TRIG6; break;
12635 - case 8: et = NG_QUAD8; break;
12637 - et = NG_TRIG; break; // for the compiler
12645 - // Return the volume element at a given index "pi"
12646 - DLL_HEADER Ng_Volume_Element_Type
12647 - Ng_GetVolumeElement (Ng_Mesh * mesh, int num, int * pi)
12649 - const Element & el = ((Mesh*)mesh)->VolumeElement(num);
12650 - for (int i = 1; i <= el.GetNP(); i++)
12651 - pi[i-1] = el.PNum(i);
12652 - Ng_Volume_Element_Type et;
12653 - switch (el.GetNP())
12655 - case 4: et = NG_TET; break;
12656 - case 5: et = NG_PYRAMID; break;
12657 - case 6: et = NG_PRISM; break;
12658 - case 10: et = NG_TET10; break;
12660 - et = NG_TET; break; // for the compiler
12668 - // Set a global limit on the maximum mesh size allowed
12669 - DLL_HEADER void Ng_RestrictMeshSizeGlobal (Ng_Mesh * mesh, double h)
12671 - ((Mesh*)mesh) -> SetGlobalH (h);
12677 - // Set a local limit on the maximum mesh size allowed around the given point
12678 - DLL_HEADER void Ng_RestrictMeshSizePoint (Ng_Mesh * mesh, double * p, double h)
12680 - ((Mesh*)mesh) -> RestrictLocalH (Point3d (p[0], p[1], p[2]), h);
12686 - // Set a local limit on the maximum mesh size allowed within a given box region
12687 - DLL_HEADER void Ng_RestrictMeshSizeBox (Ng_Mesh * mesh, double * pmin, double * pmax, double h)
12689 - for (double x = pmin[0]; x < pmax[0]; x += h)
12690 - for (double y = pmin[1]; y < pmax[1]; y += h)
12691 - for (double z = pmin[2]; z < pmax[2]; z += h)
12692 - ((Mesh*)mesh) -> RestrictLocalH (Point3d (x, y, z), h);
12698 - // Generates volume mesh from an existing surface mesh
12699 - DLL_HEADER Ng_Result Ng_GenerateVolumeMesh (Ng_Mesh * mesh, Ng_Meshing_Parameters * mp)
12701 - Mesh * m = (Mesh*)mesh;
12703 - // Philippose - 30/08/2009
12704 - // Do not locally re-define "mparam" here... "mparam" is a global
12706 - //MeshingParameters mparam;
12707 - mp->Transfer_Parameters();
12709 - m->CalcLocalH(mparam.grading);
12711 - MeshVolume (mparam, *m);
12712 - RemoveIllegalElements (*m);
12713 - OptimizeVolume (mparam, *m);
12721 - /* ------------------ 2D Meshing Functions ------------------------- */
12722 - DLL_HEADER void Ng_AddPoint_2D (Ng_Mesh * mesh, double * x)
12724 - Mesh * m = (Mesh*)mesh;
12726 - m->AddPoint (Point3d (x[0], x[1], 0));
12732 - DLL_HEADER void Ng_AddBoundarySeg_2D (Ng_Mesh * mesh, int pi1, int pi2)
12734 - Mesh * m = (Mesh*)mesh;
12739 - m->AddSegment (seg);
12745 - DLL_HEADER int Ng_GetNP_2D (Ng_Mesh * mesh)
12747 - Mesh * m = (Mesh*)mesh;
12748 - return m->GetNP();
12754 - DLL_HEADER int Ng_GetNE_2D (Ng_Mesh * mesh)
12756 - Mesh * m = (Mesh*)mesh;
12757 - return m->GetNSE();
12763 - DLL_HEADER int Ng_GetNSeg_2D (Ng_Mesh * mesh)
12765 - Mesh * m = (Mesh*)mesh;
12766 - return m->GetNSeg();
12772 - DLL_HEADER void Ng_GetPoint_2D (Ng_Mesh * mesh, int num, double * x)
12774 - Mesh * m = (Mesh*)mesh;
12776 - Point<3> & p = m->Point(num);
12784 - DLL_HEADER Ng_Surface_Element_Type
12785 - Ng_GetElement_2D (Ng_Mesh * mesh, int num, int * pi, int * matnum)
12787 - const Element2d & el = ((Mesh*)mesh)->SurfaceElement(num);
12788 - for (int i = 1; i <= el.GetNP(); i++)
12789 - pi[i-1] = el.PNum(i);
12791 - Ng_Surface_Element_Type et;
12792 - switch (el.GetNP())
12794 - case 3: et = NG_TRIG; break;
12795 - case 4: et = NG_QUAD; break;
12797 - switch (el.GetNV())
12799 - case 3: et = NG_TRIG6; break;
12800 - case 4: et = NG_QUAD6; break;
12802 - et = NG_TRIG6; break;
12805 - case 8: et = NG_QUAD8; break;
12807 - et = NG_TRIG; break; // for the compiler
12811 - *matnum = el.GetIndex();
12819 - DLL_HEADER void Ng_GetSegment_2D (Ng_Mesh * mesh, int num, int * pi, int * matnum)
12821 - const Segment & seg = ((Mesh*)mesh)->LineSegment(num);
12826 - *matnum = seg.edgenr;
12832 - DLL_HEADER Ng_Geometry_2D * Ng_LoadGeometry_2D (const char * filename)
12834 - SplineGeometry2d * geom = new SplineGeometry2d();
12835 - geom -> Load (filename);
12836 - return (Ng_Geometry_2D *)geom;
12842 - DLL_HEADER Ng_Result Ng_GenerateMesh_2D (Ng_Geometry_2D * geom,
12844 - Ng_Meshing_Parameters * mp)
12846 - // use global variable mparam
12847 - // MeshingParameters mparam;
12848 - mp->Transfer_Parameters();
12851 - MeshFromSpline2D (*(SplineGeometry2d*)geom, m, mparam);
12853 - cout << m->GetNSE() << " elements, " << m->GetNP() << " points" << endl;
12855 - *mesh = (Ng_Mesh*)m;
12862 - DLL_HEADER void Ng_HP_Refinement (Ng_Geometry_2D * geom,
12866 - Refinement2d ref(*(SplineGeometry2d*)geom);
12867 - HPRefinement (*(Mesh*)mesh, &ref, levels);
12873 - DLL_HEADER void Ng_HP_Refinement (Ng_Geometry_2D * geom,
12875 - int levels, double parameter)
12877 - Refinement2d ref(*(SplineGeometry2d*)geom);
12878 - HPRefinement (*(Mesh*)mesh, &ref, levels, parameter);
12884 - Array<STLReadTriangle> readtrias; //only before initstlgeometry
12885 - Array<Point<3> > readedges; //only before init stlgeometry
12887 - // loads geometry from STL file
12888 - DLL_HEADER Ng_STL_Geometry * Ng_STL_LoadGeometry (const char * filename, int binary)
12891 - STLGeometry geom;
12892 - STLGeometry* geo;
12893 - ifstream ist(filename);
12897 - geo = geom.LoadBinary(ist);
12901 - geo = geom.Load(ist);
12904 - readtrias.SetSize(0);
12905 - readedges.SetSize(0);
12914 - Ng_STL_Geometry * geo2 = Ng_STL_NewGeometry();
12916 - for (i = 1; i <= geo->GetNT(); i++)
12918 - const STLTriangle& t = geo->GetTriangle(i);
12919 - p = geo->GetPoint(t.PNum(1));
12920 - p1[0] = p.X(); p1[1] = p.Y(); p1[2] = p.Z();
12921 - p = geo->GetPoint(t.PNum(2));
12922 - p2[0] = p.X(); p2[1] = p.Y(); p2[2] = p.Z();
12923 - p = geo->GetPoint(t.PNum(3));
12924 - p3[0] = p.X(); p3[1] = p.Y(); p3[2] = p.Z();
12925 - normal = t.Normal();
12926 - n[0] = normal.X(); n[1] = normal.Y(); n[2] = normal.Z();
12928 - Ng_STL_AddTriangle(geo2, p1, p2, p3, n);
12937 - // generate new STL Geometry
12938 - DLL_HEADER Ng_STL_Geometry * Ng_STL_NewGeometry ()
12940 - return (Ng_STL_Geometry*)(void*)new STLGeometry;
12946 - // after adding triangles (and edges) initialize
12947 - DLL_HEADER Ng_Result Ng_STL_InitSTLGeometry (Ng_STL_Geometry * geom)
12949 - STLGeometry* geo = (STLGeometry*)geom;
12950 - geo->InitSTLGeometry(readtrias);
12951 - readtrias.SetSize(0);
12953 - if (readedges.Size() != 0)
12956 - for (int i = 1; i <= readedges.Size(); i+=2)
12958 - cout << "e(" << readedges.Get(i) << "," << readedges.Get(i+1) << ")" << endl;
12961 - geo->AddEdges(readedges);
12964 - if (geo->GetStatus() == STLTopology::STL_GOOD || geo->GetStatus() == STLTopology::STL_WARNING) return NG_OK;
12965 - return NG_SURFACE_INPUT_ERROR;
12971 - // automatically generates edges:
12972 - DLL_HEADER Ng_Result Ng_STL_MakeEdges (Ng_STL_Geometry * geom,
12974 - Ng_Meshing_Parameters * mp)
12976 - STLGeometry* stlgeometry = (STLGeometry*)geom;
12977 - Mesh* me = (Mesh*)mesh;
12979 - // Philippose - 27/07/2009
12980 - // Do not locally re-define "mparam" here... "mparam" is a global
12982 - //MeshingParameters mparam;
12983 - mp->Transfer_Parameters();
12985 - me -> SetGlobalH (mparam.maxh);
12986 - me -> SetLocalH (stlgeometry->GetBoundingBox().PMin() - Vec3d(10, 10, 10),
12987 - stlgeometry->GetBoundingBox().PMax() + Vec3d(10, 10, 10),
12990 - me -> LoadLocalMeshSize (mp->meshsize_filename);
12992 - if (mp->meshsize_filename)
12994 - ifstream infile (mp->meshsize_filename);
12995 - if (!infile.good()) return NG_FILE_NOT_FOUND;
12996 - me -> LoadLocalMeshSize (infile);
13000 - STLMeshing (*stlgeometry, *me);
13002 - stlgeometry->edgesfound = 1;
13003 - stlgeometry->surfacemeshed = 0;
13004 - stlgeometry->surfaceoptimized = 0;
13005 - stlgeometry->volumemeshed = 0;
13013 - // generates mesh, empty mesh be already created.
13014 - DLL_HEADER Ng_Result Ng_STL_GenerateSurfaceMesh (Ng_STL_Geometry * geom,
13016 - Ng_Meshing_Parameters * mp)
13018 - STLGeometry* stlgeometry = (STLGeometry*)geom;
13019 - Mesh* me = (Mesh*)mesh;
13021 - // Philippose - 27/07/2009
13022 - // Do not locally re-define "mparam" here... "mparam" is a global
13024 - //MeshingParameters mparam;
13025 - mp->Transfer_Parameters();
13029 - me -> SetGlobalH (mparam.maxh);
13030 - me -> SetLocalH (stlgeometry->GetBoundingBox().PMin() - Vec3d(10, 10, 10),
13031 - stlgeometry->GetBoundingBox().PMax() + Vec3d(10, 10, 10),
13035 - STLMeshing (*stlgeometry, *me);
13037 - stlgeometry->edgesfound = 1;
13038 - stlgeometry->surfacemeshed = 0;
13039 - stlgeometry->surfaceoptimized = 0;
13040 - stlgeometry->volumemeshed = 0;
13042 - int retval = STLSurfaceMeshing (*stlgeometry, *me);
13043 - if (retval == MESHING3_OK)
13045 - (*mycout) << "Success !!!!" << endl;
13046 - stlgeometry->surfacemeshed = 1;
13047 - stlgeometry->surfaceoptimized = 0;
13048 - stlgeometry->volumemeshed = 0;
13050 - else if (retval == MESHING3_OUTERSTEPSEXCEEDED)
13052 - (*mycout) << "ERROR: Give up because of too many trials. Meshing aborted!" << endl;
13054 - else if (retval == MESHING3_TERMINATE)
13056 - (*mycout) << "Meshing Stopped!" << endl;
13060 - (*mycout) << "ERROR: Surface meshing not successful. Meshing aborted!" << endl;
13064 - STLSurfaceOptimization (*stlgeometry, *me, mparam);
13072 - // fills STL Geometry
13073 - // positive orientation
13074 - // normal vector may be null-pointer
13075 - DLL_HEADER void Ng_STL_AddTriangle (Ng_STL_Geometry * geom,
13076 - double * p1, double * p2, double * p3,
13079 - Point<3> apts[3];
13080 - apts[0] = Point<3>(p1[0],p1[1],p1[2]);
13081 - apts[1] = Point<3>(p2[0],p2[1],p2[2]);
13082 - apts[2] = Point<3>(p3[0],p3[1],p3[2]);
13086 - n = Cross (apts[0]-apts[1], apts[0]-apts[2]);
13088 - n = Vec<3>(nv[0],nv[1],nv[2]);
13090 - readtrias.Append(STLReadTriangle(apts,n));
13093 - // add (optional) edges:
13094 - DLL_HEADER void Ng_STL_AddEdge (Ng_STL_Geometry * geom,
13095 - double * p1, double * p2)
13097 - readedges.Append(Point3d(p1[0],p1[1],p1[2]));
13098 - readedges.Append(Point3d(p2[0],p2[1],p2[2]));
13104 -#ifdef OCCGEOMETRY
13105 - // --------------------- OCC Geometry / Meshing Utility Functions -------------------
13106 - // Create new OCC Geometry Object
13107 - DLL_HEADER Ng_OCC_Geometry * Ng_OCC_NewGeometry ()
13109 - return (Ng_OCC_Geometry*)(void*)new OCCGeometry;
13115 - // Delete the OCC Geometry Object
13116 - DLL_HEADER Ng_Result Ng_OCC_DeleteGeometry(Ng_OCC_Geometry * geom)
13118 - if (geom != NULL)
13120 - delete (OCCGeometry*)geom;
13131 - // Loads geometry from STEP File
13132 - DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_STEP (const char * filename)
13134 - // Call the STEP File Load function. Note.. the geometry class
13135 - // is created and instantiated within the load function
13136 - OCCGeometry * occgeo = LoadOCC_STEP(filename);
13138 - return ((Ng_OCC_Geometry *)occgeo);
13144 - // Loads geometry from IGES File
13145 - DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_IGES (const char * filename)
13147 - // Call the IGES File Load function. Note.. the geometry class
13148 - // is created and instantiated within the load function
13149 - OCCGeometry * occgeo = LoadOCC_IGES(filename);
13151 - return ((Ng_OCC_Geometry *)occgeo);
13157 - // Loads geometry from BREP File
13158 - DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_BREP (const char * filename)
13160 - // Call the BREP File Load function. Note.. the geometry class
13161 - // is created and instantiated within the load function
13162 - OCCGeometry * occgeo = LoadOCC_BREP(filename);
13164 - return ((Ng_OCC_Geometry *)occgeo);
13170 - // Locally limit the size of the mesh to be generated at various points
13171 - // based on the topology of the geometry
13172 - DLL_HEADER Ng_Result Ng_OCC_SetLocalMeshSize (Ng_OCC_Geometry * geom,
13174 - Ng_Meshing_Parameters * mp)
13176 - OCCGeometry * occgeom = (OCCGeometry*)geom;
13177 - Mesh * me = (Mesh*)mesh;
13179 - me->geomtype = Mesh::GEOM_OCC;
13181 - mp->Transfer_Parameters();
13183 - occparam.resthcloseedgeenable = mp->closeedgeenable;
13184 - occparam.resthcloseedgefac = mp->closeedgefact;
13186 - // Delete the mesh structures in order to start with a clean
13188 - me->DeleteMesh();
13190 - OCCSetLocalMeshSize(*occgeom, *me);
13198 - // Mesh the edges and add Face descriptors to prepare for surface meshing
13199 - DLL_HEADER Ng_Result Ng_OCC_GenerateEdgeMesh (Ng_OCC_Geometry * geom,
13201 - Ng_Meshing_Parameters * mp)
13203 - OCCGeometry * occgeom = (OCCGeometry*)geom;
13204 - Mesh * me = (Mesh*)mesh;
13206 - mp->Transfer_Parameters();
13208 - OCCFindEdges(*occgeom, *me);
13210 - if((me->GetNP()) && (me->GetNFD()))
13223 - // Mesh the edges and add Face descriptors to prepare for surface meshing
13224 - DLL_HEADER Ng_Result Ng_OCC_GenerateSurfaceMesh (Ng_OCC_Geometry * geom,
13226 - Ng_Meshing_Parameters * mp)
13228 - int numpoints = 0;
13230 - OCCGeometry * occgeom = (OCCGeometry*)geom;
13231 - Mesh * me = (Mesh*)mesh;
13233 - // Set the internal meshing parameters structure from the nglib meshing
13234 - // parameters structure
13235 - mp->Transfer_Parameters();
13238 - // Only go into surface meshing if the face descriptors have already been added
13239 - if(!me->GetNFD())
13242 - numpoints = me->GetNP();
13244 - // Initially set up only for surface meshing without any optimisation
13245 - int perfstepsend = MESHCONST_MESHSURFACE;
13247 - // Check and if required, enable surface mesh optimisation step
13248 - if(mp->optsurfmeshenable)
13250 - perfstepsend = MESHCONST_OPTSURFACE;
13253 - OCCMeshSurface(*occgeom, *me, perfstepsend);
13255 - me->CalcSurfacesOfNode();
13257 - if(me->GetNP() <= numpoints)
13260 - if(me->GetNSE() <= 0)
13269 - // Extract the face map from the OCC geometry
13270 - // The face map basically gives an index to each face in the geometry,
13271 - // which can be used to access a specific face
13272 - DLL_HEADER Ng_Result Ng_OCC_GetFMap(Ng_OCC_Geometry * geom,
13273 - Ng_OCC_TopTools_IndexedMapOfShape * FMap)
13275 - OCCGeometry* occgeom = (OCCGeometry*)geom;
13276 - TopTools_IndexedMapOfShape *occfmap = (TopTools_IndexedMapOfShape *)FMap;
13278 - // Copy the face map from the geometry to the given variable
13279 - occfmap->Assign(occgeom->fmap);
13281 - if(occfmap->Extent())
13291 - // ------------------ End - OCC Geometry / Meshing Utility Functions ----------------
13297 - // ------------------ Begin - Meshing Parameters related functions ------------------
13298 - // Constructor for the local nglib meshing parameters class
13299 - DLL_HEADER Ng_Meshing_Parameters :: Ng_Meshing_Parameters()
13309 - elementsperedge = 2.0;
13310 - elementspercurve = 2.0;
13312 - closeedgeenable = 0;
13313 - closeedgefact = 2.0;
13315 - minedgelenenable = 0;
13316 - minedgelen = 1e-4;
13318 - second_order = 0;
13319 - quad_dominated = 0;
13321 - meshsize_filename = 0;
13323 - optsurfmeshenable = 1;
13324 - optvolmeshenable = 1;
13330 - invert_trigs = 0;
13332 - check_overlap = 1;
13333 - check_overlapping_boundary = 1;
13339 - // Reset the local meshing parameters to the default values
13340 - DLL_HEADER void Ng_Meshing_Parameters :: Reset_Parameters()
13350 - elementsperedge = 2.0;
13351 - elementspercurve = 2.0;
13353 - closeedgeenable = 0;
13354 - closeedgefact = 2.0;
13356 - minedgelenenable = 0;
13357 - minedgelen = 1e-4;
13359 - second_order = 0;
13360 - quad_dominated = 0;
13362 - meshsize_filename = 0;
13364 - optsurfmeshenable = 1;
13365 - optvolmeshenable = 1;
13371 - invert_trigs = 0;
13373 - check_overlap = 1;
13374 - check_overlapping_boundary = 1;
13381 - DLL_HEADER void Ng_Meshing_Parameters :: Transfer_Parameters()
13383 - mparam.uselocalh = uselocalh;
13385 - mparam.maxh = maxh;
13386 - mparam.minh = minh;
13388 - mparam.grading = grading;
13389 - mparam.curvaturesafety = elementspercurve;
13390 - mparam.segmentsperedge = elementsperedge;
13392 - mparam.secondorder = second_order;
13393 - mparam.quad = quad_dominated;
13395 - mparam.meshsizefilename = meshsize_filename;
13397 - mparam.optsteps2d = optsteps_2d;
13398 - mparam.optsteps3d = optsteps_3d;
13400 - mparam.inverttets = invert_tets;
13401 - mparam.inverttrigs = invert_trigs;
13403 - mparam.checkoverlap = check_overlap;
13404 - mparam.checkoverlappingboundary = check_overlapping_boundary;
13406 - // ------------------ End - Meshing Parameters related functions --------------------
13411 - // ------------------ Begin - Second Order Mesh generation functions ----------------
13412 - DLL_HEADER void Ng_Generate_SecondOrder(Ng_Mesh * mesh)
13415 - ref.MakeSecondOrder(*(Mesh*) mesh);
13421 - DLL_HEADER void Ng_2D_Generate_SecondOrder(Ng_Geometry_2D * geom,
13424 - ( (SplineGeometry2d*)geom ) -> GetRefinement().MakeSecondOrder( * (Mesh*) mesh );
13430 - DLL_HEADER void Ng_STL_Generate_SecondOrder(Ng_STL_Geometry * geom,
13433 - ((STLGeometry*)geom)->GetRefinement().MakeSecondOrder(*(Mesh*) mesh);
13439 - DLL_HEADER void Ng_CSG_Generate_SecondOrder (Ng_CSG_Geometry * geom,
13442 - ((CSGeometry*)geom)->GetRefinement().MakeSecondOrder(*(Mesh*) mesh);
13448 -#ifdef OCCGEOMETRY
13449 - DLL_HEADER void Ng_OCC_Generate_SecondOrder (Ng_OCC_Geometry * geom,
13452 - ((OCCGeometry*)geom )->GetRefinement().MakeSecondOrder(*(Mesh*) mesh);
13455 - // ------------------ End - Second Order Mesh generation functions ------------------
13460 - // ------------------ Begin - Uniform Mesh Refinement functions ---------------------
13461 - DLL_HEADER void Ng_Uniform_Refinement (Ng_Mesh * mesh)
13464 - ref.Refine ( * (Mesh*) mesh );
13470 - DLL_HEADER void Ng_2D_Uniform_Refinement (Ng_Geometry_2D * geom,
13473 - ( (SplineGeometry2d*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh );
13479 - DLL_HEADER void Ng_STL_Uniform_Refinement (Ng_STL_Geometry * geom,
13482 - ( (STLGeometry*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh );
13488 - DLL_HEADER void Ng_CSG_Uniform_Refinement (Ng_CSG_Geometry * geom,
13491 - ( (CSGeometry*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh );
13497 -#ifdef OCCGEOMETRY
13498 - DLL_HEADER void Ng_OCC_Uniform_Refinement (Ng_OCC_Geometry * geom,
13501 - ( (OCCGeometry*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh );
13504 - // ------------------ End - Uniform Mesh Refinement functions -----------------------
13505 -} // End of namespace nglib
13510 -// compatibility functions:
13513 - char geomfilename[255];
13515 - DLL_HEADER void MyError (const char * ch)
13523 - //Destination for messages, errors, ...
13524 - DLL_HEADER void Ng_PrintDest(const char * s)
13528 - MPI_Comm_rank(MPI_COMM_WORLD, &id);
13529 - if (id != 0) return;
13531 - (*mycout) << s << flush;
13537 - DLL_HEADER double GetTime ()
13545 - void ResetTime ()
13553 - void MyBeep (int i)
13565 -} // End of namespace netgen
13570 -void Ng_Redraw () { ; }
13571 -void Ng_ClearSolutionData () { ; }
13572 -void Ng_SetSolutionData (Ng_SolutionData * soldata)
13574 - delete soldata->solclass;
13576 -void Ng_InitSolutionData (Ng_SolutionData * soldata) { ; }
13579 +/**************************************************************************/
13580 +/* File: nglib.cpp */
13581 +/* Author: Joachim Schoeberl */
13582 +/* Date: 7. May. 2000 */
13583 +/**************************************************************************/
13587 + Interface to the netgen meshing kernel
13590 +#include <mystdlib.h>
13591 +#include <myadt.hpp>
13593 +#include <linalg.hpp>
13594 +#include <csg.hpp>
13595 +#include <stlgeom.hpp>
13596 +#include <geometry2d.hpp>
13597 +#include <meshing.hpp>
13598 +#include <../visualization/soldata.hpp>
13600 +#ifdef OCCGEOMETRY
13601 +#include <occgeom.hpp>
13604 +#include <nginterface.h>
13607 +namespace netgen {
13608 + extern void MeshFromSpline2D (SplineGeometry2d & geometry,
13610 + MeshingParameters & mp);
13620 + // int id = 0, ntasks = 1;
13621 + MPI_Comm mesh_comm;
13628 + int id = 0, ntasks = 1;
13634 +// should not be needed (occ currently requires it)
13635 +namespace netgen {
13636 +#include "../libsrc/visualization/vispar.hpp"
13637 + VisualizationParameters vispar;
13638 + VisualizationParameters :: VisualizationParameters() { ; }
13644 +#include "nglib.h"
13647 +using namespace netgen;
13648 +using namespace std;
13649 +// constants and types:
13653 + // initialize, deconstruct Netgen library:
13654 + DLL_HEADER void Ng_Init ()
13656 + mycout = &std::cout;
13658 + // netgen::testout->SetOutStream (new ofstream ("test.out"));
13659 + testout = new ofstream ("test.out");
13665 + // Clean-up functions before ending usage of nglib
13666 + DLL_HEADER void Ng_Exit ()
13675 + // Create a new netgen mesh object
13676 + DLL_HEADER Ng_Mesh * Ng_NewMesh ()
13678 + Mesh * mesh = new Mesh;
13679 + mesh->AddFaceDescriptor (FaceDescriptor (1, 1, 0, 1));
13680 + return (Ng_Mesh*)(void*)mesh;
13686 + // Delete an existing netgen mesh object
13687 + DLL_HEADER void Ng_DeleteMesh (Ng_Mesh * mesh)
13691 + // Delete the Mesh structures
13692 + ((Mesh*)mesh)->DeleteMesh();
13694 + // Now delete the Mesh class itself
13695 + delete (Mesh*)mesh;
13697 + // Set the Ng_Mesh pointer to NULL
13705 + // Save a netgen mesh in the native VOL format
13706 + DLL_HEADER void Ng_SaveMesh(Ng_Mesh * mesh, const char* filename)
13708 + ((Mesh*)mesh)->Save(filename);
13714 + // Load a netgen native VOL mesh from a given file
13715 + DLL_HEADER Ng_Mesh * Ng_LoadMesh(const char* filename)
13717 + Mesh * mesh = new Mesh;
13718 + mesh->Load(filename);
13719 + return ( (Ng_Mesh*)mesh );
13725 + // Merge another mesh file into the currently loaded one
13726 + DLL_HEADER Ng_Result Ng_MergeMesh( Ng_Mesh* mesh, const char* filename)
13728 + Ng_Result status = NG_OK;
13730 + ifstream infile(filename);
13731 + Mesh * m = (Mesh*)mesh;
13733 + if(!infile.good())
13735 + status = NG_FILE_NOT_FOUND;
13740 + status = NG_ERROR;
13743 + if(status == NG_OK)
13745 + const int num_pts = m->GetNP();
13746 + const int face_offset = m->GetNFD();
13748 + m->Merge(infile, face_offset);
13750 + if(m->GetNP() > num_pts)
13756 + status = NG_ERROR;
13766 + // Merge another mesh file into the currently loaded one
13767 + DLL_HEADER Ng_Result Ng_MergeMesh( Ng_Mesh* mesh1, Ng_Mesh* mesh2)
13775 + // Manually add a point to an existing mesh object
13776 + DLL_HEADER void Ng_AddPoint (Ng_Mesh * mesh, double * x)
13778 + Mesh * m = (Mesh*)mesh;
13779 + m->AddPoint (Point3d (x[0], x[1], x[2]));
13785 + // Manually add a surface element of a given type to an existing mesh object
13786 + DLL_HEADER void Ng_AddSurfaceElement (Ng_Mesh * mesh, Ng_Surface_Element_Type et,
13789 + Mesh * m = (Mesh*)mesh;
13790 + Element2d el (3);
13792 + el.PNum(1) = pi[0];
13793 + el.PNum(2) = pi[1];
13794 + el.PNum(3) = pi[2];
13795 + m->AddSurfaceElement (el);
13801 + // Manually add a volume element of a given type to an existing mesh object
13802 + DLL_HEADER void Ng_AddVolumeElement (Ng_Mesh * mesh, Ng_Volume_Element_Type et,
13805 + Mesh * m = (Mesh*)mesh;
13808 + el.PNum(1) = pi[0];
13809 + el.PNum(2) = pi[1];
13810 + el.PNum(3) = pi[2];
13811 + el.PNum(4) = pi[3];
13812 + m->AddVolumeElement (el);
13818 + // Obtain the number of points in the mesh
13819 + DLL_HEADER int Ng_GetNP (Ng_Mesh * mesh)
13821 + return ((Mesh*)mesh) -> GetNP();
13827 + // Obtain the number of surface elements in the mesh
13828 + DLL_HEADER int Ng_GetNSE (Ng_Mesh * mesh)
13830 + return ((Mesh*)mesh) -> GetNSE();
13836 + // Obtain the number of volume elements in the mesh
13837 + DLL_HEADER int Ng_GetNE (Ng_Mesh * mesh)
13839 + return ((Mesh*)mesh) -> GetNE();
13845 + // Return point coordinates of a given point index in the mesh
13846 + DLL_HEADER void Ng_GetPoint (Ng_Mesh * mesh, int num, double * x)
13848 + const Point3d & p = ((Mesh*)mesh)->Point(num);
13857 + // Return the surface element at a given index "pi"
13858 + DLL_HEADER Ng_Surface_Element_Type
13859 + Ng_GetSurfaceElement (Ng_Mesh * mesh, int num, int * pi)
13861 + const Element2d & el = ((Mesh*)mesh)->SurfaceElement(num);
13862 + for (int i = 1; i <= el.GetNP(); i++)
13863 + pi[i-1] = el.PNum(i);
13864 + Ng_Surface_Element_Type et;
13865 + switch (el.GetNP())
13867 + case 3: et = NG_TRIG; break;
13868 + case 4: et = NG_QUAD; break;
13870 + switch (el.GetNV())
13872 + case 3: et = NG_TRIG6; break;
13873 + case 4: et = NG_QUAD6; break;
13875 + et = NG_TRIG6; break;
13878 + case 8: et = NG_QUAD8; break;
13880 + et = NG_TRIG; break; // for the compiler
13888 + // Return the volume element at a given index "pi"
13889 + DLL_HEADER Ng_Volume_Element_Type
13890 + Ng_GetVolumeElement (Ng_Mesh * mesh, int num, int * pi)
13892 + const Element & el = ((Mesh*)mesh)->VolumeElement(num);
13893 + for (int i = 1; i <= el.GetNP(); i++)
13894 + pi[i-1] = el.PNum(i);
13895 + Ng_Volume_Element_Type et;
13896 + switch (el.GetNP())
13898 + case 4: et = NG_TET; break;
13899 + case 5: et = NG_PYRAMID; break;
13900 + case 6: et = NG_PRISM; break;
13901 + case 10: et = NG_TET10; break;
13903 + et = NG_TET; break; // for the compiler
13911 + // Set a global limit on the maximum mesh size allowed
13912 + DLL_HEADER void Ng_RestrictMeshSizeGlobal (Ng_Mesh * mesh, double h)
13914 + ((Mesh*)mesh) -> SetGlobalH (h);
13920 + // Set a local limit on the maximum mesh size allowed around the given point
13921 + DLL_HEADER void Ng_RestrictMeshSizePoint (Ng_Mesh * mesh, double * p, double h)
13923 + ((Mesh*)mesh) -> RestrictLocalH (Point3d (p[0], p[1], p[2]), h);
13929 + // Set a local limit on the maximum mesh size allowed within a given box region
13930 + DLL_HEADER void Ng_RestrictMeshSizeBox (Ng_Mesh * mesh, double * pmin, double * pmax, double h)
13932 + for (double x = pmin[0]; x < pmax[0]; x += h)
13933 + for (double y = pmin[1]; y < pmax[1]; y += h)
13934 + for (double z = pmin[2]; z < pmax[2]; z += h)
13935 + ((Mesh*)mesh) -> RestrictLocalH (Point3d (x, y, z), h);
13941 + // Generates volume mesh from an existing surface mesh
13942 + DLL_HEADER Ng_Result Ng_GenerateVolumeMesh (Ng_Mesh * mesh, Ng_Meshing_Parameters * mp)
13944 + Mesh * m = (Mesh*)mesh;
13946 + // Philippose - 30/08/2009
13947 + // Do not locally re-define "mparam" here... "mparam" is a global
13949 + //MeshingParameters mparam;
13950 + mp->Transfer_Parameters();
13952 + m->CalcLocalH(mparam.grading);
13954 + MeshVolume (mparam, *m);
13955 + RemoveIllegalElements (*m);
13956 + OptimizeVolume (mparam, *m);
13964 + /* ------------------ 2D Meshing Functions ------------------------- */
13965 + DLL_HEADER void Ng_AddPoint_2D (Ng_Mesh * mesh, double * x)
13967 + Mesh * m = (Mesh*)mesh;
13969 + m->AddPoint (Point3d (x[0], x[1], 0));
13975 + DLL_HEADER void Ng_AddBoundarySeg_2D (Ng_Mesh * mesh, int pi1, int pi2)
13977 + Mesh * m = (Mesh*)mesh;
13982 + m->AddSegment (seg);
13988 + DLL_HEADER int Ng_GetNP_2D (Ng_Mesh * mesh)
13990 + Mesh * m = (Mesh*)mesh;
13991 + return m->GetNP();
13997 + DLL_HEADER int Ng_GetNE_2D (Ng_Mesh * mesh)
13999 + Mesh * m = (Mesh*)mesh;
14000 + return m->GetNSE();
14006 + DLL_HEADER int Ng_GetNSeg_2D (Ng_Mesh * mesh)
14008 + Mesh * m = (Mesh*)mesh;
14009 + return m->GetNSeg();
14015 + DLL_HEADER void Ng_GetPoint_2D (Ng_Mesh * mesh, int num, double * x)
14017 + Mesh * m = (Mesh*)mesh;
14019 + Point<3> & p = m->Point(num);
14027 + DLL_HEADER Ng_Surface_Element_Type
14028 + Ng_GetElement_2D (Ng_Mesh * mesh, int num, int * pi, int * matnum)
14030 + const Element2d & el = ((Mesh*)mesh)->SurfaceElement(num);
14031 + for (int i = 1; i <= el.GetNP(); i++)
14032 + pi[i-1] = el.PNum(i);
14034 + Ng_Surface_Element_Type et;
14035 + switch (el.GetNP())
14037 + case 3: et = NG_TRIG; break;
14038 + case 4: et = NG_QUAD; break;
14040 + switch (el.GetNV())
14042 + case 3: et = NG_TRIG6; break;
14043 + case 4: et = NG_QUAD6; break;
14045 + et = NG_TRIG6; break;
14048 + case 8: et = NG_QUAD8; break;
14050 + et = NG_TRIG; break; // for the compiler
14054 + *matnum = el.GetIndex();
14062 + DLL_HEADER void Ng_GetSegment_2D (Ng_Mesh * mesh, int num, int * pi, int * matnum)
14064 + const Segment & seg = ((Mesh*)mesh)->LineSegment(num);
14069 + *matnum = seg.edgenr;
14075 + DLL_HEADER Ng_Geometry_2D * Ng_LoadGeometry_2D (const char * filename)
14077 + SplineGeometry2d * geom = new SplineGeometry2d();
14078 + geom -> Load (filename);
14079 + return (Ng_Geometry_2D *)geom;
14085 + DLL_HEADER Ng_Result Ng_GenerateMesh_2D (Ng_Geometry_2D * geom,
14087 + Ng_Meshing_Parameters * mp)
14089 + // use global variable mparam
14090 + // MeshingParameters mparam;
14091 + mp->Transfer_Parameters();
14094 + MeshFromSpline2D (*(SplineGeometry2d*)geom, m, mparam);
14096 + std::cout << m->GetNSE() << " elements, " << m->GetNP() << " points" << std::endl;
14098 + *mesh = (Ng_Mesh*)m;
14105 + DLL_HEADER void Ng_HP_Refinement (Ng_Geometry_2D * geom,
14109 + Refinement2d ref(*(SplineGeometry2d*)geom);
14110 + HPRefinement (*(Mesh*)mesh, &ref, levels);
14116 + DLL_HEADER void Ng_HP_Refinement (Ng_Geometry_2D * geom,
14118 + int levels, double parameter)
14120 + Refinement2d ref(*(SplineGeometry2d*)geom);
14121 + HPRefinement (*(Mesh*)mesh, &ref, levels, parameter);
14127 + Array<STLReadTriangle> readtrias; //only before initstlgeometry
14128 + Array<Point<3> > readedges; //only before init stlgeometry
14130 + // loads geometry from STL file
14131 + DLL_HEADER Ng_STL_Geometry * Ng_STL_LoadGeometry (const char * filename, int binary)
14134 + STLGeometry geom;
14135 + STLGeometry* geo;
14136 + ifstream ist(filename);
14140 + geo = geom.LoadBinary(ist);
14144 + geo = geom.Load(ist);
14147 + readtrias.SetSize(0);
14148 + readedges.SetSize(0);
14157 + Ng_STL_Geometry * geo2 = Ng_STL_NewGeometry();
14159 + for (i = 1; i <= geo->GetNT(); i++)
14161 + const STLTriangle& t = geo->GetTriangle(i);
14162 + p = geo->GetPoint(t.PNum(1));
14163 + p1[0] = p.X(); p1[1] = p.Y(); p1[2] = p.Z();
14164 + p = geo->GetPoint(t.PNum(2));
14165 + p2[0] = p.X(); p2[1] = p.Y(); p2[2] = p.Z();
14166 + p = geo->GetPoint(t.PNum(3));
14167 + p3[0] = p.X(); p3[1] = p.Y(); p3[2] = p.Z();
14168 + normal = t.Normal();
14169 + n[0] = normal.X(); n[1] = normal.Y(); n[2] = normal.Z();
14171 + Ng_STL_AddTriangle(geo2, p1, p2, p3, n);
14180 + // generate new STL Geometry
14181 + DLL_HEADER Ng_STL_Geometry * Ng_STL_NewGeometry ()
14183 + return (Ng_STL_Geometry*)(void*)new STLGeometry;
14189 + // after adding triangles (and edges) initialize
14190 + DLL_HEADER Ng_Result Ng_STL_InitSTLGeometry (Ng_STL_Geometry * geom)
14192 + STLGeometry* geo = (STLGeometry*)geom;
14193 + geo->InitSTLGeometry(readtrias);
14194 + readtrias.SetSize(0);
14196 + if (readedges.Size() != 0)
14199 + for (int i = 1; i <= readedges.Size(); i+=2)
14201 + cout << "e(" << readedges.Get(i) << "," << readedges.Get(i+1) << ")" << endl;
14204 + geo->AddEdges(readedges);
14207 + if (geo->GetStatus() == STLTopology::STL_GOOD || geo->GetStatus() == STLTopology::STL_WARNING) return NG_OK;
14208 + return NG_SURFACE_INPUT_ERROR;
14214 + // automatically generates edges:
14215 + DLL_HEADER Ng_Result Ng_STL_MakeEdges (Ng_STL_Geometry * geom,
14217 + Ng_Meshing_Parameters * mp)
14219 + STLGeometry* stlgeometry = (STLGeometry*)geom;
14220 + Mesh* me = (Mesh*)mesh;
14222 + // Philippose - 27/07/2009
14223 + // Do not locally re-define "mparam" here... "mparam" is a global
14225 + //MeshingParameters mparam;
14226 + mp->Transfer_Parameters();
14228 + me -> SetGlobalH (mparam.maxh);
14229 + me -> SetLocalH (stlgeometry->GetBoundingBox().PMin() - Vec3d(10, 10, 10),
14230 + stlgeometry->GetBoundingBox().PMax() + Vec3d(10, 10, 10),
14233 + me -> LoadLocalMeshSize (mp->meshsize_filename);
14235 + if (mp->meshsize_filename)
14237 + ifstream infile (mp->meshsize_filename);
14238 + if (!infile.good()) return NG_FILE_NOT_FOUND;
14239 + me -> LoadLocalMeshSize (infile);
14243 + STLMeshing (*stlgeometry, *me);
14245 + stlgeometry->edgesfound = 1;
14246 + stlgeometry->surfacemeshed = 0;
14247 + stlgeometry->surfaceoptimized = 0;
14248 + stlgeometry->volumemeshed = 0;
14256 + // generates mesh, empty mesh be already created.
14257 + DLL_HEADER Ng_Result Ng_STL_GenerateSurfaceMesh (Ng_STL_Geometry * geom,
14259 + Ng_Meshing_Parameters * mp)
14261 + STLGeometry* stlgeometry = (STLGeometry*)geom;
14262 + Mesh* me = (Mesh*)mesh;
14264 + // Philippose - 27/07/2009
14265 + // Do not locally re-define "mparam" here... "mparam" is a global
14267 + //MeshingParameters mparam;
14268 + mp->Transfer_Parameters();
14272 + me -> SetGlobalH (mparam.maxh);
14273 + me -> SetLocalH (stlgeometry->GetBoundingBox().PMin() - Vec3d(10, 10, 10),
14274 + stlgeometry->GetBoundingBox().PMax() + Vec3d(10, 10, 10),
14278 + STLMeshing (*stlgeometry, *me);
14280 + stlgeometry->edgesfound = 1;
14281 + stlgeometry->surfacemeshed = 0;
14282 + stlgeometry->surfaceoptimized = 0;
14283 + stlgeometry->volumemeshed = 0;
14285 + int retval = STLSurfaceMeshing (*stlgeometry, *me);
14286 + if (retval == MESHING3_OK)
14288 + (*mycout) << "Success !!!!" << std::endl;
14289 + stlgeometry->surfacemeshed = 1;
14290 + stlgeometry->surfaceoptimized = 0;
14291 + stlgeometry->volumemeshed = 0;
14293 + else if (retval == MESHING3_OUTERSTEPSEXCEEDED)
14295 + (*mycout) << "ERROR: Give up because of too many trials. Meshing aborted!" << std::endl;
14297 + else if (retval == MESHING3_TERMINATE)
14299 + (*mycout) << "Meshing Stopped!" << std::endl;
14303 + (*mycout) << "ERROR: Surface meshing not successful. Meshing aborted!" << std::endl;
14307 + STLSurfaceOptimization (*stlgeometry, *me, mparam);
14315 + // fills STL Geometry
14316 + // positive orientation
14317 + // normal vector may be null-pointer
14318 + DLL_HEADER void Ng_STL_AddTriangle (Ng_STL_Geometry * geom,
14319 + double * p1, double * p2, double * p3,
14322 + Point<3> apts[3];
14323 + apts[0] = Point<3>(p1[0],p1[1],p1[2]);
14324 + apts[1] = Point<3>(p2[0],p2[1],p2[2]);
14325 + apts[2] = Point<3>(p3[0],p3[1],p3[2]);
14329 + n = Cross (apts[0]-apts[1], apts[0]-apts[2]);
14331 + n = Vec<3>(nv[0],nv[1],nv[2]);
14333 + readtrias.Append(STLReadTriangle(apts,n));
14336 + // add (optional) edges:
14337 + DLL_HEADER void Ng_STL_AddEdge (Ng_STL_Geometry * geom,
14338 + double * p1, double * p2)
14340 + readedges.Append(Point3d(p1[0],p1[1],p1[2]));
14341 + readedges.Append(Point3d(p2[0],p2[1],p2[2]));
14347 +#ifdef OCCGEOMETRY
14348 + // --------------------- OCC Geometry / Meshing Utility Functions -------------------
14349 + // Create new OCC Geometry Object
14350 + DLL_HEADER Ng_OCC_Geometry * Ng_OCC_NewGeometry ()
14352 + return (Ng_OCC_Geometry*)(void*)new OCCGeometry;
14358 + // Delete the OCC Geometry Object
14359 + DLL_HEADER Ng_Result Ng_OCC_DeleteGeometry(Ng_OCC_Geometry * geom)
14361 + if (geom != NULL)
14363 + delete (OCCGeometry*)geom;
14374 + // Loads geometry from STEP File
14375 + DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_STEP (const char * filename)
14377 + // Call the STEP File Load function. Note.. the geometry class
14378 + // is created and instantiated within the load function
14379 + OCCGeometry * occgeo = LoadOCC_STEP(filename);
14381 + return ((Ng_OCC_Geometry *)occgeo);
14387 + // Loads geometry from IGES File
14388 + DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_IGES (const char * filename)
14390 + // Call the IGES File Load function. Note.. the geometry class
14391 + // is created and instantiated within the load function
14392 + OCCGeometry * occgeo = LoadOCC_IGES(filename);
14394 + return ((Ng_OCC_Geometry *)occgeo);
14400 + // Loads geometry from BREP File
14401 + DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_BREP (const char * filename)
14403 + // Call the BREP File Load function. Note.. the geometry class
14404 + // is created and instantiated within the load function
14405 + OCCGeometry * occgeo = LoadOCC_BREP(filename);
14407 + return ((Ng_OCC_Geometry *)occgeo);
14413 + // Locally limit the size of the mesh to be generated at various points
14414 + // based on the topology of the geometry
14415 + DLL_HEADER Ng_Result Ng_OCC_SetLocalMeshSize (Ng_OCC_Geometry * geom,
14417 + Ng_Meshing_Parameters * mp)
14419 + OCCGeometry * occgeom = (OCCGeometry*)geom;
14420 + Mesh * me = (Mesh*)mesh;
14422 + me->geomtype = Mesh::GEOM_OCC;
14424 + mp->Transfer_Parameters();
14426 + occparam.resthcloseedgeenable = mp->closeedgeenable;
14427 + occparam.resthcloseedgefac = mp->closeedgefact;
14429 + // Delete the mesh structures in order to start with a clean
14431 + me->DeleteMesh();
14433 + OCCSetLocalMeshSize(*occgeom, *me);
14441 + // Mesh the edges and add Face descriptors to prepare for surface meshing
14442 + DLL_HEADER Ng_Result Ng_OCC_GenerateEdgeMesh (Ng_OCC_Geometry * geom,
14444 + Ng_Meshing_Parameters * mp)
14446 + OCCGeometry * occgeom = (OCCGeometry*)geom;
14447 + Mesh * me = (Mesh*)mesh;
14449 + mp->Transfer_Parameters();
14451 + OCCFindEdges(*occgeom, *me);
14453 + if((me->GetNP()) && (me->GetNFD()))
14466 + // Mesh the edges and add Face descriptors to prepare for surface meshing
14467 + DLL_HEADER Ng_Result Ng_OCC_GenerateSurfaceMesh (Ng_OCC_Geometry * geom,
14469 + Ng_Meshing_Parameters * mp)
14471 + int numpoints = 0;
14473 + OCCGeometry * occgeom = (OCCGeometry*)geom;
14474 + Mesh * me = (Mesh*)mesh;
14476 + // Set the internal meshing parameters structure from the nglib meshing
14477 + // parameters structure
14478 + mp->Transfer_Parameters();
14481 + // Only go into surface meshing if the face descriptors have already been added
14482 + if(!me->GetNFD())
14485 + numpoints = me->GetNP();
14487 + // Initially set up only for surface meshing without any optimisation
14488 + int perfstepsend = MESHCONST_MESHSURFACE;
14490 + // Check and if required, enable surface mesh optimisation step
14491 + if(mp->optsurfmeshenable)
14493 + perfstepsend = MESHCONST_OPTSURFACE;
14496 + OCCMeshSurface(*occgeom, *me, perfstepsend);
14498 + me->CalcSurfacesOfNode();
14500 + if(me->GetNP() <= numpoints)
14503 + if(me->GetNSE() <= 0)
14512 + // Extract the face map from the OCC geometry
14513 + // The face map basically gives an index to each face in the geometry,
14514 + // which can be used to access a specific face
14515 + DLL_HEADER Ng_Result Ng_OCC_GetFMap(Ng_OCC_Geometry * geom,
14516 + Ng_OCC_TopTools_IndexedMapOfShape * FMap)
14518 + OCCGeometry* occgeom = (OCCGeometry*)geom;
14519 + TopTools_IndexedMapOfShape *occfmap = (TopTools_IndexedMapOfShape *)FMap;
14521 + // Copy the face map from the geometry to the given variable
14522 + occfmap->Assign(occgeom->fmap);
14524 + if(occfmap->Extent())
14534 + // ------------------ End - OCC Geometry / Meshing Utility Functions ----------------
14540 + // ------------------ Begin - Meshing Parameters related functions ------------------
14541 + // Constructor for the local nglib meshing parameters class
14542 + DLL_HEADER Ng_Meshing_Parameters :: Ng_Meshing_Parameters()
14552 + elementsperedge = 2.0;
14553 + elementspercurve = 2.0;
14555 + closeedgeenable = 0;
14556 + closeedgefact = 2.0;
14558 + minedgelenenable = 0;
14559 + minedgelen = 1e-4;
14561 + second_order = 0;
14562 + quad_dominated = 0;
14564 + meshsize_filename = 0;
14566 + optsurfmeshenable = 1;
14567 + optvolmeshenable = 1;
14573 + invert_trigs = 0;
14575 + check_overlap = 1;
14576 + check_overlapping_boundary = 1;
14582 + // Reset the local meshing parameters to the default values
14583 + DLL_HEADER void Ng_Meshing_Parameters :: Reset_Parameters()
14593 + elementsperedge = 2.0;
14594 + elementspercurve = 2.0;
14596 + closeedgeenable = 0;
14597 + closeedgefact = 2.0;
14599 + minedgelenenable = 0;
14600 + minedgelen = 1e-4;
14602 + second_order = 0;
14603 + quad_dominated = 0;
14605 + meshsize_filename = 0;
14607 + optsurfmeshenable = 1;
14608 + optvolmeshenable = 1;
14614 + invert_trigs = 0;
14616 + check_overlap = 1;
14617 + check_overlapping_boundary = 1;
14624 + DLL_HEADER void Ng_Meshing_Parameters :: Transfer_Parameters()
14626 + mparam.uselocalh = uselocalh;
14628 + mparam.maxh = maxh;
14629 + mparam.minh = minh;
14631 + mparam.grading = grading;
14632 + mparam.curvaturesafety = elementspercurve;
14633 + mparam.segmentsperedge = elementsperedge;
14635 + mparam.secondorder = second_order;
14636 + mparam.quad = quad_dominated;
14638 + mparam.meshsizefilename = meshsize_filename;
14640 + mparam.optsteps2d = optsteps_2d;
14641 + mparam.optsteps3d = optsteps_3d;
14643 + mparam.inverttets = invert_tets;
14644 + mparam.inverttrigs = invert_trigs;
14646 + mparam.checkoverlap = check_overlap;
14647 + mparam.checkoverlappingboundary = check_overlapping_boundary;
14649 + // ------------------ End - Meshing Parameters related functions --------------------
14654 + // ------------------ Begin - Second Order Mesh generation functions ----------------
14655 + DLL_HEADER void Ng_Generate_SecondOrder(Ng_Mesh * mesh)
14658 + ref.MakeSecondOrder(*(Mesh*) mesh);
14664 + DLL_HEADER void Ng_2D_Generate_SecondOrder(Ng_Geometry_2D * geom,
14667 + ( (SplineGeometry2d*)geom ) -> GetRefinement().MakeSecondOrder( * (Mesh*) mesh );
14673 + DLL_HEADER void Ng_STL_Generate_SecondOrder(Ng_STL_Geometry * geom,
14676 + ((STLGeometry*)geom)->GetRefinement().MakeSecondOrder(*(Mesh*) mesh);
14682 + DLL_HEADER void Ng_CSG_Generate_SecondOrder (Ng_CSG_Geometry * geom,
14685 + ((CSGeometry*)geom)->GetRefinement().MakeSecondOrder(*(Mesh*) mesh);
14691 +#ifdef OCCGEOMETRY
14692 + DLL_HEADER void Ng_OCC_Generate_SecondOrder (Ng_OCC_Geometry * geom,
14695 + ((OCCGeometry*)geom )->GetRefinement().MakeSecondOrder(*(Mesh*) mesh);
14698 + // ------------------ End - Second Order Mesh generation functions ------------------
14703 + // ------------------ Begin - Uniform Mesh Refinement functions ---------------------
14704 + DLL_HEADER void Ng_Uniform_Refinement (Ng_Mesh * mesh)
14707 + ref.Refine ( * (Mesh*) mesh );
14713 + DLL_HEADER void Ng_2D_Uniform_Refinement (Ng_Geometry_2D * geom,
14716 + ( (SplineGeometry2d*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh );
14722 + DLL_HEADER void Ng_STL_Uniform_Refinement (Ng_STL_Geometry * geom,
14725 + ( (STLGeometry*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh );
14731 + DLL_HEADER void Ng_CSG_Uniform_Refinement (Ng_CSG_Geometry * geom,
14734 + ( (CSGeometry*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh );
14740 +#ifdef OCCGEOMETRY
14741 + DLL_HEADER void Ng_OCC_Uniform_Refinement (Ng_OCC_Geometry * geom,
14744 + ( (OCCGeometry*)geom ) -> GetRefinement().Refine ( * (Mesh*) mesh );
14747 + // ------------------ End - Uniform Mesh Refinement functions -----------------------
14748 +} // End of namespace nglib
14753 +// compatibility functions:
14756 + char geomfilename[255];
14758 + DLL_HEADER void MyError (const char * ch)
14766 + //Destination for messages, errors, ...
14767 + DLL_HEADER void Ng_PrintDest(const char * s)
14771 + MPI_Comm_rank(MPI_COMM_WORLD, &id);
14772 + if (id != 0) return;
14774 + (*mycout) << s << std::flush;
14780 + DLL_HEADER double GetTime ()
14788 + void ResetTime ()
14796 + void MyBeep (int i)
14808 +} // End of namespace netgen
14813 +void Ng_Redraw () { ; }
14814 +void Ng_ClearSolutionData () { ; }
14815 +void Ng_SetSolutionData (Ng_SolutionData * soldata)
14817 + delete soldata->solclass;
14819 +void Ng_InitSolutionData (Ng_SolutionData * soldata) { ; }
14822 --- netgen_ref/nglib/nglib.h
14823 +++ netgen/nglib/nglib.h
14824 @@ -1,747 +1,747 @@
14828 -/**************************************************************************/
14829 -/* File: nglib.h */
14830 -/* Author: Joachim Schoeberl */
14831 -/* Date: 7. May. 2000 */
14832 -/**************************************************************************/
14836 - \brief Library interface to the netgen meshing kernel
14837 - \author Joachim Schoeberl
14838 - \date 7. May 2000
14840 - This header file provides access to the core functionality of the Netgen
14841 - Mesher via a library interface, without an interactive User Interface.
14843 - The intention of providing these set of functions is to allow system
14844 - developers to integrate Netgen into top-level code, to act as the low
14845 - level mesh generation / optimisation kernel.
14848 -// Philippose - 14.02.2009
14849 -// Modifications for creating a DLL in Windows
14851 - #ifdef NGLIB_EXPORTS || nglib_EXPORTS
14852 - #define DLL_HEADER __declspec(dllexport)
14854 - #define DLL_HEADER __declspec(dllimport)
14857 - #define DLL_HEADER
14862 -// ** Constants used within Netgen *********************
14863 -/// Maximum allowed number of nodes per volume element
14864 -#define NG_VOLUME_ELEMENT_MAXPOINTS 10
14866 -/// Maximum allowed number of nodes per surface element
14867 -#define NG_SURFACE_ELEMENT_MAXPOINTS 8
14871 -// *** Data-types for accessing Netgen functionality ***
14872 -/// Data type for NETGEN mesh
14873 -typedef void * Ng_Mesh;
14875 -/// Data type for NETGEN CSG geometry
14876 -typedef void * Ng_CSG_Geometry;
14878 -/// Data type for NETGEN 2D geometry
14879 -typedef void * Ng_Geometry_2D;
14881 -/// Data type for NETGEN STL geometry
14882 -typedef void * Ng_STL_Geometry;
14884 -#ifdef OCCGEOMETRY
14885 -/// Data type for NETGEN OpenCascade geometry
14886 -typedef void * Ng_OCC_Geometry;
14887 -typedef void * Ng_OCC_TopTools_IndexedMapOfShape;
14891 -// *** Special Enum types used within Netgen ***********
14892 -/// Currently implemented surface element types
14893 -enum Ng_Surface_Element_Type
14894 - { NG_TRIG = 1, NG_QUAD = 2, NG_TRIG6 = 3, NG_QUAD6 = 4, NG_QUAD8 = 5 };
14896 -/// Currently implemented volume element types
14897 -enum Ng_Volume_Element_Type
14898 - { NG_TET = 1, NG_PYRAMID = 2, NG_PRISM = 3, NG_TET10 = 4 };
14900 -/// Values returned by Netgen functions
14905 - NG_SURFACE_INPUT_ERROR = 1,
14906 - NG_VOLUME_FAILURE = 2,
14907 - NG_STL_INPUT_ERROR = 3,
14908 - NG_SURFACE_FAILURE = 4,
14909 - NG_FILE_NOT_FOUND = 5
14914 -// *** Classes required for use within Netgen **********
14915 -/// Netgen Meshing Parameters class
14916 -class Ng_Meshing_Parameters
14919 - int uselocalh; //!< Switch to enable / disable usage of local mesh size modifiers
14921 - double maxh; //!< Maximum global mesh size allowed
14922 - double minh; //!< Minimum global mesh size allowed
14924 - double fineness; //!< Mesh density: 0...1 (0 => coarse; 1 => fine)
14925 - double grading; //!< Mesh grading: 0...1 (0 => uniform mesh; 1 => aggressive local grading)
14927 - double elementsperedge; //!< Number of elements to generate per edge of the geometry
14928 - double elementspercurve; //!< Elements to generate per curvature radius
14930 - int closeedgeenable; //!< Enable / Disable mesh refinement at close edges
14931 - double closeedgefact; //!< Factor to use for refinement at close edges (larger => finer)
14933 - int minedgelenenable; //!< Enable / Disable user defined minimum edge length for edge subdivision
14934 - double minedgelen; //!< Minimum edge length to use while subdividing the edges (default = 1e-4)
14936 - int second_order; //!< Generate second-order surface and volume elements
14937 - int quad_dominated; //!< Creates a Quad-dominated mesh
14939 - char * meshsize_filename; //!< Optional external mesh size file
14941 - int optsurfmeshenable; //!< Enable / Disable automatic surface mesh optimization
14942 - int optvolmeshenable; //!< Enable / Disable automatic volume mesh optimization
14944 - int optsteps_3d; //!< Number of optimize steps to use for 3-D mesh optimization
14945 - int optsteps_2d; //!< Number of optimize steps to use for 2-D mesh optimization
14947 - // Philippose - 13/09/2010
14948 - // Added a couple more parameters into the meshing parameters list
14949 - // from Netgen into Nglib
14950 - int invert_tets; //!< Invert all the volume elements
14951 - int invert_trigs; //!< Invert all the surface triangle elements
14953 - int check_overlap; //!< Check for overlapping surfaces during Surface meshing
14954 - int check_overlapping_boundary; //!< Check for overlapping surface elements before volume meshing
14958 - Default constructor for the Mesh Parameters class
14960 - Note: This constructor initialises the variables in the
14961 - class with the following default values
14966 - - #elementsperedge: 2.0
14967 - - #elementspercurve: 2.0
14968 - - #closeedgeenable: 0
14969 - - #closeedgefact: 2.0
14970 - - #secondorder: 0
14971 - - #meshsize_filename: null
14972 - - #quad_dominated: 0
14973 - - #optsurfmeshenable: 1
14974 - - #optvolmeshenable: 1
14975 - - #optsteps_2d: 3
14976 - - #optsteps_3d: 3
14977 - - #invert_tets: 0
14978 - - #invert_trigs:0
14979 - - #check_overlap: 1
14980 - - #check_overlapping_boundary: 1
14982 - DLL_HEADER Ng_Meshing_Parameters();
14987 - Reset the meshing parameters to their defaults
14989 - This member function resets all the meshing parameters
14990 - of the object to the default values
14992 - DLL_HEADER void Reset_Parameters();
14997 - Transfer local meshing parameters to internal meshing parameters
14999 - This member function transfers all the meshing parameters
15000 - defined in the local meshing parameters structure of nglib into
15001 - the internal meshing parameters structure used by the Netgen core
15003 - DLL_HEADER void Transfer_Parameters();
15009 -// *** Functions Exported by this Library *************
15011 -// ------------------------------------------------------------------
15012 -// Netgen library initialisation / destruction functions
15014 -/*! \brief Initialise the Netgen library and prepare for use
15016 - This function needs to be called by the third-party
15017 - program before beginning to use the other Netgen
15018 - specific functions.
15020 -DLL_HEADER void Ng_Init ();
15023 -/*! \brief Exit the Netgen meshing kernel in a clean manner
15025 - Use this function to exit the meshing sub-system in
15026 - a clean and orderly manner.
15028 -DLL_HEADER void Ng_Exit ();
15031 -/*! \brief Create a new (and empty) Netgen Mesh Structure
15033 - This function creates a new Netgen Mesh, initialises
15034 - it, and returns a pointer to the created mesh structure.
15036 - Use the returned pointer for subsequent operations
15037 - which involve mesh operations.
15039 - \return Ng_Mesh Pointer to a Netgen Mesh type #Ng_Mesh
15041 -DLL_HEADER Ng_Mesh * Ng_NewMesh ();
15044 -/*! \brief Delete an existing Netgen Mesh Structure
15046 - Use this function to delete an existing Netgen mesh
15047 - structure and release the used memory.
15049 - \param mesh Pointer to an existing Netgen Mesh structure
15052 -DLL_HEADER void Ng_DeleteMesh (Ng_Mesh * mesh);
15055 -/*! \brief Save a Netgen Mesh to disk
15057 - This function allows a generated mesh structure to be saved
15060 - A Mesh saved using this function, will be written to disk
15061 - in the Netgen VOL file format.
15063 - \param mesh Pointer to an existing Netgen Mesh structure
15065 - \param filename Pointer to a character array containing the
15066 - name of the file to which the mesh should
15069 -DLL_HEADER void Ng_SaveMesh(Ng_Mesh * mesh, const char* filename);
15072 -/*! \brief Load a Netgen VOL Mesh from disk into memory
15074 - A Netgen mesh saved in the internal VOL format can be loaded
15075 - into a Netgen Mesh structure using this function.
15077 - \param filename Pointer to a character array containing the
15078 - name of the file to load
15079 - \return Ng_Mesh Pointer to a Netgen Mesh type #Ng_Mesh containing
15080 - the mesh loaded from disk
15082 -DLL_HEADER Ng_Mesh * Ng_LoadMesh(const char* filename);
15085 -/*! \brief Merge a Netgen VOL Mesh from disk into an existing mesh in memory
15087 - A Netgen mesh saved in the internal VOL format can be merged
15088 - into an existing Netgen Mesh structure using this function.
15090 - \param mesh Name of the Mesh structure already existent in memory
15091 - \param filename Pointer to a character array containing the
15092 - name of the file to load
15093 - \return Ng_Result Status of the merge operation
15095 -DLL_HEADER Ng_Result Ng_MergeMesh(Ng_Mesh * mesh, const char* filename);
15098 -/*! \brief Merge one Netgen Mesh into another Netgen Mesh in the case
15099 - when both are already in memory
15101 - (NOTE: FUNCTION STILL WORK IN PROGRESS!!!)
15103 - This function can be used to merge two Netgen meshes already present
15106 - \param mesh1 Parent Mesh structure into which the second mesh
15108 - \param mesh2 Child mesh structure which will get merged into
15110 - \return Ng_Result Status of the merge operation
15112 -DLL_HEADER Ng_Result Ng_MergeMesh(Ng_Mesh * mesh1, Ng_Mesh * mesh2);
15113 -// ------------------------------------------------------------------
15117 -// ------------------------------------------------------------------
15118 -// Basic Meshing functions for manually adding points, surface elements
15119 -// and volume elements to a Netgen Mesh structure
15121 -/*! \brief Add a point to a given Netgen Mesh Structure
15123 - This function allows points to be directly added to a Netgen
15124 - mesh structure by providing the co-ordinates.
15126 - Each call to the function allows only one point to be added.
15128 - \param mesh Pointer to an existing Netgen Mesh structure of
15130 - \param x Pointer to an array of type double containing the co-ordinates
15131 - of the point to be added in the form: \n
15132 - - x[0] = X co-ordinate
15133 - - x[1] = Y co-ordinate
15134 - - x[2] = Z co-ordinate
15136 -DLL_HEADER void Ng_AddPoint (Ng_Mesh * mesh, double * x);
15139 -/*! \brief Add a surface element to a given Netgen Mesh Structure
15141 - This function allows the top-level code to directly add individual
15142 - Surface Elements to a Netgen Mesh Structure by providing the type of
15143 - element to be added and the indices of the points which constitute the
15147 - - The points referred to by the surface elements must have been
15148 - added prior to calling this function.
15149 - - Currently only triangular elements are supported, and the Surface Element
15150 - Type argument is not used.
15152 - \param mesh Pointer to an existing Netgen Mesh structure of
15154 - \param et Surface Element type provided via the enumerated type
15155 - #Ng_Surface_Element_Type
15156 - \param pi Pointer to an array of integers containing the indices of the
15157 - points which constitute the surface element being added
15159 -DLL_HEADER void Ng_AddSurfaceElement (Ng_Mesh * mesh, Ng_Surface_Element_Type et, int * pi);
15162 -/*! \brief Add a volume element to a given Netgen Mesh Structure
15164 - This function allows the top-level code to directly add individual
15165 - Volume Elements to a Netgen Mesh Structure by providing the type of
15166 - element to be added and the indices of the points which constitute the
15170 - - The points referred to by the volume elements must have been
15171 - added prior to calling this function.
15172 - - Currently only tetrahedral elements are supported, and the Volume Element
15173 - Type argument is not used.
15175 - \param mesh Pointer to an existing Netgen Mesh structure of
15177 - \param et Volume Element type provided via the enumerated type
15178 - #Ng_Volume_Element_Type
15179 - \param pi Pointer to an array of integers containing the indices of the
15180 - points which constitute the volume element being added
15183 -DLL_HEADER void Ng_AddVolumeElement (Ng_Mesh * mesh, Ng_Volume_Element_Type et, int * pi);
15185 -// ------------------------------------------------------------------
15189 -// ------------------------------------------------------------------
15190 -// Local Mesh Size restriction / limiting utilities
15192 -/*! \brief Apply a global restriction on mesh element size
15194 - This utility allows the user to apply a global mesh element
15197 - During mesh creation, in the absence of an explicit local
15198 - size restriction around the neighbourhood of a point within
15199 - the meshing domain, this global size restriction will be
15202 - <b>Note</b>: This function only limits the <b>Maximum</b>
15203 - size of an element within the mesh.
15205 - \param mesh Pointer to an existing Netgen Mesh structure of
15207 - \param h Variable of type <i>double</i>, specifying the maximum
15208 - allowable mesh size
15210 -DLL_HEADER void Ng_RestrictMeshSizeGlobal (Ng_Mesh * mesh, double h);
15213 -/*! \brief Locally restrict the mesh element size at the given point
15215 - Unlike the function #Ng_RestrictMeshSizeGlobal, this function
15216 - allows the user to locally restrict the maximum allowable mesh
15217 - size at a given point.
15219 - The point is specified via its three cartesian co-ordinates.
15221 - <b>Note</b>: This function only limits the <b>Maximum</b> size
15222 - of the elements around the specified point.
15224 - \param mesh Pointer to an existing Netgen Mesh structure of
15226 - \param p Pointer to an Array of type <i>double</i>, containing
15227 - the three co-ordinates of the point in the form: \n
15228 - - p[0] = X co-ordinate
15229 - - p[1] = Y co-ordinate
15230 - - p[2] = Z co-ordinate
15231 - \param h Variable of type <i>double</i>, specifying the maximum
15232 - allowable mesh size at that point
15234 -DLL_HEADER void Ng_RestrictMeshSizePoint (Ng_Mesh * mesh, double * p, double h);
15237 -/*! \brief Locally restrict the mesh element size within a specified box
15239 - Similar to the function #Ng_RestrictMeshSizePoint, this function
15240 - allows the size of elements within a mesh to be locally limited.
15242 - However, rather than limit the mesh size at a single point, this
15243 - utility restricts the local mesh size within a 3D Box region, specified
15244 - via the co-ordinates of the two diagonally opposite points of a cuboid.
15246 - <b>Note</b>: This function only limits the <b>Maximum</b> size
15247 - of the elements within the specified region.
15249 - \param mesh Pointer to an existing Netgen Mesh structure of
15251 - \param pmin Pointer to an Array of type <i>double</i>, containing
15252 - the three co-ordinates of the first point of the cuboid: \n
15253 - - pmin[0] = X co-ordinate
15254 - - pmin[1] = Y co-ordinate
15255 - - pmin[2] = Z co-ordinate
15256 - \param pmax Pointer to an Array of type <i>double</i>, containing
15257 - the three co-ordinates of the opposite point of the
15259 - - pmax[0] = X co-ordinate
15260 - - pmax[1] = Y co-ordinate
15261 - - pmax[2] = Z co-ordinate
15262 - \param h Variable of type <i>double</i>, specifying the maximum
15263 - allowable mesh size at that point
15265 -DLL_HEADER void Ng_RestrictMeshSizeBox (Ng_Mesh * mesh, double * pmin, double * pmax, double h);
15267 -// ------------------------------------------------------------------
15271 -// ------------------------------------------------------------------
15272 -// 3D Mesh Generation functions
15274 -/*! \brief Create a 3D Volume Mesh given a Surface Mesh
15276 - After creating a surface mesh, this function can be utilised
15277 - to automatically generate the corresponding 3D Volume Mesh.
15279 - Mesh generation parameters (such as grading, maximum element size,
15280 - etc.) are specified via the meshing parameters class which also
15281 - needs to be passed to this function.
15283 - <b>Note</b>: Currently, Netgen generates pure tetrahedral volume
15286 - \param mesh Pointer to an existing Netgen Mesh structure of
15288 - \param mp Pointer to a copy of the Meshing Parameters class
15289 - (#Ng_Meshing_Parameters), filled up with the
15292 - \return Ng_Result Status of the Mesh Generation routine. More
15293 - details regarding the return value can be
15294 - found in the description of #Ng_Result
15296 -DLL_HEADER Ng_Result Ng_GenerateVolumeMesh (Ng_Mesh * mesh, Ng_Meshing_Parameters * mp);
15298 -// ------------------------------------------------------------------
15302 -// ------------------------------------------------------------------
15303 -// Basic Mesh information functions
15305 -/*! \brief Returns the Number of Points present in the specified Mesh
15307 - Given an already existent Netgen Mesh Structure, this function
15308 - returns the number of points currently present within the Mesh.
15310 - \param mesh Pointer to an existing Netgen Mesh structure of
15313 - Integer Data-type with the number of points in the Mesh
15315 -DLL_HEADER int Ng_GetNP (Ng_Mesh * mesh);
15318 -/*! \brief Returns the Number of Surface Elements present in the specified Mesh
15320 - Given an already existent Netgen Mesh Structure, this function
15321 - returns the number of surface elements currently present within
15324 - \param mesh Pointer to an existing Netgen Mesh structure of
15327 - Integer Data-type with the number of surface elements in the Mesh
15329 -DLL_HEADER int Ng_GetNSE (Ng_Mesh * mesh);
15332 -/*! \brief Returns the Number of Volume Elements present in the specified Mesh
15334 - Given an already existent Netgen Mesh Structure, this function
15335 - returns the number of volume elements currently present within
15338 - \param mesh Pointer to an existing Netgen Mesh structure of
15341 - Integer Data-type with the number of volume elements in the Mesh
15343 -DLL_HEADER int Ng_GetNE (Ng_Mesh * mesh);
15345 -// ------------------------------------------------------------------
15349 -// ------------------------------------------------------------------
15350 -// Mesh Topology functions
15351 -// Use these functions to extract points, surface / volume elements,
15352 -// perform topological searches, etc..etc...
15354 -// Return the Point Coordinates of a specified Point
15355 -// The x, y and z co-ordinates are returned in the array pointer as
15356 -// x[0] = x ; x[1] = y ; x[2] = z
15357 -DLL_HEADER void Ng_GetPoint (Ng_Mesh * mesh, int num, double * x);
15361 -// return surface and volume element in pi
15362 -DLL_HEADER Ng_Surface_Element_Type
15363 -Ng_GetSurfaceElement (Ng_Mesh * mesh, int num, int * pi);
15365 -DLL_HEADER Ng_Volume_Element_Type
15366 -Ng_GetVolumeElement (Ng_Mesh * mesh, int num, int * pi);
15368 -// ------------------------------------------------------------------
15373 -// **********************************************************
15374 -// ** 2D Meshing **
15375 -// **********************************************************
15378 -// feeds points and boundary to mesh
15380 -DLL_HEADER void Ng_AddPoint_2D (Ng_Mesh * mesh, double * x);
15381 -DLL_HEADER void Ng_AddBoundarySeg_2D (Ng_Mesh * mesh, int pi1, int pi2);
15383 -// ask for number of points, elements and boundary segments
15384 -DLL_HEADER int Ng_GetNP_2D (Ng_Mesh * mesh);
15385 -DLL_HEADER int Ng_GetNE_2D (Ng_Mesh * mesh);
15386 -DLL_HEADER int Ng_GetNSeg_2D (Ng_Mesh * mesh);
15388 -// return point coordinates
15389 -DLL_HEADER void Ng_GetPoint_2D (Ng_Mesh * mesh, int num, double * x);
15391 -// return 2d elements
15392 -DLL_HEADER Ng_Surface_Element_Type
15393 -Ng_GetElement_2D (Ng_Mesh * mesh, int num, int * pi, int * matnum = NULL);
15395 -// return 2d boundary segment
15396 -DLL_HEADER void Ng_GetSegment_2D (Ng_Mesh * mesh, int num, int * pi, int * matnum = NULL);
15399 -// load 2d netgen spline geometry
15400 -DLL_HEADER Ng_Geometry_2D * Ng_LoadGeometry_2D (const char * filename);
15402 -// generate 2d mesh, mesh is allocated by function
15403 -DLL_HEADER Ng_Result Ng_GenerateMesh_2D (Ng_Geometry_2D * geom,
15405 - Ng_Meshing_Parameters * mp);
15407 -DLL_HEADER void Ng_HP_Refinement (Ng_Geometry_2D * geom,
15415 -// **********************************************************
15416 -// ** STL Meshing **
15417 -// **********************************************************
15420 -// loads geometry from STL file
15421 -DLL_HEADER Ng_STL_Geometry * Ng_STL_LoadGeometry (const char * filename, int binary = 0);
15424 -// generate new STL Geometry
15425 -DLL_HEADER Ng_STL_Geometry * Ng_STL_NewGeometry ();
15428 -// fills STL Geometry
15429 -// positive orientation
15430 -// normal vector may be null-pointer
15431 -DLL_HEADER void Ng_STL_AddTriangle (Ng_STL_Geometry * geom,
15432 - double * p1, double * p2, double * p3,
15433 - double * nv = NULL);
15435 -// add (optional) edges :
15436 -DLL_HEADER void Ng_STL_AddEdge (Ng_STL_Geometry * geom,
15437 - double * p1, double * p2);
15439 -// after adding triangles (and edges) initialize
15440 -DLL_HEADER Ng_Result Ng_STL_InitSTLGeometry (Ng_STL_Geometry * geom);
15442 -// automatically generates edges:
15443 -DLL_HEADER Ng_Result Ng_STL_MakeEdges (Ng_STL_Geometry * geom,
15445 - Ng_Meshing_Parameters * mp);
15448 -// generates mesh, empty mesh must be already created.
15449 -DLL_HEADER Ng_Result Ng_STL_GenerateSurfaceMesh (Ng_STL_Geometry * geom,
15451 - Ng_Meshing_Parameters * mp);
15456 -// **********************************************************
15457 -// ** ACIS Meshing **
15458 -// **********************************************************
15460 -/// Data type for NETGEN STL geomty
15461 -typedef void * Ng_ACIS_Geometry;
15463 -// loads geometry from STL file
15464 -DLL_HEADER Ng_ACIS_Geometry * Ng_ACIS_LoadGeometry (const char * filename);
15466 -// generates mesh, empty mesh must be already created.
15467 -DLL_HEADER Ng_Result Ng_ACIS_GenerateSurfaceMesh (Ng_ACIS_Geometry * geom,
15469 - Ng_Meshing_Parameters * mp);
15476 -#ifdef OCCGEOMETRY
15478 -// **********************************************************
15479 -// ** OpenCascade Geometry / Meshing Utilities **
15480 -// **********************************************************
15482 -// Create new OCC Geometry Object
15483 -DLL_HEADER Ng_OCC_Geometry * Ng_OCC_NewGeometry ();
15485 -// Delete an OCC Geometry Object
15486 -DLL_HEADER Ng_Result Ng_OCC_DeleteGeometry (Ng_OCC_Geometry * geom);
15488 -// Loads geometry from STEP file
15489 -DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_STEP (const char * filename);
15491 -// Loads geometry from IGES file
15492 -DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_IGES (const char * filename);
15494 -// Loads geometry from BREP file
15495 -DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_BREP (const char * filename);
15497 -// Set the local mesh size based on geometry / topology
15498 -DLL_HEADER Ng_Result Ng_OCC_SetLocalMeshSize (Ng_OCC_Geometry * geom,
15500 - Ng_Meshing_Parameters * mp);
15502 -// Mesh the edges and add Face descriptors to prepare for surface meshing
15503 -DLL_HEADER Ng_Result Ng_OCC_GenerateEdgeMesh (Ng_OCC_Geometry * geom,
15505 - Ng_Meshing_Parameters * mp);
15507 -// Mesh the surfaces of an OCC geometry
15508 -DLL_HEADER Ng_Result Ng_OCC_GenerateSurfaceMesh (Ng_OCC_Geometry * geom,
15510 - Ng_Meshing_Parameters * mp);
15512 -// Get the face map of an already loaded OCC geometry
15513 -DLL_HEADER Ng_Result Ng_OCC_GetFMap(Ng_OCC_Geometry * geom,
15514 - Ng_OCC_TopTools_IndexedMapOfShape * FMap);
15516 -#endif // OCCGEOMETRY
15520 -// **********************************************************
15521 -// ** Mesh refinement algorithms **
15522 -// **********************************************************
15524 -// uniform mesh refinement
15525 -DLL_HEADER void Ng_Uniform_Refinement (Ng_Mesh * mesh);
15528 -// uniform mesh refinement with geometry adaption:
15530 -DLL_HEADER void Ng_2D_Uniform_Refinement (Ng_Geometry_2D * geom,
15533 -DLL_HEADER void Ng_STL_Uniform_Refinement (Ng_STL_Geometry * geom,
15536 -DLL_HEADER void Ng_CSG_Uniform_Refinement (Ng_CSG_Geometry * geom,
15539 -#ifdef OCCGEOMETRY
15540 -DLL_HEADER void Ng_OCC_Uniform_Refinement (Ng_OCC_Geometry * geom,
15546 -// **********************************************************
15547 -// ** Second Order mesh algorithms **
15548 -// **********************************************************
15550 -// convert mesh to second order
15551 -DLL_HEADER void Ng_Generate_SecondOrder (Ng_Mesh * mesh);
15554 -// convert mesh to second order with geometry adaption:
15556 -DLL_HEADER void Ng_2D_Generate_SecondOrder (Ng_Geometry_2D * geom,
15559 -DLL_HEADER void Ng_STL_Generate_SecondOrder (Ng_STL_Geometry * geom,
15562 -DLL_HEADER void Ng_CSG_Generate_SecondOrder (Ng_CSG_Geometry * geom,
15565 -#ifdef OCCGEOMETRY
15566 -DLL_HEADER void Ng_OCC_Generate_SecondOrder (Ng_OCC_Geometry * geom,
15575 +/**************************************************************************/
15576 +/* File: nglib.h */
15577 +/* Author: Joachim Schoeberl */
15578 +/* Date: 7. May. 2000 */
15579 +/**************************************************************************/
15583 + \brief Library interface to the netgen meshing kernel
15584 + \author Joachim Schoeberl
15585 + \date 7. May 2000
15587 + This header file provides access to the core functionality of the Netgen
15588 + Mesher via a library interface, without an interactive User Interface.
15590 + The intention of providing these set of functions is to allow system
15591 + developers to integrate Netgen into top-level code, to act as the low
15592 + level mesh generation / optimisation kernel.
15595 +// Philippose - 14.02.2009
15596 +// Modifications for creating a DLL in Windows
15598 + #if defined NGLIB_EXPORTS || defined nglib_EXPORTS
15599 + #define DLL_HEADER __declspec(dllexport)
15601 + #define DLL_HEADER __declspec(dllimport)
15604 + #define DLL_HEADER
15609 +// ** Constants used within Netgen *********************
15610 +/// Maximum allowed number of nodes per volume element
15611 +#define NG_VOLUME_ELEMENT_MAXPOINTS 10
15613 +/// Maximum allowed number of nodes per surface element
15614 +#define NG_SURFACE_ELEMENT_MAXPOINTS 8
15618 +// *** Data-types for accessing Netgen functionality ***
15619 +/// Data type for NETGEN mesh
15620 +typedef void * Ng_Mesh;
15622 +/// Data type for NETGEN CSG geometry
15623 +typedef void * Ng_CSG_Geometry;
15625 +/// Data type for NETGEN 2D geometry
15626 +typedef void * Ng_Geometry_2D;
15628 +/// Data type for NETGEN STL geometry
15629 +typedef void * Ng_STL_Geometry;
15631 +#ifdef OCCGEOMETRY
15632 +/// Data type for NETGEN OpenCascade geometry
15633 +typedef void * Ng_OCC_Geometry;
15634 +typedef void * Ng_OCC_TopTools_IndexedMapOfShape;
15638 +// *** Special Enum types used within Netgen ***********
15639 +/// Currently implemented surface element types
15640 +enum Ng_Surface_Element_Type
15641 + { NG_TRIG = 1, NG_QUAD = 2, NG_TRIG6 = 3, NG_QUAD6 = 4, NG_QUAD8 = 5 };
15643 +/// Currently implemented volume element types
15644 +enum Ng_Volume_Element_Type
15645 + { NG_TET = 1, NG_PYRAMID = 2, NG_PRISM = 3, NG_TET10 = 4 };
15647 +/// Values returned by Netgen functions
15652 + NG_SURFACE_INPUT_ERROR = 1,
15653 + NG_VOLUME_FAILURE = 2,
15654 + NG_STL_INPUT_ERROR = 3,
15655 + NG_SURFACE_FAILURE = 4,
15656 + NG_FILE_NOT_FOUND = 5
15661 +// *** Classes required for use within Netgen **********
15662 +/// Netgen Meshing Parameters class
15663 +class Ng_Meshing_Parameters
15666 + int uselocalh; //!< Switch to enable / disable usage of local mesh size modifiers
15668 + double maxh; //!< Maximum global mesh size allowed
15669 + double minh; //!< Minimum global mesh size allowed
15671 + double fineness; //!< Mesh density: 0...1 (0 => coarse; 1 => fine)
15672 + double grading; //!< Mesh grading: 0...1 (0 => uniform mesh; 1 => aggressive local grading)
15674 + double elementsperedge; //!< Number of elements to generate per edge of the geometry
15675 + double elementspercurve; //!< Elements to generate per curvature radius
15677 + int closeedgeenable; //!< Enable / Disable mesh refinement at close edges
15678 + double closeedgefact; //!< Factor to use for refinement at close edges (larger => finer)
15680 + int minedgelenenable; //!< Enable / Disable user defined minimum edge length for edge subdivision
15681 + double minedgelen; //!< Minimum edge length to use while subdividing the edges (default = 1e-4)
15683 + int second_order; //!< Generate second-order surface and volume elements
15684 + int quad_dominated; //!< Creates a Quad-dominated mesh
15686 + char * meshsize_filename; //!< Optional external mesh size file
15688 + int optsurfmeshenable; //!< Enable / Disable automatic surface mesh optimization
15689 + int optvolmeshenable; //!< Enable / Disable automatic volume mesh optimization
15691 + int optsteps_3d; //!< Number of optimize steps to use for 3-D mesh optimization
15692 + int optsteps_2d; //!< Number of optimize steps to use for 2-D mesh optimization
15694 + // Philippose - 13/09/2010
15695 + // Added a couple more parameters into the meshing parameters list
15696 + // from Netgen into Nglib
15697 + int invert_tets; //!< Invert all the volume elements
15698 + int invert_trigs; //!< Invert all the surface triangle elements
15700 + int check_overlap; //!< Check for overlapping surfaces during Surface meshing
15701 + int check_overlapping_boundary; //!< Check for overlapping surface elements before volume meshing
15705 + Default constructor for the Mesh Parameters class
15707 + Note: This constructor initialises the variables in the
15708 + class with the following default values
15713 + - #elementsperedge: 2.0
15714 + - #elementspercurve: 2.0
15715 + - #closeedgeenable: 0
15716 + - #closeedgefact: 2.0
15717 + - #secondorder: 0
15718 + - #meshsize_filename: null
15719 + - #quad_dominated: 0
15720 + - #optsurfmeshenable: 1
15721 + - #optvolmeshenable: 1
15722 + - #optsteps_2d: 3
15723 + - #optsteps_3d: 3
15724 + - #invert_tets: 0
15725 + - #invert_trigs:0
15726 + - #check_overlap: 1
15727 + - #check_overlapping_boundary: 1
15729 + DLL_HEADER Ng_Meshing_Parameters();
15734 + Reset the meshing parameters to their defaults
15736 + This member function resets all the meshing parameters
15737 + of the object to the default values
15739 + DLL_HEADER void Reset_Parameters();
15744 + Transfer local meshing parameters to internal meshing parameters
15746 + This member function transfers all the meshing parameters
15747 + defined in the local meshing parameters structure of nglib into
15748 + the internal meshing parameters structure used by the Netgen core
15750 + DLL_HEADER void Transfer_Parameters();
15756 +// *** Functions Exported by this Library *************
15758 +// ------------------------------------------------------------------
15759 +// Netgen library initialisation / destruction functions
15761 +/*! \brief Initialise the Netgen library and prepare for use
15763 + This function needs to be called by the third-party
15764 + program before beginning to use the other Netgen
15765 + specific functions.
15767 +DLL_HEADER void Ng_Init ();
15770 +/*! \brief Exit the Netgen meshing kernel in a clean manner
15772 + Use this function to exit the meshing sub-system in
15773 + a clean and orderly manner.
15775 +DLL_HEADER void Ng_Exit ();
15778 +/*! \brief Create a new (and empty) Netgen Mesh Structure
15780 + This function creates a new Netgen Mesh, initialises
15781 + it, and returns a pointer to the created mesh structure.
15783 + Use the returned pointer for subsequent operations
15784 + which involve mesh operations.
15786 + \return Ng_Mesh Pointer to a Netgen Mesh type #Ng_Mesh
15788 +DLL_HEADER Ng_Mesh * Ng_NewMesh ();
15791 +/*! \brief Delete an existing Netgen Mesh Structure
15793 + Use this function to delete an existing Netgen mesh
15794 + structure and release the used memory.
15796 + \param mesh Pointer to an existing Netgen Mesh structure
15799 +DLL_HEADER void Ng_DeleteMesh (Ng_Mesh * mesh);
15802 +/*! \brief Save a Netgen Mesh to disk
15804 + This function allows a generated mesh structure to be saved
15807 + A Mesh saved using this function, will be written to disk
15808 + in the Netgen VOL file format.
15810 + \param mesh Pointer to an existing Netgen Mesh structure
15812 + \param filename Pointer to a character array containing the
15813 + name of the file to which the mesh should
15816 +DLL_HEADER void Ng_SaveMesh(Ng_Mesh * mesh, const char* filename);
15819 +/*! \brief Load a Netgen VOL Mesh from disk into memory
15821 + A Netgen mesh saved in the internal VOL format can be loaded
15822 + into a Netgen Mesh structure using this function.
15824 + \param filename Pointer to a character array containing the
15825 + name of the file to load
15826 + \return Ng_Mesh Pointer to a Netgen Mesh type #Ng_Mesh containing
15827 + the mesh loaded from disk
15829 +DLL_HEADER Ng_Mesh * Ng_LoadMesh(const char* filename);
15832 +/*! \brief Merge a Netgen VOL Mesh from disk into an existing mesh in memory
15834 + A Netgen mesh saved in the internal VOL format can be merged
15835 + into an existing Netgen Mesh structure using this function.
15837 + \param mesh Name of the Mesh structure already existent in memory
15838 + \param filename Pointer to a character array containing the
15839 + name of the file to load
15840 + \return Ng_Result Status of the merge operation
15842 +DLL_HEADER Ng_Result Ng_MergeMesh(Ng_Mesh * mesh, const char* filename);
15845 +/*! \brief Merge one Netgen Mesh into another Netgen Mesh in the case
15846 + when both are already in memory
15848 + (NOTE: FUNCTION STILL WORK IN PROGRESS!!!)
15850 + This function can be used to merge two Netgen meshes already present
15853 + \param mesh1 Parent Mesh structure into which the second mesh
15855 + \param mesh2 Child mesh structure which will get merged into
15857 + \return Ng_Result Status of the merge operation
15859 +DLL_HEADER Ng_Result Ng_MergeMesh(Ng_Mesh * mesh1, Ng_Mesh * mesh2);
15860 +// ------------------------------------------------------------------
15864 +// ------------------------------------------------------------------
15865 +// Basic Meshing functions for manually adding points, surface elements
15866 +// and volume elements to a Netgen Mesh structure
15868 +/*! \brief Add a point to a given Netgen Mesh Structure
15870 + This function allows points to be directly added to a Netgen
15871 + mesh structure by providing the co-ordinates.
15873 + Each call to the function allows only one point to be added.
15875 + \param mesh Pointer to an existing Netgen Mesh structure of
15877 + \param x Pointer to an array of type double containing the co-ordinates
15878 + of the point to be added in the form: \n
15879 + - x[0] = X co-ordinate
15880 + - x[1] = Y co-ordinate
15881 + - x[2] = Z co-ordinate
15883 +DLL_HEADER void Ng_AddPoint (Ng_Mesh * mesh, double * x);
15886 +/*! \brief Add a surface element to a given Netgen Mesh Structure
15888 + This function allows the top-level code to directly add individual
15889 + Surface Elements to a Netgen Mesh Structure by providing the type of
15890 + element to be added and the indices of the points which constitute the
15894 + - The points referred to by the surface elements must have been
15895 + added prior to calling this function.
15896 + - Currently only triangular elements are supported, and the Surface Element
15897 + Type argument is not used.
15899 + \param mesh Pointer to an existing Netgen Mesh structure of
15901 + \param et Surface Element type provided via the enumerated type
15902 + #Ng_Surface_Element_Type
15903 + \param pi Pointer to an array of integers containing the indices of the
15904 + points which constitute the surface element being added
15906 +DLL_HEADER void Ng_AddSurfaceElement (Ng_Mesh * mesh, Ng_Surface_Element_Type et, int * pi);
15909 +/*! \brief Add a volume element to a given Netgen Mesh Structure
15911 + This function allows the top-level code to directly add individual
15912 + Volume Elements to a Netgen Mesh Structure by providing the type of
15913 + element to be added and the indices of the points which constitute the
15917 + - The points referred to by the volume elements must have been
15918 + added prior to calling this function.
15919 + - Currently only tetrahedral elements are supported, and the Volume Element
15920 + Type argument is not used.
15922 + \param mesh Pointer to an existing Netgen Mesh structure of
15924 + \param et Volume Element type provided via the enumerated type
15925 + #Ng_Volume_Element_Type
15926 + \param pi Pointer to an array of integers containing the indices of the
15927 + points which constitute the volume element being added
15930 +DLL_HEADER void Ng_AddVolumeElement (Ng_Mesh * mesh, Ng_Volume_Element_Type et, int * pi);
15932 +// ------------------------------------------------------------------
15936 +// ------------------------------------------------------------------
15937 +// Local Mesh Size restriction / limiting utilities
15939 +/*! \brief Apply a global restriction on mesh element size
15941 + This utility allows the user to apply a global mesh element
15944 + During mesh creation, in the absence of an explicit local
15945 + size restriction around the neighbourhood of a point within
15946 + the meshing domain, this global size restriction will be
15949 + <b>Note</b>: This function only limits the <b>Maximum</b>
15950 + size of an element within the mesh.
15952 + \param mesh Pointer to an existing Netgen Mesh structure of
15954 + \param h Variable of type <i>double</i>, specifying the maximum
15955 + allowable mesh size
15957 +DLL_HEADER void Ng_RestrictMeshSizeGlobal (Ng_Mesh * mesh, double h);
15960 +/*! \brief Locally restrict the mesh element size at the given point
15962 + Unlike the function #Ng_RestrictMeshSizeGlobal, this function
15963 + allows the user to locally restrict the maximum allowable mesh
15964 + size at a given point.
15966 + The point is specified via its three cartesian co-ordinates.
15968 + <b>Note</b>: This function only limits the <b>Maximum</b> size
15969 + of the elements around the specified point.
15971 + \param mesh Pointer to an existing Netgen Mesh structure of
15973 + \param p Pointer to an Array of type <i>double</i>, containing
15974 + the three co-ordinates of the point in the form: \n
15975 + - p[0] = X co-ordinate
15976 + - p[1] = Y co-ordinate
15977 + - p[2] = Z co-ordinate
15978 + \param h Variable of type <i>double</i>, specifying the maximum
15979 + allowable mesh size at that point
15981 +DLL_HEADER void Ng_RestrictMeshSizePoint (Ng_Mesh * mesh, double * p, double h);
15984 +/*! \brief Locally restrict the mesh element size within a specified box
15986 + Similar to the function #Ng_RestrictMeshSizePoint, this function
15987 + allows the size of elements within a mesh to be locally limited.
15989 + However, rather than limit the mesh size at a single point, this
15990 + utility restricts the local mesh size within a 3D Box region, specified
15991 + via the co-ordinates of the two diagonally opposite points of a cuboid.
15993 + <b>Note</b>: This function only limits the <b>Maximum</b> size
15994 + of the elements within the specified region.
15996 + \param mesh Pointer to an existing Netgen Mesh structure of
15998 + \param pmin Pointer to an Array of type <i>double</i>, containing
15999 + the three co-ordinates of the first point of the cuboid: \n
16000 + - pmin[0] = X co-ordinate
16001 + - pmin[1] = Y co-ordinate
16002 + - pmin[2] = Z co-ordinate
16003 + \param pmax Pointer to an Array of type <i>double</i>, containing
16004 + the three co-ordinates of the opposite point of the
16006 + - pmax[0] = X co-ordinate
16007 + - pmax[1] = Y co-ordinate
16008 + - pmax[2] = Z co-ordinate
16009 + \param h Variable of type <i>double</i>, specifying the maximum
16010 + allowable mesh size at that point
16012 +DLL_HEADER void Ng_RestrictMeshSizeBox (Ng_Mesh * mesh, double * pmin, double * pmax, double h);
16014 +// ------------------------------------------------------------------
16018 +// ------------------------------------------------------------------
16019 +// 3D Mesh Generation functions
16021 +/*! \brief Create a 3D Volume Mesh given a Surface Mesh
16023 + After creating a surface mesh, this function can be utilised
16024 + to automatically generate the corresponding 3D Volume Mesh.
16026 + Mesh generation parameters (such as grading, maximum element size,
16027 + etc.) are specified via the meshing parameters class which also
16028 + needs to be passed to this function.
16030 + <b>Note</b>: Currently, Netgen generates pure tetrahedral volume
16033 + \param mesh Pointer to an existing Netgen Mesh structure of
16035 + \param mp Pointer to a copy of the Meshing Parameters class
16036 + (#Ng_Meshing_Parameters), filled up with the
16039 + \return Ng_Result Status of the Mesh Generation routine. More
16040 + details regarding the return value can be
16041 + found in the description of #Ng_Result
16043 +DLL_HEADER Ng_Result Ng_GenerateVolumeMesh (Ng_Mesh * mesh, Ng_Meshing_Parameters * mp);
16045 +// ------------------------------------------------------------------
16049 +// ------------------------------------------------------------------
16050 +// Basic Mesh information functions
16052 +/*! \brief Returns the Number of Points present in the specified Mesh
16054 + Given an already existent Netgen Mesh Structure, this function
16055 + returns the number of points currently present within the Mesh.
16057 + \param mesh Pointer to an existing Netgen Mesh structure of
16060 + Integer Data-type with the number of points in the Mesh
16062 +DLL_HEADER int Ng_GetNP (Ng_Mesh * mesh);
16065 +/*! \brief Returns the Number of Surface Elements present in the specified Mesh
16067 + Given an already existent Netgen Mesh Structure, this function
16068 + returns the number of surface elements currently present within
16071 + \param mesh Pointer to an existing Netgen Mesh structure of
16074 + Integer Data-type with the number of surface elements in the Mesh
16076 +DLL_HEADER int Ng_GetNSE (Ng_Mesh * mesh);
16079 +/*! \brief Returns the Number of Volume Elements present in the specified Mesh
16081 + Given an already existent Netgen Mesh Structure, this function
16082 + returns the number of volume elements currently present within
16085 + \param mesh Pointer to an existing Netgen Mesh structure of
16088 + Integer Data-type with the number of volume elements in the Mesh
16090 +DLL_HEADER int Ng_GetNE (Ng_Mesh * mesh);
16092 +// ------------------------------------------------------------------
16096 +// ------------------------------------------------------------------
16097 +// Mesh Topology functions
16098 +// Use these functions to extract points, surface / volume elements,
16099 +// perform topological searches, etc..etc...
16101 +// Return the Point Coordinates of a specified Point
16102 +// The x, y and z co-ordinates are returned in the array pointer as
16103 +// x[0] = x ; x[1] = y ; x[2] = z
16104 +DLL_HEADER void Ng_GetPoint (Ng_Mesh * mesh, int num, double * x);
16108 +// return surface and volume element in pi
16109 +DLL_HEADER Ng_Surface_Element_Type
16110 +Ng_GetSurfaceElement (Ng_Mesh * mesh, int num, int * pi);
16112 +DLL_HEADER Ng_Volume_Element_Type
16113 +Ng_GetVolumeElement (Ng_Mesh * mesh, int num, int * pi);
16115 +// ------------------------------------------------------------------
16120 +// **********************************************************
16121 +// ** 2D Meshing **
16122 +// **********************************************************
16125 +// feeds points and boundary to mesh
16127 +DLL_HEADER void Ng_AddPoint_2D (Ng_Mesh * mesh, double * x);
16128 +DLL_HEADER void Ng_AddBoundarySeg_2D (Ng_Mesh * mesh, int pi1, int pi2);
16130 +// ask for number of points, elements and boundary segments
16131 +DLL_HEADER int Ng_GetNP_2D (Ng_Mesh * mesh);
16132 +DLL_HEADER int Ng_GetNE_2D (Ng_Mesh * mesh);
16133 +DLL_HEADER int Ng_GetNSeg_2D (Ng_Mesh * mesh);
16135 +// return point coordinates
16136 +DLL_HEADER void Ng_GetPoint_2D (Ng_Mesh * mesh, int num, double * x);
16138 +// return 2d elements
16139 +DLL_HEADER Ng_Surface_Element_Type
16140 +Ng_GetElement_2D (Ng_Mesh * mesh, int num, int * pi, int * matnum = NULL);
16142 +// return 2d boundary segment
16143 +DLL_HEADER void Ng_GetSegment_2D (Ng_Mesh * mesh, int num, int * pi, int * matnum = NULL);
16146 +// load 2d netgen spline geometry
16147 +DLL_HEADER Ng_Geometry_2D * Ng_LoadGeometry_2D (const char * filename);
16149 +// generate 2d mesh, mesh is allocated by function
16150 +DLL_HEADER Ng_Result Ng_GenerateMesh_2D (Ng_Geometry_2D * geom,
16152 + Ng_Meshing_Parameters * mp);
16154 +DLL_HEADER void Ng_HP_Refinement (Ng_Geometry_2D * geom,
16162 +// **********************************************************
16163 +// ** STL Meshing **
16164 +// **********************************************************
16167 +// loads geometry from STL file
16168 +DLL_HEADER Ng_STL_Geometry * Ng_STL_LoadGeometry (const char * filename, int binary = 0);
16171 +// generate new STL Geometry
16172 +DLL_HEADER Ng_STL_Geometry * Ng_STL_NewGeometry ();
16175 +// fills STL Geometry
16176 +// positive orientation
16177 +// normal vector may be null-pointer
16178 +DLL_HEADER void Ng_STL_AddTriangle (Ng_STL_Geometry * geom,
16179 + double * p1, double * p2, double * p3,
16180 + double * nv = NULL);
16182 +// add (optional) edges :
16183 +DLL_HEADER void Ng_STL_AddEdge (Ng_STL_Geometry * geom,
16184 + double * p1, double * p2);
16186 +// after adding triangles (and edges) initialize
16187 +DLL_HEADER Ng_Result Ng_STL_InitSTLGeometry (Ng_STL_Geometry * geom);
16189 +// automatically generates edges:
16190 +DLL_HEADER Ng_Result Ng_STL_MakeEdges (Ng_STL_Geometry * geom,
16192 + Ng_Meshing_Parameters * mp);
16195 +// generates mesh, empty mesh must be already created.
16196 +DLL_HEADER Ng_Result Ng_STL_GenerateSurfaceMesh (Ng_STL_Geometry * geom,
16198 + Ng_Meshing_Parameters * mp);
16203 +// **********************************************************
16204 +// ** ACIS Meshing **
16205 +// **********************************************************
16207 +/// Data type for NETGEN STL geomty
16208 +typedef void * Ng_ACIS_Geometry;
16210 +// loads geometry from STL file
16211 +DLL_HEADER Ng_ACIS_Geometry * Ng_ACIS_LoadGeometry (const char * filename);
16213 +// generates mesh, empty mesh must be already created.
16214 +DLL_HEADER Ng_Result Ng_ACIS_GenerateSurfaceMesh (Ng_ACIS_Geometry * geom,
16216 + Ng_Meshing_Parameters * mp);
16223 +#ifdef OCCGEOMETRY
16225 +// **********************************************************
16226 +// ** OpenCascade Geometry / Meshing Utilities **
16227 +// **********************************************************
16229 +// Create new OCC Geometry Object
16230 +DLL_HEADER Ng_OCC_Geometry * Ng_OCC_NewGeometry ();
16232 +// Delete an OCC Geometry Object
16233 +DLL_HEADER Ng_Result Ng_OCC_DeleteGeometry (Ng_OCC_Geometry * geom);
16235 +// Loads geometry from STEP file
16236 +DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_STEP (const char * filename);
16238 +// Loads geometry from IGES file
16239 +DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_IGES (const char * filename);
16241 +// Loads geometry from BREP file
16242 +DLL_HEADER Ng_OCC_Geometry * Ng_OCC_Load_BREP (const char * filename);
16244 +// Set the local mesh size based on geometry / topology
16245 +DLL_HEADER Ng_Result Ng_OCC_SetLocalMeshSize (Ng_OCC_Geometry * geom,
16247 + Ng_Meshing_Parameters * mp);
16249 +// Mesh the edges and add Face descriptors to prepare for surface meshing
16250 +DLL_HEADER Ng_Result Ng_OCC_GenerateEdgeMesh (Ng_OCC_Geometry * geom,
16252 + Ng_Meshing_Parameters * mp);
16254 +// Mesh the surfaces of an OCC geometry
16255 +DLL_HEADER Ng_Result Ng_OCC_GenerateSurfaceMesh (Ng_OCC_Geometry * geom,
16257 + Ng_Meshing_Parameters * mp);
16259 +// Get the face map of an already loaded OCC geometry
16260 +DLL_HEADER Ng_Result Ng_OCC_GetFMap(Ng_OCC_Geometry * geom,
16261 + Ng_OCC_TopTools_IndexedMapOfShape * FMap);
16263 +#endif // OCCGEOMETRY
16267 +// **********************************************************
16268 +// ** Mesh refinement algorithms **
16269 +// **********************************************************
16271 +// uniform mesh refinement
16272 +DLL_HEADER void Ng_Uniform_Refinement (Ng_Mesh * mesh);
16275 +// uniform mesh refinement with geometry adaption:
16277 +DLL_HEADER void Ng_2D_Uniform_Refinement (Ng_Geometry_2D * geom,
16280 +DLL_HEADER void Ng_STL_Uniform_Refinement (Ng_STL_Geometry * geom,
16283 +DLL_HEADER void Ng_CSG_Uniform_Refinement (Ng_CSG_Geometry * geom,
16286 +#ifdef OCCGEOMETRY
16287 +DLL_HEADER void Ng_OCC_Uniform_Refinement (Ng_OCC_Geometry * geom,
16293 +// **********************************************************
16294 +// ** Second Order mesh algorithms **
16295 +// **********************************************************
16297 +// convert mesh to second order
16298 +DLL_HEADER void Ng_Generate_SecondOrder (Ng_Mesh * mesh);
16301 +// convert mesh to second order with geometry adaption:
16303 +DLL_HEADER void Ng_2D_Generate_SecondOrder (Ng_Geometry_2D * geom,
16306 +DLL_HEADER void Ng_STL_Generate_SecondOrder (Ng_STL_Geometry * geom,
16309 +DLL_HEADER void Ng_CSG_Generate_SecondOrder (Ng_CSG_Geometry * geom,
16312 +#ifdef OCCGEOMETRY
16313 +DLL_HEADER void Ng_OCC_Generate_SecondOrder (Ng_OCC_Geometry * geom,