Skip to content

Commit

Permalink
fix Makefile when PQP is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
k-okada committed Jun 8, 2020
1 parent f8cccd0 commit 0ec948f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
43 changes: 43 additions & 0 deletions irteus/CPQP.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,51 +22,93 @@
/// above copyright notice remains intact.
///

#if HAVE_PQP
#define CALL_WITH_PQP_CHECK(X) {/* X */}
#else
#define CALL_WITH_PQP_CHECK(X) fprintf(stderr, "jskeus is compiled without PQP because of non-free license, so you can not use function %s.\n", __PRETTY_FUNCTION__); X;
#endif

#if HAVE_PQP

#include "PQP/src/PQP.h"
#include "PQP/src/MatVec.h"

#else // HAVE_PQP

#define PQP_Model void
#define PQP_REAL double

#endif // HAVE_PQP

#include <stdio.h>
extern "C"{

PQP_Model *PQP_MakeModel()
{
#if ! HAVE_PQP
CALL_WITH_PQP_CHECK(return (void *)NULL);
#else
return new PQP_Model();
#endif // HAVE_PQP
}

void PQP_DeleteModel(PQP_Model *m)
{
#if ! HAVE_PQP
CALL_WITH_PQP_CHECK(return;);
#else
delete(m);
#endif // HAVE_PQP
}

int PQP_BeginModel(PQP_Model* m)
{
#if ! HAVE_PQP
CALL_WITH_PQP_CHECK(return 0;);
#else
return m->BeginModel();
#endif // HAVE_PQP
}

int PQP_EndModel(PQP_Model* m)
{
#if ! HAVE_PQP
CALL_WITH_PQP_CHECK(return 0;);
#else
return m->EndModel();
#endif // HAVE_PQP
}

int PQP_AddTri(PQP_Model *m, double p1[], double p2[], double p3[],
int flag)
{
#if ! HAVE_PQP
CALL_WITH_PQP_CHECK(return 0;);
#else
return m->AddTri(p1, p2, p3, flag);
#endif // HAVE_PQP
}

int PQP_Collide(double R1[3][3], double T1[3], PQP_Model *PQP_Model1,
double R2[3][3], double T2[3], PQP_Model *PQP_Model2,
int flag)
{
#if ! HAVE_PQP
CALL_WITH_PQP_CHECK(return 0;);
#else
PQP_CollideResult cres;
PQP_Collide(&cres, R1, T1, PQP_Model1, R2, T2, PQP_Model2, flag);
return cres.NumPairs();
#endif // HAVE_PQP
}

double PQP_Distance(double R1[3][3], double T1[3], PQP_Model *PQP_Model1,
double R2[3][3], double T2[3], PQP_Model *PQP_Model2,
PQP_REAL *P1, PQP_REAL *P2, int qsize)
{
#if ! HAVE_PQP
CALL_WITH_PQP_CHECK(return 0.0;)
#else
PQP_REAL V1[3], V2[3];
PQP_DistanceResult dres;
PQP_Distance(&dres, R1, T1, PQP_Model1, R2, T2, PQP_Model2, 0.0, 0.0, qsize);
Expand All @@ -75,6 +117,7 @@ double PQP_Distance(double R1[3][3], double T1[3], PQP_Model *PQP_Model1,
MxVpV(P1, R1, V1, T1);
MxVpV(P2, R2, V2, T2);
return (double)(dres.Distance());
#endif // HAVE_PQP
}
}

Expand Down
16 changes: 13 additions & 3 deletions irteus/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,25 @@ else
endif
$(info "-- HAVE_BULLET = ${HAVE_BULLET}")

ifneq ($(wildcard PQP/*),)
HAVE_PQP=1
else
HAVE_PQP=0
endif
$(info "-- HAVE_PQP = ${HAVE_PQP}")

# common
WFLAGS= #-Wall

BINDIR=$(EUSDIR)/$(ARCHDIR)/bin
OBJDIR=$(EUSDIR)/$(ARCHDIR)/obj
LIBDIR=$(EUSDIR)/$(ARCHDIR)/lib

PQPLIBDIR=PQP/$(ARCHDIR)
PQPLIB=-L$(PQPLIBDIR) -lPQP-static
ifeq ($(HAVE_PQP), 1)
PQPCFLAGS=-DHAVE_PQP=$(HAVE_PQP)
PQPLIBDIR=PQP/$(ARCHDIR)
PQPLIB=-L$(PQPLIBDIR) -lPQP-static
endif

ifeq ($(HAVE_BULLET), 1)
BULLETCFLAGS=`pkg-config bullet --cflags` -DHAVE_BULLET=$(HAVE_BULLET)
Expand Down Expand Up @@ -243,7 +253,7 @@ $(INSTALLOBJDIR)/irtglc.$(OSFX): irtglc.c $(filter-out $(INSTALLOBJDIR)/irtglc.$
$(INSTALLOBJDIR)/irtgeoc.$(OSFX): irtgeoc.c $(filter-out $(INSTALLOBJDIR)/irtgeoc.$(OSFX), $(IRTEUSOBJS) $(IRTEUSGOBJS) $(IRTGCOBJECTS) PQP/$(ARCHDIR)/libPQP-static.a $(IRTEUSXOBJS) $(INSTALLLIBDIR)/jpegmemcd.$(LSFX) $(IRTEUSIMGOBJS) $(IRTIMGCOBJECTS) $(IRTEUSGLOBJS) $(IRTGLCOBJECTS)) defun.h
$(CC) $(CFLAGS) $(WFLAGS) -c irtgeoc.c $(OBJOPT)$(INSTALLOBJDIR)/irtgeoc.$(OSFX)
$(INSTALLOBJDIR)/CPQP.$(OSFX): CPQP.C defun.h
$(CXX) $(CXXFLAGS) -c CPQP.C $(OBJOPT)$(INSTALLOBJDIR)/CPQP.$(OSFX)
$(CXX) $(CXXFLAGS) $(PQPCFLAGS) -c CPQP.C $(OBJOPT)$(INSTALLOBJDIR)/CPQP.$(OSFX)
$(INSTALLOBJDIR)/euspqp.$(OSFX): euspqp.c defun.h
$(CC) $(CFLAGS) $(WFLAGS) -c euspqp.c $(OBJOPT)$(INSTALLOBJDIR)/euspqp.$(OSFX)
$(INSTALLOBJDIR)/CBULLET.$(OSFX): CBULLET.cpp defun.h
Expand Down

0 comments on commit 0ec948f

Please sign in to comment.