Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only CGNS driver added may worth a PR #25

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 74 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
cmake_minimum_required(VERSION 3.3)
project(SMESH C CXX)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# --------------------------------------------------------------------------- #
# OPTIONS
# --------------------------------------------------------------------------- #
option(ENABLE_NETGEN "Enable NETGEN" ON)
option(ENABLE_MED "Enable MED" OFF)
option(ENABLE_BLSURF "Enable BLSURF" OFF)
option(ENABLE_NETGEN "Enable NETGEN mesher" ON)
option(ENABLE_MED "Enable MED mesh format IO" OFF)
option(ENABLE_CGNS "Enable CGNS mesh format input and output " ON)
option(ENABLE_BLSURF "Enable BLSURF mesher" OFF)
option(ENABLE_LIB_NAMING "Enable additional library naming" OFF)

set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install" CACHE PATH "Installation directory.")
set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries")

Expand All @@ -24,10 +27,18 @@ set(SMESH_VERSION_TWEAK 3)
# Build shared libraries
set(BUILD_SHARED_LIBS ON)

# Compiler flags
# if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# endif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
# you ccache is installed, use it
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()

# Compiler flags, c++11 is essential for OCCT 7.3
# netget 6.2 also need G++6, using `export CXX=g++6` to select compiler
# is that possible to detect OpenCASCADE_VERSION by cmake?
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)

# --------------------------------------------------------------------------- #
# OpenCASCADE
Expand Down Expand Up @@ -149,6 +160,10 @@ if(ENABLE_NETGEN)
include_directories(${NETGEN_INCLUDE_DIR}/gprim)
include_directories(${NETGEN_INCLUDE_DIR}/include)
include_directories(${NETGEN_INCLUDE_DIR}/stlgeom)

#netgen 6.2 has more subfolder for headers
include_directories(${NETGEN_INCLUDE_DIR}/core)
remove_definitions("-DNETGEN_PYTHON")

