Commit f5592877 authored by Michael Turner's avatar Michael Turner

Merge branch 'fix/macos-projectcad' into 'master'

fix/macos-projectcad

See merge request !876
parents 8e433420 73cb7b09
......@@ -30,6 +30,8 @@ v5.0.0
- Adds CFI CAD engine back-end (!864)
- Adds CFI Mesh IO support (!864)
- Cleanup of CAD system data structures (!864)
- Fix mac OSX on buildbots (!876)
- Fix error from (!826) (!876)
**NekMesh**:
- Add feature to read basic 2D geo files as CAD (!731)
......
# Try to find OCE / OCC
# Once done this will define
#
# OCC_FOUND - system has OCC - OpenCASCADE
# OCC_INCLUDE_DIR - where the OCC include directory can be found
# OCC_LIBRARY_DIR - where the OCC library directory can be found
# OCC_LIBRARIES - Link this to use OCC
# OCC_OCAF_LIBRARIES - Link this to use OCC OCAF framework
#
# Adapted from FreeCAD: http://free-cad.sf.net
SET(TEST_ENV $ENV{OCE_ROOT})
IF(NOT DEFINED OCE_DIR AND DEFINED TEST_ENV)
FILE(GLOB OCE_DIR $ENV{OCE_ROOT}/lib/oce-*)
ENDIF()
set(TEST_ENV $ENV{OCE_ROOT})
if(NOT DEFINED OCE_DIR AND DEFINED TEST_ENV)
file(GLOB OCE_DIR $ENV{OCE_ROOT}/lib/oce-*)
endif()
SET(TEST_ENV $ENV{OCE_DIR})
IF(NOT DEFINED OCE_DIR AND DEFINED TEST_ENV)
SET(OCE_DIR $ENV{OCE_DIR})
ENDIF()
set(TEST_ENV $ENV{OCE_DIR})
if(NOT DEFINED OCE_DIR AND DEFINED TEST_ENV)
set(OCE_DIR $ENV{OCE_DIR})
endif()
SET(OCE_FIND_COMPONENTS ${OCC_LIB_LIST})
# First try to find OpenCASCADE Community Edition
if(NOT DEFINED OCE_DIR)
# Check for OSX needs to come first because UNIX evaluates to true on OSX
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(DEFINED MACPORTS_PREFIX)
find_package(OCE 0.17 QUIET HINTS ${MACPORTS_PREFIX}/Library/Frameworks)
elseif(DEFINED HOMEBREW_PREFIX)
find_package(OCE 0.17 QUIET HINTS ${HOMEBREW_PREFIX}/Cellar/oce/*)
endif()
elseif(UNIX)
set(OCE_DIR "/usr/local/share/cmake/")
endif()
endif()
find_package(OCE 0.17 QUIET)
if(OCE_FOUND)
message(STATUS "OpenCASCADE Community Edition has been found.")
#check that the OCE package has CAF modules
FIND_LIBRARY(OCC_CAF_LIBRARY TKXCAF ${OCE_INCLUDE_DIRS}/../../lib )
#First try to find OpenCASCADE Community Edition
IF(NOT DEFINED OCE_DIR)
#Check for OSX needs to come first because UNIX evaluates to true on OSX
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
IF(DEFINED MACPORTS_PREFIX)
FIND_PACKAGE(OCE 0.17 QUIET HINTS ${MACPORTS_PREFIX}/Library/Frameworks)
ELSEIF(DEFINED HOMEBREW_PREFIX)
FIND_PACKAGE(OCE 0.17 QUIET HINTS ${HOMEBREW_PREFIX}/Cellar/oce/*)
ENDIF()
ENDIF()
ENDIF()
if(OCC_CAF_LIBRARY)
set(OCC_INCLUDE_DIR ${OCE_INCLUDE_DIRS})
else()
message(STATUS "-- OCE does not have CAF libraries, will build from source.")
endif()
FIND_PACKAGE(OCE 0.17 QUIET)
else(OCE_FOUND) #look for OpenCASCADE
SET(OCC_FOUND FALSE)
FIND_PATH(OCC_INCLUDE_DIR Standard_Version.hxx
/usr/include/opencascade
/usr/local/include/opencascade
/usr/local/opt/opencascade/include
/opt/opencascade/include
/opt/opencascade/inc
)
FIND_LIBRARY(OCC_LIBRARY TKernel
/usr/lib
/usr/local/lib
/usr/local/opt/opencascade/lib
/opt/opencascade/lib
opt/local/lib
)
IF(OCE_FOUND AND OCE_ALL_FOUND)
MESSAGE(STATUS "OpenCASCADE Community Edition has been found with all required components.")
SET(OCC_INCLUDE_DIR ${OCE_INCLUDE_DIRS})
SET(OCC_FOUND TRUE)
ELSE(OCE_FOUND AND OCE_ALL_FOUND) #look for OpenCASCADE
MESSAGE(STATUS "OpenCASCADE Community Edition could not be found or has missing components.")
SET(OpenCASCADE_FIND_COMPONENTS ${OCE_FIND_COMPONENTS})
FIND_PACKAGE(OpenCASCADE 6.8 QUIET HINTS /opt/local)
if(OCC_LIBRARY)
message(STATUS "OpenCASCADE has been found.")
GET_FILENAME_COMPONENT(OCC_LIBRARY_DIR ${OCC_LIBRARY} PATH)
IF(NOT OCC_INCLUDE_DIR)
FIND_PATH(OCC_INCLUDE_DIR Standard_Version.hxx
${OCC_LIBRARY_DIR}/../inc
)
IF(OpenCASCADE_FOUND)
MESSAGE(STATUS "OpenCASCADE has been found with all required components.")
SET(OCC_INCLUDE_DIR ${OpenCASCADE_INCLUDE_DIR})
SET(OCC_FOUND TRUE)
ELSE()
MESSAGE(STATUS "OpenCASCADE could not be found or has missing components.")
ENDIF()
endif(OCC_LIBRARY)
endif(OCE_FOUND)
if(OCC_INCLUDE_DIR)
file(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAJOR
REGEX "#define OCC_VERSION_MAJOR.*"
)
string(REGEX MATCH "[0-9]+" OCC_MAJOR ${OCC_MAJOR})
file(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MINOR
REGEX "#define OCC_VERSION_MINOR.*"
)
string(REGEX MATCH "[0-9]+" OCC_MINOR ${OCC_MINOR})
file(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAINT
REGEX "#define OCC_VERSION_MAINTENANCE.*"
)
string(REGEX MATCH "[0-9]+" OCC_MAINT ${OCC_MAINT})
ENDIF(OCE_FOUND AND OCE_ALL_FOUND)
set(OCC_VERSION_STRING "${OCC_MAJOR}.${OCC_MINOR}.${OCC_MAINT}")
endif(OCC_INCLUDE_DIR)
IF(OCC_FOUND)
FILE(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAJOR
REGEX "#define OCC_VERSION_MAJOR.*")
STRING(REGEX MATCH "[0-9]+" OCC_MAJOR ${OCC_MAJOR})
FILE(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MINOR
REGEX "#define OCC_VERSION_MINOR.*")
STRING(REGEX MATCH "[0-9]+" OCC_MINOR ${OCC_MINOR})
FILE(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAINT
REGEX "#define OCC_VERSION_MAINTENANCE.*")
STRING(REGEX MATCH "[0-9]+" OCC_MAINT ${OCC_MAINT})
# handle the QUIETLY and REQUIRED arguments and set OCC_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OCC REQUIRED_VARS OCC_INCLUDE_DIR VERSION_VAR OCC_VERSION_STRING)
SET(OCC_VERSION_STRING "${OCC_MAJOR}.${OCC_MINOR}.${OCC_MAINT}")
if(OCC_FOUND)
set(OCC_LIBRARIES
TKFillet
TKMesh
TKernel
TKG2d
TKG3d
TKMath
TKIGES
TKSTL
TKShHealing
TKXSBase
TKBool
TKBO
TKBRep
TKTopAlgo
TKGeomAlgo
TKGeomBase
TKOffset
TKPrim
TKSTEP
TKSTEPBase
TKSTEPAttr
TKHLR
TKFeat
TKXCAF
TKXDESTEP
)
if(OCC_VERSION_STRING VERSION_LESS 6.8)
MESSAGE(SEND_ERROR "OCC version too low")
endif(OCC_VERSION_STRING VERSION_LESS 6.8)
message(STATUS "-- Found OCE/OpenCASCADE with OCC version: ${OCC_VERSION_STRING}")
endif(OCC_FOUND)
IF(OCC_VERSION_STRING VERSION_LESS 6.8)
MESSAGE(STATUS "OCC version too low, will build from source")
SET(OCC_FOUND FALSE)
ELSE()
MESSAGE(STATUS "-- Found OCE/OpenCASCADE with OCC version: ${OCC_VERSION_STRING}")
SET(OCC_LIBRARIES ${OCE_FIND_COMPONENTS})
ENDIF()
ENDIF(OCC_FOUND)
......@@ -7,6 +7,36 @@
########################################################################
IF(NEKTAR_USE_MESHGEN)
#required opencascade libraries
SET(OCC_LIB_LIST
TKFillet
TKMesh
TKernel
TKG2d
TKG3d
TKMath
TKIGES
TKSTL
TKShHealing
TKXSBase
TKBool
TKBO
TKBRep
TKTopAlgo
TKGeomAlgo
TKGeomBase
TKOffset
TKPrim
TKSTEP
TKSTEPBase
TKSTEPAttr
TKHLR
TKFeat
TKXCAF
TKLCAF
TKXDESTEP
)
# Try to find installed version of OpenCascade
INCLUDE(FindOCC)
......@@ -22,39 +52,6 @@ IF(NEKTAR_USE_MESHGEN)
IF (THIRDPARTY_BUILD_OCE)
INCLUDE(ExternalProject)
SET(OCC_LIBRARIES_TMP
TKFillet
TKMesh
TKernel
TKG2d
TKG3d
TKMath
TKIGES
TKSTL
TKShHealing
TKXSBase
TKBool
TKBO
TKBRep
TKTopAlgo
TKGeomAlgo
TKGeomBase
TKOffset
TKPrim
TKSTEP
TKSTEPBase
TKSTEPAttr
TKHLR
TKFeat
TKXCAF
TKXDESTEP
)
FOREACH(OCC_LIB ${OCC_LIBRARIES_TMP})
LIST(APPEND OCC_LIBRARIES ${TPDIST}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}${OCC_LIB}${CMAKE_SHARED_LIBRARY_SUFFIX})
ENDFOREACH()
UNSET(OCC_LIBRARIES_TMP)
IF(WIN32)
MESSAGE(SEND_ERROR "Cannot currently use OpenCascade with Nektar++ on Windows")
ENDIF()
......@@ -86,12 +83,12 @@ IF(NEKTAR_USE_MESHGEN)
DEPENDEES install)
ENDIF()
THIRDPARTY_LIBRARY(OCC_LIBRARIES SHARED ${OCC_LIB_LIST} DESCRIPTION "OpenCascade libs")
SET(OCC_INCLUDE_DIR ${TPDIST}/include/oce CACHE FILEPATH "OCC include" FORCE)
MESSAGE(STATUS "Build OpenCascade community edition: ${TPDIST}/lib")
LINK_DIRECTORIES(${TPDIST}/lib)
INCLUDE_DIRECTORIES(${TPDIST}/include/oce)
ELSE()
ADD_CUSTOM_TARGET(oce-0.17 ALL)
SET(OPENCASCADE_CONFIG_INCLUDE_DIR ${OCC_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${OCC_INCLUDE_DIR})
ENDIF()
ENDIF()
INCLUDE_DIRECTORIES(${OCC_INCLUDE_DIR})
......@@ -84,12 +84,7 @@ bool CADSurfOCE::IsPlanar()
Array<OneD, NekDouble> CADSurfOCE::BoundingBox()
{
BRepMesh_IncrementalMesh brmsh;
brmsh.SetShape(m_shape);
brmsh.SetDeflection(0.005);
brmsh.Perform();
BRepMesh_IncrementalMesh brmsh(m_shape, 0.005);
Bnd_Box B;
BRepBndLib::Add(m_shape, B);
......
......@@ -16,7 +16,7 @@
<metric type="Linf" id="2">
<value variable="rho" tolerance="1e-6">0.530796</value>
<value variable="rhou" tolerance="1e-6">92.5827</value>
<value variable="rhov" tolerance="2e-4">58.1851</value>
<value variable="rhov" tolerance="4e-4">58.1851</value>
<value variable="E" tolerance="1e-6">346912</value>
</metric>
</metrics>
......
......@@ -89,10 +89,11 @@ bool ProcessProjectCAD::findAndProject(bgi::rtree<boxI, bgi::quadratic<16> > &rt
int minsurf = 0;
NekDouble minDist = numeric_limits<double>::max();
NekDouble dist;
for (int j = 0; j < result.size(); j++)
{
NekDouble dist = m_mesh->m_cad->GetSurf(result[j].second)->DistanceTo(in);
m_mesh->m_cad->GetSurf(result[j].second)->locuv(in, dist);
if (dist < minDist)
{
......@@ -101,8 +102,7 @@ bool ProcessProjectCAD::findAndProject(bgi::rtree<boxI, bgi::quadratic<16> > &rt
}
}
Array<OneD, NekDouble> uv(2);
m_mesh->m_cad->GetSurf(minsurf)->ProjectTo(in, uv);
Array<OneD, NekDouble> uv = m_mesh->m_cad->GetSurf(minsurf)->locuv(in, dist);
return true;
}
......@@ -335,9 +335,8 @@ void ProcessProjectCAD::Process()
for (int j = 0; j < result.size(); j++)
{
NekDouble dist = m_mesh->m_cad->
GetSurf(result[j].second)->
DistanceTo((*i)->GetLoc());
NekDouble dist;
m_mesh->m_cad->GetSurf(result[j].second)->locuv((*i)->GetLoc(), dist);
distList.push_back(dist);
distId.push_back(result[j].second);
}
......@@ -392,9 +391,10 @@ void ProcessProjectCAD::Process()
shift = distList[j];
Array<OneD, NekDouble> uvt(2);
NekDouble dist = 0;
CADSurfSharedPtr s = m_mesh->m_cad->GetSurf(distId[j]);
Array<OneD, NekDouble> l = (*i)->GetLoc();
s->ProjectTo(l, uvt);
uvt = s->locuv(l, dist);
NekDouble tmpX = (*i)->m_x;
NekDouble tmpY = (*i)->m_y;
......@@ -435,10 +435,11 @@ void ProcessProjectCAD::Process()
}
CADSurfSharedPtr s = m_mesh->m_cad->GetSurf(distId[j]);
Array<OneD, NekDouble> uv(2);
Array<OneD, NekDouble> uv;
NekDouble dist=0;
Array<OneD, NekDouble> loc = (*i)->GetLoc();
s->ProjectTo(loc, uv);
(*i)->SetCADSurf(distId[j], s, uv);
uv = s->locuv(loc, dist);
(*i)->SetCADSurf(s, uv);
}
maxNodeCor = max(maxNodeCor, shift);
}
......@@ -494,17 +495,17 @@ void ProcessProjectCAD::Process()
{
continue;
}
vector<pair<int, CADSurfSharedPtr> > v1 = (*i)->m_n1->GetCADSurfs();
vector<pair<int, CADSurfSharedPtr> > v2 = (*i)->m_n2->GetCADSurfs();
vector<CADSurfSharedPtr> v1 = (*i)->m_n1->GetCADSurfs();
vector<CADSurfSharedPtr> v2 = (*i)->m_n2->GetCADSurfs();
vector<int> vi1, vi2;
for (int i = 0; i < v1.size();i++)
{
vi1.push_back(v1[i].first);
vi1.push_back(v1[i]->GetId());
}
for (int i = 0; i < v2.size();i++)
{
vi2.push_back(v2[i].first);
vi2.push_back(v2[i]->GetId());
}
sort(vi1.begin(), vi1.end());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment