Fix exit condition, remove Werror flag
parent
d67a1b7db6
commit
646c1d3edc
|
@ -42,23 +42,23 @@ ENDIF()
|
|||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
# using GCC
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -finline-functions")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -finline-functions")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Werror")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -finline-functions")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra -finline-functions")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3 -Werror")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||
|
||||
add_compile_options(-static-libgcc -static-libstdc++ )
|
||||
add_definitions(-DMT)
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
# using Visual Studio C++
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall /WX /wd4131 /wd4701 /wd4255 /wd4710 /wd4820 /wd4711")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4131 /wd4701 /wd4255 /wd4710 /wd4820 /wd4711 /wd5045")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "/Ox")
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall /WX /wd4131 /wd4701 /wd4255 /wd4710 /wd4820 /wd4711")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4131 /wd4701 /wd4255 /wd4710 /wd4820 /wd4711 /wd5045")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1")
|
||||
set(CMAKE_C_FLAGS_RELEASE "/Ox")
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define _CRT_HAS_CXX17 0
|
||||
#include <stdio.h>
|
||||
|
||||
/* For importing openGJK this is Step 1: include header in subfolder. */
|
||||
|
@ -58,7 +59,7 @@ int readinput ( const char *inputfile, double ***pts, int * out ) {
|
|||
}
|
||||
|
||||
/* Read number of input vertices. */
|
||||
if (fscanf_s(fp, "%1d", &npoints) != 1)
|
||||
if (fscanf_s(fp, "%d", &npoints) != 1)
|
||||
return 1;
|
||||
|
||||
/* Allocate memory. */
|
||||
|
|
|
@ -16,8 +16,7 @@ project (openGJKlib)
|
|||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
# SELECT USER OPTIONS
|
||||
option(VERSION_ACCURATE "Reduce speed to maximise accuracy (OFF)"
|
||||
OFF )
|
||||
option(VERSION_ACCURATE "Reduce speed to maximise accuracy (OFF)" OFF )
|
||||
|
||||
# APPLY USER OPTIONS
|
||||
IF(VERSION_ACCURATE)
|
||||
|
@ -46,8 +45,8 @@ IF(USE_PREDICATES)
|
|||
ENDIF()
|
||||
|
||||
# Create the (dynamic) library
|
||||
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${SOURCE_HEADS})
|
||||
add_definitions(-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE)
|
||||
add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES} ${SOURCE_HEADS})
|
||||
add_definitions(-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=FALSE)
|
||||
|
||||
# Link include file
|
||||
target_include_directories( ${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define _CRT_HAS_CXX17 0
|
||||
#include <stdio.h>
|
||||
|
||||
#include "openGJK/openGJK.h"
|
||||
|
@ -777,18 +778,19 @@ void subalgorithm ( struct simplex *s ) {
|
|||
double gjk ( struct bd bd1, struct bd bd2, struct simplex *s) {
|
||||
|
||||
int k = 0; /**< Iteration counter */
|
||||
int i; /**< General purpose index */
|
||||
int mk = 1000; /**< Maximum number of iterations */
|
||||
int i; /**< General purpose counter */
|
||||
int mk = 100; /**< Maximum number of iterations of the GJK algorithm */
|
||||
double v[3]; /**< Search direction */
|
||||
double vminus[3]; /**< Search direction */
|
||||
double w[3]; /**< Vertex on CSO frontier */
|
||||
double eps_rel = 1e-10; /**< Tolerance on relative */
|
||||
double eps_tot = 1e-14; /**< Tolerance on total */
|
||||
double eps_tot = 1e-13;
|
||||
double dd = -1; /**< Squared distance */
|
||||
int maxitreached = 0; /**< Flag for maximum iterations */
|
||||
int origininsimplex = 0; /**< Flag for origin in simples */
|
||||
int exeedtol_rel = 0; /**< Flag for 1st exit condition */
|
||||
int exeedtol_tot = 0; /**< Flag for 2nd exit condition */
|
||||
int nullV = 0; /**< Flag for 3rd exit condition */
|
||||
|
||||
#ifdef ADAPTIVEFP
|
||||
exactinit();
|
||||
|
@ -800,34 +802,11 @@ double gjk ( struct bd bd1, struct bd bd2, struct simplex *s) {
|
|||
vminus[i] = -v[i];
|
||||
}
|
||||
|
||||
|
||||
#if DEBUG
|
||||
mexPrintf ("Num points A = %i \n",bd1.numpoints );
|
||||
mexPrintf ("Num points B = %i \n",bd2.numpoints );
|
||||
for ( i = 0; i < bd1.numpoints; ++i) {
|
||||
for (int j = 0; j < 3; j++){
|
||||
mexPrintf ("%.4f ", bd1.coord[ i][j ]);
|
||||
}
|
||||
mexPrintf ("\n");
|
||||
}
|
||||
|
||||
for ( i = 0; i < bd2.numpoints; ++i) {
|
||||
for (int j = 0; j < 3; j++){
|
||||
mexPrintf ("%.4f ", bd2.coord[ i][j ]);
|
||||
}
|
||||
mexPrintf ("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Begin GJK iteration */
|
||||
do {
|
||||
/* Increment iteration counter */
|
||||
k++;
|
||||
|
||||
#ifdef DEBUG
|
||||
mexPrintf ("iteration number = %i \n",k );
|
||||
#endif
|
||||
/* Evaluate support function*/
|
||||
/* Support function on polytope A */
|
||||
support( &bd1 , vminus );
|
||||
/* Support function on polytope B */
|
||||
|
@ -840,7 +819,11 @@ double gjk ( struct bd bd1, struct bd bd2, struct simplex *s) {
|
|||
/* Test first exit condition (can't move further) */
|
||||
exeedtol_rel = (norm2(v) - dotprod (v,w) ) <= eps_rel * norm2(v);
|
||||
if ( exeedtol_rel ){
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
nullV = norm2(v) < eps_rel;
|
||||
if (nullV) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Add support vertex to simplex at the position nvrtx+1 */
|
||||
|
@ -851,9 +834,6 @@ double gjk ( struct bd bd1, struct bd bd2, struct simplex *s) {
|
|||
/* Invoke sub-distance algorithm */
|
||||
subalgorithm ( s );
|
||||
|
||||
#ifdef DEBUG
|
||||
mexPrintf ("Elm in simplex = %i \n",s->nvrtx );
|
||||
#endif
|
||||
/* Termination tests */
|
||||
maxitreached = k == mk;
|
||||
origininsimplex = s->nvrtx == 4;
|
||||
|
@ -1008,26 +988,7 @@ void mexFunction( int nlhs, mxArray *plhs[],
|
|||
double csFunction( int nCoordsA, double *inCoordsA, int nCoordsB, double *inCoordsB )
|
||||
{
|
||||
double distance = 0;
|
||||
int i, j;
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Coordinates of A\n");
|
||||
for (i = 0; i < nCoordsA; i++){
|
||||
for (j = 0; j < 3; j++){
|
||||
printf("%.4f ", inCoordsA[i+j*nCoordsA] );
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
printf("Coordinates of B\n");
|
||||
for (i = 0; i < nCoordsB; i++){
|
||||
for (j = 0; j < 3; j++){
|
||||
printf("%.4f ", inCoordsB[i+j*nCoordsB] );
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
int i, j;
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
/* POPULATE BODIES' STRUCTURES */
|
||||
|
|
Loading…
Reference in New Issue