# Set NETGEN_VERSION
file(STRINGS ${NETGEN_INCLUDE_DIR}/mydefs.hpp NETGEN_VERSION
Expand Down Expand Up @@ -212,16 +227,35 @@ if(ENABLE_MED)
message(FATAL_ERROR "Failed to find MED include directories.")
endif()

if(NOT EXISTS ${MEDFILE_INCLUDE_DIRS})
message(FATAL_ERROR "Failed to find MED librar directory.")
endif()

message(STATUS "MED include directory: ${MED_INCLUDE_DIR}")
message(STATUS "MED library directory: ${MED_LIBRARY_DIR}")
include_directories(${MEDFILE_INCLUDE_DIRS})
endif()


# --------------------------------------------------------------------------- #
# CGNS
# --------------------------------------------------------------------------- #
if(ENABLE_CGNS)
if(NOT DEFINED CGNS_INCLUDE_DIRS OR NOT DEFINED CGNS_LIBRARY_DIR)
message(STATUS "Searching for CGNS...")
find_package(CGNS) # REQUIRED
endif()

if(NOT EXISTS ${CGNS_INCLUDE_DIRS})
message(FATAL_ERROR "Failed to find CGNS include directories.")
endif()

if(NOT EXISTS ${CGNS_INCLUDE_DIRS})
message(FATAL_ERROR "Failed to find CGNS librar directory.")
endif()

message(STATUS "CGNS include directory: ${CGNS_INCLUDE_DIR}")
message(STATUS "CGNS library directory: ${CGNS_LIBRARY_DIR}")
include_directories(${CGNS_INCLUDE_DIRS})
endif()


# --------------------------------------------------------------------------- #
# SMESH
# --------------------------------------------------------------------------- #
Expand Down Expand Up @@ -314,6 +348,18 @@ if(ENABLE_MED)
endif()
endif()

# DriverCGNS
if(UNIX)
if(ENABLE_CGNS)
file(GLOB DriverCGNS_SRC src/DriverCGNS/*.cxx)
add_library(DriverCGNS ${DriverCGNS_SRC})
target_link_libraries(DriverCGNS SMDS Driver SMESHMisc SMESHTrace SMESHBasics ${CGNSFILE_LIBRARIES})
if(WIN32)
set_target_properties(DriverCGNS PROPERTIES COMPILE_FLAGS "-MESHDRIVERCGNS_EXPORT")
endif()
endif()
endif()

# MEFISTO2
file(GLOB MEFISTO2_SRC src/MEFISTO2/aptrte.cxx src/MEFISTO2/trte.c)
add_library(MEFISTO2 ${MEFISTO2_SRC})
Expand All @@ -334,15 +380,25 @@ endif()
if(ENABLE_NETGEN)
file(GLOB NETGENPlugin_SRC src/NETGENPlugin/*.cxx)
add_library(NETGENPlugin ${NETGENPlugin_SRC})
# the latest netget 6.2 need C++14
if (${NETGEN_VERSION} VERSION_GREATER_EQUAL 6.2)
set_target_properties(NETGENPlugin PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
endif()
if (NETGEN_LIBRARY)
target_link_libraries(NETGENPlugin StdMeshers TKIGES TKXDEIGES ${NETGEN_LIBRARY})
message(STATUS "NETGEN_LIBRARY= ${NETGEN_LIBRARY}")
else (NETGEN_LIBRARY)
target_link_libraries(NETGENPlugin StdMeshers nglib)
endif (NETGEN_LIBRARY)
if(WIN32)
set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "-DNETGENPLUGIN_EXPORTS -DNO_PARALLEL_THREADS -DOCCGEOMETRY -DNETGEN_VERSION=${NETGEN_VERSION}")
else()
set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "${NETGEN_CXX_FLAGS} -DNETGEN_VERSION=${NETGEN_VERSION}")
message(STATUS "NETGEN_CXX_FLAGS= ${NETGEN_CXX_FLAGS}")
endif()
endif()

Expand Down Expand Up @@ -380,7 +436,7 @@ else()
set_target_properties(StdMeshers PROPERTIES COMPILE_FLAGS "${StdMeshers_CFLAGS}")
endif()

# Trace
# Salome kernel's Trace
file(GLOB Trace_SRC src/Trace/*.cxx)
add_library(SMESHTrace ${Trace_SRC})
if(UNIX)
Expand All @@ -392,8 +448,8 @@ if(WIN32)
set_target_properties(SMESHTrace PROPERTIES COMPILE_FLAGS "-DSALOMELOCALTRACE_EXPORTS")
endif()

# Utils
file(GLOB Utils_SRC src/Utils/*.cxx)
# SMESHUtils
file(GLOB Utils_SRC src/SMESHUtils/*.cxx)
add_library(SMESHUtils ${Utils_SRC})
target_link_libraries(SMESHUtils SMDS TKShHealing TKPrim TKernel TKBRep TKG2d TKG3d TKGeomBase TKGeomAlgo TKTopAlgo TKMesh ${Boost_LIBRARIES})
if(WIN32)
Expand Down Expand Up @@ -426,6 +482,10 @@ if(ENABLE_MED)
set(SMESH_LIBRARIES ${SMESH_LIBRARIES} DriverMED)
endif()

if(ENABLE_CGNS)
set(SMESH_LIBRARIES ${SMESH_LIBRARIES} DriverCGNS)
endif()

if (MSVC AND ENABLE_LIB_NAMING)
foreach(it ${SMESH_LIBRARIES})
LIST(APPEND SMESH_LIBS "optimized ${it}")
Expand Down
48 changes: 48 additions & 0 deletions cmake/FindCGNS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
# Find the native CGNS includes and library
#
# CGNS_INCLUDE_DIR - where to find cgns.h, etc.
# CGNS_LIBRARIES - List of fully qualified libraries to link against when using CGNS.
# CGNS_FOUND - Do not attempt to use CGNS if "no" or undefined.

find_path(CGNS_INCLUDE_DIR
NAMES
cgnslib.h
PATHS
/usr/local/include
/usr/include
DOC "CGNS include directory")
mark_as_advanced(CGNS_INCLUDE_DIR)

find_library(CGNS_LIBRARY
NAMES
cgns
DOC "CGNS library")
mark_as_advanced(CGNS_LIBRARY)

if (CGNS_INCLUDE_DIR)
file(STRINGS "${CGNS_INCLUDE_DIR}/cgnslib.h" version
REGEX "CGNS_DOTVERS")
string(REGEX REPLACE ".*CGNS_DOTVERS *\([0-9.]*\).*" "\\1" CGNS_VERSION "${version}")
unset(version)
else ()
set(CGNS_VERSION CGNS_VERSION-NOTFOUND)
endif ()

# handle the QUIETLY and REQUIRED arguments and set CGNS_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CGNS
REQUIRED_VARS CGNS_INCLUDE_DIR CGNS_LIBRARY
VERSION_VAR CGNS_VERSION)

if (CGNS_FOUND)
set(CGNS_LIBRARIES "${CGNS_LIBRARY}")
set(CGNS_INCLUDE_DIRS "${CGNS_INCLUDE_DIR}")
if (NOT TARGET CGNS::CGNS)
add_library(CGNS::CGNS UNKNOWN IMPORTED)
set_target_properties(CGNS::CGNS PROPERTIES
IMPORTED_LOCATION "${CGNS_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${CGNS_INCLUDE_DIR}")
endif ()
endif ()
43 changes: 35 additions & 8 deletions src/SUIT/SUIT_SelectionFilter.cxx → inc/DriverCGNS_Read.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,41 @@
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : DriverCGNS_Read.hxx
// Created : Thu Jun 30 10:25:09 2011
// Author : Edward AGAPOV (eap)

#include "SUIT_SelectionFilter.h"
#ifndef __DriverCGNS_Read_HXX__
#define __DriverCGNS_Read_HXX__

/*! constructor. do nothing*/
SUIT_SelectionFilter::SUIT_SelectionFilter()
{
}
/*! destructor. do nothing*/
SUIT_SelectionFilter::~SUIT_SelectionFilter()
#include "SMESH_DriverCGNS.hxx"

#include "Driver_SMESHDS_Mesh.h"

#include <vector>
#include <string>

/*!
* \brief Driver reading a mesh from the CGNS file. The mesh to read is selected by
* an index (counted from 0) set via SetMeshId()
*/
class MESHDriverCGNS_EXPORT DriverCGNS_Read : public Driver_SMESHDS_Mesh
{
}
public:

DriverCGNS_Read();
~DriverCGNS_Read();

virtual Status Perform();

int GetNbMeshes(Status& theStatus);


private:

Status open();

int _fn; //!< file index
};

#endif
36 changes: 21 additions & 15 deletions inc/SMESH_TypeFilter.hxx → inc/DriverCGNS_Write.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,35 @@
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : DriverCGNS_Write.hxx
// Created : Thu Jun 30 10:25:09 2011
// Author : Edward AGAPOV (eap)

// File : SMESH_TypeFilter.hxx
// Module : SMESH
//
#ifndef _SMESH_TypeFilter_HeaderFile
#define _SMESH_TypeFilter_HeaderFile
#ifndef __DriverCGNS_Write_HXX__
#define __DriverCGNS_Write_HXX__

#include "SMESH_DriverCGNS.hxx"

#include "SMESH_Type.h"
#include "SUIT_SelectionFilter.h"
#include "Driver_SMESHDS_Mesh.h"

class SUIT_DataOwner;
#include <vector>
#include <string>

class SMESHFILTERSSELECTION_EXPORT SMESH_TypeFilter : public SUIT_SelectionFilter
/*!
* \brief Driver writinging a mesh into the CGNS file.
*/
class MESHDriverCGNS_EXPORT DriverCGNS_Write : public Driver_SMESHDS_Mesh
{
public:
SMESH_TypeFilter (SMESH::MeshObjectType theType);
~SMESH_TypeFilter();

virtual bool isOk (const SUIT_DataOwner*) const;
SMESH::MeshObjectType type() const;
DriverCGNS_Write();
~DriverCGNS_Write();

virtual Status Perform();

private:

protected:
SMESH::MeshObjectType myType;
int _fn; //!< file index
};

#endif
2 changes: 2 additions & 0 deletions inc/NETGENPlugin_Defs.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#ifndef _NETGENPlugin_DEFS_HXX_
#define _NETGENPlugin_DEFS_HXX_

#undef NETGEN_PYTHON

#ifdef WIN32
#if defined NETGENPLUGIN_EXPORTS || defined NETGENEngine_EXPORTS
#define NETGENPLUGIN_EXPORT __declspec( dllexport )
Expand Down
Empty file modified inc/SMESH_DriverCGNS.hxx
100644 → 100755
Empty file.
60 changes: 0 additions & 60 deletions inc/SMESH_LogicalFilter.hxx

This file was deleted.

Loading