-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
243 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
cmake_minimum_required(VERSION 2.8.6) | ||
|
||
if(BUILD_IN_TRILINOS) | ||
include(TribitsSubPackageMacros) | ||
include(TribitsLibraryMacros) | ||
tribits_subpackage(gmi_sim) | ||
else() | ||
project(gmi_sim) | ||
endif() | ||
|
||
if(NOT BUILD_IN_TRILINOS) | ||
find_package(gmi PATHS ${CMAKE_BINARY_DIR}) | ||
find_package(SimModSuite REQUIRED) | ||
|
||
set(GMI_SIM_INCLUDE_DIRS | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
${GMI_INCLUDE_DIRS} | ||
${SIMMODSUITE_INCLUDE_DIR}) | ||
include_directories(${GMI_SIM_INCLUDE_DIRS}) | ||
set(DEP_LIBS ${GMI_LIBS} ${SIMMODSUITE_LIBS}) | ||
set(GMI_SIM_LIBS gmi_sim ${DEP_LIBS}) | ||
else() | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) | ||
endif() | ||
|
||
#Sources & Headers | ||
set(SOURCES gmi_sim.cc) | ||
set(HEADERS gmi_sim.h) | ||
|
||
#Library | ||
if(BUILD_IN_TRILINOS) | ||
tribits_add_library( | ||
gmi_sim | ||
HEADERS ${HEADERS} | ||
SOURCES ${SOURCES}) | ||
else() | ||
add_library(gmi_sim ${SOURCES}) | ||
target_link_libraries(gmi_sim ${DEP_LIBS}) | ||
endif() | ||
|
||
if(NOT BUILD_IN_TRILINOS) | ||
INSTALL(FILES ${HEADERS} DESTINATION include) | ||
INSTALL(FILES "${PROJECT_BINARY_DIR}/libgmi_sim.pc" DESTINATION lib/pkgconfig) | ||
INSTALL(TARGETS | ||
gmi_sim | ||
RUNTIME DESTINATION bin | ||
LIBRARY DESTINATION lib | ||
ARCHIVE DESTINATION lib | ||
) | ||
endif() | ||
|
||
configure_file( | ||
"${CMAKE_CURRENT_SOURCE_DIR}/gmi_simConfig.cmake.in" | ||
"${CMAKE_BINARY_DIR}/gmi_simConfig.cmake") | ||
|
||
#pkgconfig { | ||
set(prefix "${CMAKE_INSTALL_PREFIX}") | ||
set(exec_prefix "${CMAKE_INSTALL_PREFIX}/bin") | ||
set(libdir "${CMAKE_INSTALL_PREFIX}/lib") | ||
set(includedir "${CMAKE_INSTALL_PREFIX}/include") | ||
set(PACKAGE_VERSION "1.0") | ||
configure_file( | ||
"${CMAKE_CURRENT_SOURCE_DIR}/libgmi_sim.pc.in" | ||
"${PROJECT_BINARY_DIR}/libgmi_sim.pc" | ||
@ONLY) | ||
#pkgconfig } | ||
|
||
if(BUILD_IN_TRILINOS) | ||
tribits_subpackage_postprocess() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
/****************************************************************************** | ||
Copyright 2014 Scientific Computation Research Center, | ||
Rensselaer Polytechnic Institute. All rights reserved. | ||
This work is open source software, licensed under the terms of the | ||
BSD license as described in the LICENSE file in the top-level directory. | ||
*******************************************************************************/ | ||
#include "gmi_sim.h" | ||
#include <gmi.h> | ||
#include <stdlib.h> | ||
#include <gmi.h> | ||
#include <SimModel.h> | ||
|
||
struct sim_model { | ||
struct gmi_model model; | ||
SGModel* sim; | ||
}; | ||
|
||
struct sim_iter { | ||
union { | ||
GVIter v; | ||
GEIter e; | ||
GFIter f; | ||
GRIter r; | ||
} i; | ||
int dim; | ||
}; | ||
|
||
extern "C" { | ||
|
||
static gmi_iter* begin(gmi_model* m, int dim) | ||
{ | ||
sim_model* mm; | ||
sim_iter* i; | ||
mm = (sim_model*)m; | ||
i = (sim_iter*)malloc(sizeof(*i)); | ||
i->dim = dim; | ||
if (dim == 0) | ||
i->i.v = GM_vertexIter(mm->sim); | ||
else if (dim == 1) | ||
i->i.e = GM_edgeIter(mm->sim); | ||
else if (dim == 2) | ||
i->i.f = GM_faceIter(mm->sim); | ||
else if (dim == 3) | ||
i->i.r = GM_regionIter(mm->sim); | ||
return (gmi_iter*)i; | ||
} | ||
|
||
static gmi_ent* next(gmi_model* m, gmi_iter* i) | ||
{ | ||
sim_iter* si; | ||
si = (sim_iter*)i; | ||
if (si->dim == 0) | ||
return (gmi_ent*)GVIter_next(si->i.v); | ||
if (si->dim == 1) | ||
return (gmi_ent*)GEIter_next(si->i.e); | ||
if (si->dim == 2) | ||
return (gmi_ent*)GFIter_next(si->i.f); | ||
if (si->dim == 3) | ||
return (gmi_ent*)GRIter_next(si->i.r); | ||
return 0; | ||
} | ||
|
||
static void end(gmi_model* m, gmi_iter* i) | ||
{ | ||
sim_iter* si; | ||
si = (sim_iter*)i; | ||
if (si->dim == 0) | ||
return GVIter_delete(si->i.v); | ||
if (si->dim == 1) | ||
return GEIter_delete(si->i.e); | ||
if (si->dim == 2) | ||
return GFIter_delete(si->i.f); | ||
if (si->dim == 3) | ||
return GRIter_delete(si->i.r); | ||
free(si); | ||
} | ||
|
||
static int get_dim(gmi_model* m, gmi_ent* e) | ||
{ | ||
return GEN_type((pGEntity)e); | ||
} | ||
|
||
static int get_tag(gmi_model* m, gmi_ent* e) | ||
{ | ||
return GEN_tag((pGEntity)e); | ||
} | ||
|
||
static gmi_ent* find(gmi_model* m, int dim, int tag) | ||
{ | ||
sim_model* mm = (sim_model*)m; | ||
return (gmi_ent*)GM_entityByTag(mm->sim, dim, tag); | ||
} | ||
|
||
static void destroy(gmi_model* m) | ||
{ | ||
sim_model* mm = (sim_model*)m; | ||
GM_release(mm->sim); | ||
free(mm); | ||
} | ||
|
||
static struct gmi_model_ops ops; | ||
|
||
static gmi_model* create(const char* filename) | ||
{ | ||
return gmi_import_sim(GM_load(filename, NULL, NULL)); | ||
} | ||
|
||
void gmi_register_sim(void) | ||
{ | ||
ops.begin = begin; | ||
ops.next = next; | ||
ops.end = end; | ||
ops.dim = get_dim; | ||
ops.tag = get_tag; | ||
ops.find = find; | ||
ops.destroy = destroy; | ||
gmi_register(create, "smd"); | ||
} | ||
|
||
gmi_model* gmi_import_sim(SGModel* sm) | ||
{ | ||
sim_model* m; | ||
m = (sim_model*)malloc(sizeof(*m)); | ||
m->model.ops = &ops; | ||
m->sim = sm; | ||
m->model.n[0] = GM_numVertices(sm); | ||
m->model.n[1] = GM_numEdges(sm); | ||
m->model.n[2] = GM_numFaces(sm); | ||
m->model.n[3] = GM_numRegions(sm); | ||
return &m->model; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/****************************************************************************** | ||
Copyright 2014 Scientific Computation Research Center, | ||
Rensselaer Polytechnic Institute. All rights reserved. | ||
This work is open source software, licensed under the terms of the | ||
BSD license as described in the LICENSE file in the top-level directory. | ||
*******************************************************************************/ | ||
#ifndef GMI_SIM_H | ||
#define GMI_SIM_H | ||
|
||
class SGModel; | ||
|
||
extern "C" void gmi_register_sim(void); | ||
extern "C" struct gmi_model* gmi_import_sim(SGModel* sim_model); | ||
|
||
#endif | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SET(GMI_SIM_LIBS @GMI_SIM_LIBS@) | ||
SET(GMI_SIM_INCLUDE_DIRS @GMI_SIM_INCLUDE_DIRS@) | ||
SET(GMI_SIM_FOUND TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
prefix=@prefix@ | ||
exec_prefix=@exec_prefix@ | ||
libdir=@libdir@ | ||
includedir=@includedir@ | ||
|
||
Name: GMI-SIM | ||
URL: http://www.scorec.rpi.edu/~dibanez/ | ||
Description: Geometric Model Interface for Simmetrix | ||
Version: @PACKAGE_VERSION@ | ||
Requires: libgmi libSimModSuite | ||
Libs: -L${libdir} -lgmi_sim | ||
Cflags: -I${includedir} |