929 lines
37 KiB
929 lines
37 KiB
/*==========================================================
|
|
parasolid_test.c
|
|
|
|
Copyright 2017 Siemens Product Lifecycle Management Software Inc.
|
|
All rights reserved.
|
|
This software and related documentation are proprietary to
|
|
Siemens Product Lifecycle Management Software Inc.
|
|
|
|
Siemens Product Lifecycle Management Software assumes no
|
|
responsibility for the use or reliability of this software.
|
|
It is sample code, provided to give application writers an
|
|
example of basic calls to Parasolid.
|
|
|
|
============================================================
|
|
The frustrum ifails and tokens *.h files are not included
|
|
here (they already appear in the frustrum.c file, which is
|
|
being linked with this file).
|
|
The script "parasolid_link.com" shows how parasolid_test.c
|
|
is compiled and linked.
|
|
============================================================
|
|
==========================================================*/
|
|
/*
|
|
MS Windows: cl /I%PARASOLID%
|
|
Unix and Unix-like: cc -I$PARASOLID
|
|
*/
|
|
|
|
extern "C" {
|
|
#include "frustrum.h"
|
|
#include "kernel_interface.h"
|
|
#include "parasolid_kernel.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
}
|
|
|
|
#include <chrono>
|
|
#include <cmath>
|
|
#include <iostream>
|
|
#include "case_reader.h"
|
|
#include "config.hpp"
|
|
#include"boost/format.hpp"
|
|
|
|
//#include <sys/time.h>
|
|
//double get_time() {
|
|
// struct timeval tv;
|
|
// double t;
|
|
//
|
|
// gettimeofday(&tv, (struct timezone *)NULL);
|
|
// t = tv.tv_sec + (double)tv.tv_usec * 1e-6;
|
|
//
|
|
// return t;
|
|
//}
|
|
|
|
void evaluation_test();
|
|
|
|
void errHandle() {
|
|
bool wasError;
|
|
PK_ERROR_sf_t errorSf;
|
|
auto askLastErrErrCode = PK_ERROR_ask_last(reinterpret_cast<PK_LOGICAL_t *const>(&wasError), &errorSf);
|
|
// 输出code_token
|
|
cout << "\nerrorSf.code_token: " << errorSf.code_token << endl;
|
|
}
|
|
|
|
int report_ifail(int ifail, int expect) {
|
|
if (ifail != expect) {
|
|
printf("Non-zero ifail %d. Expected %d\n", ifail, expect);
|
|
return 1;
|
|
} else {
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void wrong_result(int nwrong) {
|
|
printf("*********Unexpected number %d *********\n", nwrong);
|
|
}
|
|
|
|
void parasolid_test() {
|
|
double vec1[3], vec2[3];
|
|
double cyl_rad = 2.0;
|
|
double cyl_ht = 12.0;
|
|
double distance = 99.0;
|
|
double width = 6.0;
|
|
double height = 8.0;
|
|
double depth = 10.0;
|
|
int ifail, nfaces, nbod, vrsion, nchars;
|
|
int pos, nitems;
|
|
int tworld, tass1, tget, tass2, ttran, tbox1, tbox2;
|
|
int tcyl, tfl1, tfl2, tbyli, tbody[1];
|
|
int usrfld = 0;
|
|
int pcode = 5;
|
|
int pival = 2000000;
|
|
double prval = 0.0;
|
|
int fault_tokens;
|
|
int fault_tags;
|
|
int chcken_mxflts = 0;
|
|
int chcken_nopts = 0;
|
|
int chcken_option[1];
|
|
int pdata;
|
|
int nfault;
|
|
int fg_key_len = 5;
|
|
char fg_key[6] = "dummy";
|
|
int fg_nspace = 0;
|
|
int fg_nints = 0;
|
|
int fg_ints[1];
|
|
int fg_nreals = 0;
|
|
double fg_reals[1];
|
|
int fg_tag_surf;
|
|
int token1, token2;
|
|
// printf(" Parasolid Acceptance Test\n");
|
|
// printf(" =========================\n");
|
|
// printf("\n");
|
|
// printf(" This acceptance test will try out some of the features which\n");
|
|
// printf("are available through the Kernel Interface of Parasolid.\n");
|
|
// printf(" Although the tests are not exhaustive, they make use\n");
|
|
// printf("use of some of the major parts of the system, including:\n");
|
|
// printf(" - starting and stopping the modeller\n");
|
|
// printf(" - model creation and deletion\n");
|
|
// printf(" - Boolean operations\n");
|
|
// printf(" - archived model files\n");
|
|
// printf(" - snapshot files of tag memory\n");
|
|
// printf(" - error handling\n");
|
|
// printf(" - rollback.\n");
|
|
// printf("\n");
|
|
// printf(" The following Parasolid routines are called:\n");
|
|
// printf("\n");
|
|
// printf("APPTRA CHCKEN CLABYS CRBXSO CRCYSO CRETRA DELENT GETMOD GETSNP\n");
|
|
// printf("GTTGLI IDCOEN INTBYS MERGEN ROLBLM ROLSMK SAVMOD SAVSNP SEINTP\n");
|
|
// printf("STAMOD STOMOD UNIBYS\n");
|
|
// printf("\n");
|
|
// printf(" The following files will be generated by the test, and can be\n");
|
|
// printf("deleted on completion:\n");
|
|
// printf(" - jfile.jnl_txt (journal file)\n");
|
|
// printf(" - xfile.xmt_txt (archived body)\n");
|
|
// printf(" - sfile.snp_bin (snapshot file)\n");
|
|
// printf("\n");
|
|
// printf(" As the test proceeds, messages are output which give the name\n");
|
|
// printf("of the Parasolid routine about to be called, and a brief\n");
|
|
// printf("description of what it will do. If an unexpected result is \n");
|
|
// printf("detected, the tests will stop. Hence, the routine causing an\n");
|
|
// printf("error can be found from the messages.\n");
|
|
// printf("\n");
|
|
// printf("\n");
|
|
{
|
|
/*
|
|
From V7.0, Parasolid is `DLL-capable', ie, the Parasolid
|
|
library contains stub functions which transfer the Downward Interface
|
|
calls to registered callback functions, allowing Parasolid to be
|
|
delivered as a self-contained image as well as an archive/object library.
|
|
This does affect how the application is linked against Parasolid in order
|
|
to obtain a correct runtime match between the application's Frustrum and
|
|
the Parasolid stubs, ie, for the parasolid_test.c program, the behaviour
|
|
of the example frustrum.lib and fg.lib.
|
|
|
|
We choose to always register all our example routines: when
|
|
linking against the archive library cc parasolid_test.c frustrum.lib
|
|
fg.lib parasolid.lib or cc parasolid_test.c frustrum.o fg.o
|
|
parasolid.lib then our routines are preloaded into the image and the
|
|
stubs in parasolid.lib are never required - the registry does occur but
|
|
nothing in Parasolid then uses the registration. Note that the V6
|
|
equivalent cc parasolid_test.c parasolid.lib frustrum.lib fg.lib will not
|
|
work: only the stub routines are loaded from the Parasolid library and
|
|
STAMOD will fail. When linking against a standalone image cc
|
|
parasolid_test.c frustrum.lib fg.lib parasolid.so or cc
|
|
parasolid_test.c frustrum.o fg.o parasolid.so then both the example
|
|
routines and the Parasolid stubs are loaded, the stubs being hidden in
|
|
the image and performing immediate transfer to the active code from the
|
|
example libraries.
|
|
*/
|
|
extern void FSTART(int *);
|
|
extern void FABORT(int *);
|
|
extern void FSTOP(int *);
|
|
extern void FMALLO(int *, char **, int *);
|
|
extern void FMFREE(int *, char **, int *);
|
|
extern void GOSGMT(const int *, const int *, const int *, const int *,
|
|
const double *, const int *, const int *, int *);
|
|
extern void GOOPSG(const int *, const int *, const int *, const int *,
|
|
const double *, const int *, const int *, int *);
|
|
extern void GOCLSG(const int *, const int *, const int *, const int *,
|
|
const double *, const int *, const int *, int *);
|
|
extern void GOPIXL(const int *, const double *, const int *, const int *,
|
|
int *);
|
|
extern void GOOPPX(const int *, const double *, const int *, const int *,
|
|
int *);
|
|
extern void GOCLPX(const int *, const double *, const int *, const int *,
|
|
int *);
|
|
extern void FFOPRD(const int *, const int *, const char *, const int *,
|
|
const int *, int *, int *);
|
|
extern void FFOPWR(const int *, const int *, const char *, const int *,
|
|
const char *, const int *, int *, int *);
|
|
extern void FFCLOS(const int *, const int *, const int *, int *);
|
|
extern void FFREAD(const int *, const int *, const int *, char *, int *,
|
|
int *);
|
|
extern void FFWRIT(const int *, const int *, const int *, const char *,
|
|
int *);
|
|
extern void FFOPRB(const int *, const int *, const int *, int *, int *,
|
|
int *);
|
|
extern void FFSEEK(const int *, const int *, const int *, int *);
|
|
extern void FFTELL(const int *, const int *, int *, int *);
|
|
extern void FGCRCU(const char *, int *, int *, int *, int *, double *,
|
|
int *, double *, int *);
|
|
extern void FGCRSU(const char *, int *, int *, int *, int *, double *,
|
|
int *, double *, int *);
|
|
extern void FGEVCU(int *, double *, double *, double *, int *, double *,
|
|
int *);
|
|
extern void FGEVSU(int *, double *, double *, double *, double *, int *,
|
|
int *, int *, double *, int *);
|
|
extern void FGPRCU(int *, double *, double *, double *, int *, int *);
|
|
extern void FGPRSU(int *, double *, double *, double *, int *, int *);
|
|
|
|
PK_SESSION_frustrum_t fru;
|
|
// printf("Registering Example Frustrum ...\n");
|
|
PK_SESSION_frustrum_o_m(fru);
|
|
fru.fstart = FSTART;
|
|
// fru.fabort = FABORT;
|
|
fru.fstop = FSTOP;
|
|
fru.fmallo = FMALLO;
|
|
fru.fmfree = FMFREE;
|
|
// fru.gosgmt = GOSGMT;
|
|
// fru.goopsg = GOOPSG;
|
|
// fru.goclsg = GOCLSG;
|
|
// fru.gopixl = GOPIXL;
|
|
// fru.gooppx = GOOPPX;
|
|
// fru.goclpx = GOCLPX;
|
|
fru.ffoprd = FFOPRD;
|
|
fru.ffopwr = FFOPWR;
|
|
fru.ffclos = FFCLOS;
|
|
fru.ffread = FFREAD;
|
|
fru.ffwrit = FFWRIT;
|
|
// fru.ffoprb = FFOPRB;
|
|
// fru.ffseek = FFSEEK;
|
|
// fru.fftell = FFTELL;
|
|
// fru.fgcrcu = FGCRCU;
|
|
// fru.fgcrsu = FGCRSU;
|
|
// fru.fgevcu = FGEVCU;
|
|
// fru.fgevsu = FGEVSU;
|
|
// fru.fgprcu = FGPRCU;
|
|
// fru.fgprsu = FGPRSU;
|
|
PK_SESSION_register_frustrum(&fru);
|
|
}
|
|
// printf(
|
|
// "STAMOD: Start the modeller and check that the version is suitable.\n");
|
|
// printf(" A journal file jfile.jnl_txt will be written.\n");
|
|
nchars = 5;
|
|
token1 = KI_TRUE;
|
|
STAMOD(&token1, &nchars, const_cast<KI_chr_filename *>("jfile"), &usrfld, &tworld, &vrsion, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("STAMOD: returns version %d\n", vrsion);
|
|
// printf("SEINTP: Set interface parameter to allow rollback and rollforward\n");
|
|
SEINTP(&pcode, &pival, &prval, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("DELENT: Attempt to delete invalid entity (the null tag)\n");
|
|
// printf(" This should result in the ifail KI_not_a_tag 22\n");
|
|
token1 = NULTAG;
|
|
DELENT(&token1, &ifail);
|
|
if (report_ifail(ifail, KI_not_a_tag) != 0)
|
|
return;
|
|
// printf("CRBXSO: Create a block\n");
|
|
vec1[0] = 0.0;
|
|
vec1[1] = 0.0;
|
|
vec1[2] = 0.0;
|
|
vec2[0] = 0.0;
|
|
vec2[1] = 0.0;
|
|
vec2[2] = 1.0;
|
|
CRBXSO(vec1, vec2, &width, &height, &depth, &tbox1, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("IDCOEN: Get a list of all the faces and check that there are\n");
|
|
// printf(" the correct number of them (6).\n");
|
|
token1 = TYTOFA;
|
|
IDCOEN(&tbox1, &token1, &tfl1, &nfaces, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
if (nfaces != 6)
|
|
wrong_result(nfaces);
|
|
// printf(
|
|
// "SAVMOD: Save the block in a file XFILE. This will be read in later.\n");
|
|
nchars = 5;
|
|
SAVMOD(&tbox1, &nchars, const_cast<KI_chr_key *>("xfile"), &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("DELENT: Delete the block.\n");
|
|
DELENT(&tbox1, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("CRBXSO: Create another solid block\n");
|
|
vec1[0] = 0.0;
|
|
vec1[1] = 0.0;
|
|
vec1[2] = 0.0;
|
|
vec2[0] = 0.0;
|
|
vec2[1] = 0.0;
|
|
vec2[2] = 1.0;
|
|
CRBXSO(vec1, vec2, &width, &height, &depth, &tbox2, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("CRCYSO: Create a solid cylinder\n");
|
|
vec1[0] = 0.0;
|
|
vec1[1] = 0.0;
|
|
vec1[2] = -1.0;
|
|
vec2[0] = 0.0;
|
|
vec2[1] = 0.0;
|
|
vec2[2] = 1.0;
|
|
cyl_rad = 2.0;
|
|
cyl_ht = 12.0;
|
|
CRCYSO(vec1, vec2, &cyl_rad, &cyl_ht, &tcyl, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("CRETRA: Create a translation transformation\n");
|
|
vec1[0] = 1.0;
|
|
vec1[1] = 0.0;
|
|
vec1[2] = 0.0;
|
|
distance = 99.0;
|
|
CRETRA(vec1, &distance, &ttran, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("ROLSMK: Set rollback mark\n");
|
|
ROLSMK(&ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("APPTRA: Apply transformation to the cylinder to move it away from\n");
|
|
// printf(" the block.\n");
|
|
APPTRA(&tcyl, &ttran, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("CLABYS: Test if the bodies clash, which they should not do.\n");
|
|
token1 = NULTAG;
|
|
token2 = KI_FALSE;
|
|
CLABYS(&tbox2, &token1, &tcyl, &token1, &token2, &tfl1, &tfl2, &nfaces,
|
|
&ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf(" Number of faces returned by CLABYS %d\n", nfaces);
|
|
if (nfaces != 0)
|
|
wrong_result(nfaces);
|
|
// printf("ROLBLM: Roll back to undo the transformation.\n");
|
|
ROLBLM(&ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("CLABYS: Test that the bodies now do clash.\n");
|
|
token1 = NULTAG;
|
|
token2 = KI_TRUE;
|
|
CLABYS(&tbox2, &token1, &tcyl, &token1, &token2, &tfl1, &tfl2, &nfaces,
|
|
&ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf(" Number of faces now returned by CLABYS %d\n", nfaces);
|
|
if (nfaces != 2)
|
|
wrong_result(nfaces);
|
|
// printf("INTBYS: Intersect the block and the cylinder\n");
|
|
// printf(" A single new body should be created\n");
|
|
INTBYS(&tcyl, &tbox2, &tass1, &nbod, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
if (nbod != 1)
|
|
wrong_result(nbod);
|
|
// printf("IDCOEN: Get a list of the bodies in the resulting assembly\n");
|
|
token1 = TYTOBY;
|
|
IDCOEN(&tass1, &token1, &tbyli, &nbod, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
if (nbod != 1)
|
|
wrong_result(nbod);
|
|
// printf("GTTGLI: Get the body from the list\n");
|
|
pos = 1;
|
|
nitems = 1;
|
|
GTTGLI(&tbyli, &pos, &nitems, tbody, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("CHCKEN: Check the body\n");
|
|
CHCKEN(&tbody[0], &chcken_mxflts, &chcken_nopts, chcken_option, &fault_tokens,
|
|
&fault_tags, &pdata, &nfault, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("SAVSNP: Save the state of tag memory to a file\n");
|
|
nchars = 5;
|
|
token1 = KI_FALSE;
|
|
SAVSNP(&nchars, const_cast<KI_chr_filename *> ("sfile"), &token1, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("DELENT: Delete the assembly\n");
|
|
DELENT(&tass1, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("STOMOD: Stop the modeller.\n");
|
|
STOMOD(&ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("STAMOD: Restart the modeller, this time without a journal file.\n");
|
|
nchars = 0;
|
|
token1 = KI_FALSE;
|
|
STAMOD(&token1, &nchars, const_cast<KI_chr_filename *> ("jfile"), &usrfld, &tworld, &vrsion, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("GETSNP: Restore the saved state of tag memory\n");
|
|
nchars = 5;
|
|
token1 = KI_FALSE;
|
|
GETSNP(&nchars, const_cast<KI_chr_filename *> ("sfile"), &token1, &token1, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("GETMOD: Try to get non-existent model. This should result in\n");
|
|
// printf(" ifail KI_key_not_found 58\n");
|
|
nchars = 6;
|
|
GETMOD(&nchars, const_cast<KI_chr_key *>("xyz123"), &tget, &ifail);
|
|
if (report_ifail(ifail, KI_key_not_found) != 0)
|
|
return;
|
|
// printf("GETMOD: Get the saved body.\n");
|
|
nchars = 5;
|
|
GETMOD(&nchars, const_cast<KI_chr_key *>("xfile"), &tget, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("CRCYSO: Create another solid cylinder\n");
|
|
vec1[0] = 0.0;
|
|
vec1[1] = 0.0;
|
|
vec1[2] = 0.0;
|
|
vec2[0] = 0.0;
|
|
vec2[1] = 0.0;
|
|
vec2[2] = 1.0;
|
|
cyl_rad = 2.0;
|
|
cyl_ht = 12.0;
|
|
CRCYSO(vec1, vec2, &cyl_rad, &cyl_ht, &tcyl, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("UNIBYS: Unite the new cylinder and saved block\n");
|
|
UNIBYS(&tget, &tcyl, &tass2, &nbod, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
if (nbod != 1)
|
|
wrong_result(nbod);
|
|
// printf("IDCOEN: Get a list of the bodies from the resulting assembly\n");
|
|
token1 = TYTOBY;
|
|
IDCOEN(&tass2, &token1, &tbyli, &nbod, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
if (nbod != 1)
|
|
wrong_result(nbod);
|
|
// printf("GTTGLI: Get the body from the list\n");
|
|
pos = 1;
|
|
nitems = 1;
|
|
GTTGLI(&tbyli, &pos, &nitems, tbody, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("CHCKEN: Check the body\n");
|
|
CHCKEN(&tbody[0], &chcken_mxflts, &chcken_nopts, chcken_option, &fault_tokens,
|
|
&fault_tags, &pdata, &nfault, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("IDCOEN: Get a list of all the faces and check that there are 9\n");
|
|
token1 = TYTOFA;
|
|
IDCOEN(&tbody[0], &token1, &tfl1, &nfaces, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
if (nfaces != 9)
|
|
wrong_result(nfaces);
|
|
// printf("MERGEN: Merge the superfluous faces away.\n");
|
|
MERGEN(&tbody[0], &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
// printf("IDCOEN: Get a list of all the faces and check that there are 8\n");
|
|
token1 = TYTOFA;
|
|
IDCOEN(&tbody[0], &token1, &tfl1, &nfaces, &ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
if (nfaces != 8)
|
|
wrong_result(nfaces);
|
|
// printf("CRFGSU: Cause a dummy call to be made to a FG routine (FGCRSU)\n");
|
|
CRFGSU(&fg_key_len, fg_key, &fg_nspace, &fg_nints, fg_ints, &fg_nreals,
|
|
fg_reals, &fg_tag_surf, &ifail);
|
|
|
|
|
|
// string caseName = "myCase5";
|
|
// CaseReader caseReader((boost::format("%1%/intersectCases/%2%/surfaces.txt") % SOURCE_DIR % caseName).str());
|
|
string caseName = "zyr&jh23_12_21/case6";
|
|
CaseReader caseReader((boost::format("%1%/intersectCases/%2%/surf_A.txt") % SOURCE_DIR % caseName).str(),
|
|
(boost::format("%1%/intersectCases/%2%/surf_B.txt") % SOURCE_DIR % caseName).str(), 3);
|
|
// caseReader.srf1.printSrf();
|
|
// double vertex_1[144] = {
|
|
// 0, 0, 0.22, 1.1, 0, 0.18, 0.27, 0.9, 0, 0.44, 0.275, 1.1,
|
|
// 0, 0.54, 0.108, 0.9, 0, 0.8, 0.22, 1, 0, 1, 0.12, 1,
|
|
// 0.2, 0, 0.22, 1, 0.2, 0.2, -0.3, 1, 0.2, 0.4, 0.4, 1,
|
|
// 0.22, 0.66, -0.11, 1.1, 0.2, 0.8, -0.1, 1, 0.18, 0.9, 0.18, 0.9,
|
|
// 0.36, 0, 0.162, 0.9, 0.4, 0.2, -0.3, 1, 0.44, 0.44, 0.44, 1.1,
|
|
// 0.4, 0.6, -0.1, 1, 0.36, 0.72, -0.09, 0.9, 0.4, 1, 0.23, 1,
|
|
// 0.54, 0, 0.18, 0.9, 0.54, 0.18, 0.36, 0.9, 0.6, 0.4, 0.4, 1,
|
|
// 0.54, 0.54, 0.36, 0.9, 0.6, 0.8, 0.4, 1, 0.6, 1, 0.2, 1,
|
|
// 0.88, 0, 0.209, 1.1, 0.8, 0.2, -0.4, 1, 0.88, 0.44, 0.44, 1.1,
|
|
// 0.8, 0.6, -0.27, 1, 0.8, 0.8, -0.27, 1, 0.72, 0.9, 0.18, 0.9,
|
|
// 1.1, 0, 0.22, 1.1, 1, 0.2, 0.12, 1, 1, 0.4, 0.22, 1,
|
|
// 1, 0.6, 0.32, 1, 1.2, 0.96, 0.264, 1.2, 1.1, 1.1, 0.132, 1.1};
|
|
//
|
|
// double vertex_2[144] = {
|
|
// 0, 0, 0.11, 1.1, 0, 0.18, -0.09, 0.9, 0, 0.44, 0, 1.1,
|
|
// 0, 0.54, 0.09, 0.9, 0, 0.8, 0, 1, 0, 0.9, 0, 1,
|
|
// 0.2, 0, 0, 1, 0.2, 0.2, 0.42, 1, 0.2, 0.4, 0.42, 1,
|
|
// 0.22, 0.66, -0.22, 1.1, 0.2, 0.8, 0.6, 1, 0.18, 0.9, 0, 0.9,
|
|
// 0.36, 0, 0, 0.9, 0.4, 0.2, -0.2, 1, 0.44, 0.44, -0.22, 1.1,
|
|
// 0.4, 0.6, 0.4, 1, 0.36, 0.72, -0.18, 0.9, 0.4, 1, 0, 1,
|
|
// 0.54, 0, 0, 0.9, 0.54, 0.18, 0.36, 0.9, 0.6, 0.4, 0.4, 1,
|
|
// 0.54, 0.54, -0.18, 0.9, 0.6, 0.8, 0.41, 1, 0.6, 1, 0, 1,
|
|
// 0.88, 0, 0, 1.1, 0.8, 0.2, 0.4, 1, 0.88, 0.44, 0.44, 1.1,
|
|
// 0.8, 0.6, -0.2, 1, 0.8, 0.8, 0.41, 1, 0.72, 0.9, 0, 0.9,
|
|
// 1.21, 0, 0, 1.1, 1, 0.2, 0, 1, 1, 0.4, 0, 1,
|
|
// 1, 0.6, 0, 1, 1.2, 0.96, 0, 1.2, 1.1, 1.1, 0.0825, 1.1,
|
|
// };
|
|
|
|
// double vertex_4[108] = {
|
|
// 0, 0, 0.2, 0, 0.2, 0.3, 0, 0.4, 0.25, 0, 0.6, 0.12,
|
|
// 0, 0.8, 0.22, 0, 1, 0.12, 0.2, 0, 0.22, 0.2, 0.2, -0.3,
|
|
// 0.2, 0.4, 0.4, 0.2, 0.6, -0.1, 0.2, 0.8, -0.1, 0.2, 1, 0.2,
|
|
// 0.4, 0, 0.18, 0.4, 0.2, -0.3, 0.4, 0.4, 0.4, 0.4, 0.6, -0.1,
|
|
// 0.4, 0.8, -0.1, 0.4, 1, 0.23, 0.6, 0, 0.2, 0.6, 0.2, 0.4,
|
|
// 0.6, 0.4, 0.4, 0.6, 0.6, 0.4, 0.6, 0.8, 0.4, 0.6, 1, 0.2,
|
|
// 0.8, 0, 0.19, 0.8, 0.2, -0.4, 0.8, 0.4, 0.4, 0.8, 0.6, -0.27,
|
|
// 0.8, 0.8, -0.27, 0.8, 1, 0.2, 1, 0, 0.2, 1, 0.2, 0.12,
|
|
// 1, 0.4, 0.22, 1, 0.6, 0.32, 1, 0.8, 0.22, 1, 1, 0.12,
|
|
// };
|
|
auto dim_1_u = caseReader.srf1.dim_u, dim_1_v = caseReader.srf1.dim_v;
|
|
auto dim_2_u = caseReader.srf2.dim_u, dim_2_v = caseReader.srf2.dim_v;
|
|
// double knot_1_u[2] = {0., 1.};
|
|
// int knot_mult_1_u[2] = {dim_1_u, dim_1_u};
|
|
// double knot_1_v[2] = {0., 1.};
|
|
// int knot_mult_1_v[2] = {dim_1_v, dim_1_v};
|
|
//
|
|
// double knot_2_u[2] = {0., 1.};
|
|
// int knot_mult_2_u[2] = {dim_2_u, dim_2_u};
|
|
// double knot_2_v[2] = {0., 1.};
|
|
// int knot_mult_2_v[2] = {dim_2_v, dim_2_v};
|
|
|
|
PK_BSURF_sf_t bsurf_sf_1;
|
|
PK_BSURF_t bsurf_1 = -1;
|
|
PK_BSURF_sf_t bsurf_sf_2;
|
|
PK_BSURF_t bsurf_2 = -1;
|
|
|
|
PK_PARTITION_t partition;
|
|
int n_geoms;
|
|
PK_GEOM_t *geoms;
|
|
|
|
PK_SESSION_ask_curr_partition(&partition);
|
|
PK_PARTITION_ask_geoms(partition, &n_geoms, &geoms);
|
|
PK_ENTITY_delete(n_geoms, geoms);
|
|
|
|
bsurf_sf_1.u_degree = caseReader.srf1.degree_u; // bezier
|
|
bsurf_sf_1.v_degree = caseReader.srf1.degree_v;
|
|
bsurf_sf_1.n_u_vertices = dim_1_u;
|
|
bsurf_sf_1.n_v_vertices = dim_1_v;
|
|
|
|
// bsurf_sf_1.vertex_dim = 3;
|
|
// bsurf_sf_1.is_rational = PK_LOGICAL_false;
|
|
|
|
bsurf_sf_1.vertex_dim = caseReader.srf1.ptDim;
|
|
if (bsurf_sf_1.vertex_dim == 3)
|
|
bsurf_sf_1.is_rational = PK_LOGICAL_false;
|
|
else if (bsurf_sf_1.vertex_dim == 4)
|
|
bsurf_sf_1.is_rational = PK_LOGICAL_true;
|
|
else
|
|
assert(0);
|
|
bsurf_sf_1.vertex = caseReader.srf1.vertex;
|
|
bsurf_sf_1.form = PK_BSURF_form_unset_c;
|
|
bsurf_sf_1.n_u_knots = caseReader.srf1.knots_num_u;
|
|
bsurf_sf_1.n_v_knots = caseReader.srf1.knots_num_v;
|
|
bsurf_sf_1.u_knot_mult = caseReader.srf1.knots_mult_u;
|
|
bsurf_sf_1.v_knot_mult = caseReader.srf1.knots_mult_v;
|
|
bsurf_sf_1.u_knot = caseReader.srf1.knots_u;
|
|
bsurf_sf_1.v_knot = caseReader.srf1.knots_v;
|
|
bsurf_sf_1.u_knot_type = PK_knot_unset_c;
|
|
bsurf_sf_1.v_knot_type = PK_knot_unset_c;
|
|
// bsurf_sf_1.u_knot_type = PK_knot_bezier_ends_c;
|
|
// bsurf_sf_1.v_knot_type = PK_knot_bezier_ends_c;
|
|
bsurf_sf_1.is_u_periodic = PK_LOGICAL_false;
|
|
bsurf_sf_1.is_v_periodic = PK_LOGICAL_false;
|
|
bsurf_sf_1.is_u_closed = PK_LOGICAL_false;
|
|
bsurf_sf_1.is_v_closed = PK_LOGICAL_false;
|
|
bsurf_sf_1.self_intersecting = PK_LOGICAL_false;
|
|
cout << "bsurf_sf_1.u_knot: " << bsurf_sf_1.u_knot[0] << ", " << bsurf_sf_1.u_knot[1] << endl;
|
|
cout << "bsurf_sf_1.v_knot: " << bsurf_sf_1.v_knot[0] << ", " << bsurf_sf_1.v_knot[1] << endl;
|
|
cout << "bsurf_sf_1.u_knot_mult: " << bsurf_sf_1.u_knot_mult[0] << ", " << bsurf_sf_1.u_knot_mult[1] << endl;
|
|
cout << "bsurf_sf_1.v_knot_mult: " << bsurf_sf_1.v_knot_mult[0] << ", " << bsurf_sf_1.v_knot_mult[1] << endl;
|
|
bsurf_sf_1.convexity = PK_convexity_unset_c;
|
|
auto err_code_1 = PK_BSURF_create(&bsurf_sf_1, &bsurf_1);
|
|
if (err_code_1 != 0) {
|
|
// bool wasError;
|
|
// PK_ERROR_sf_t errorSf;
|
|
// auto askLastErrErrCode = PK_ERROR_ask_last(reinterpret_cast<PK_LOGICAL_t *const>(&wasError), &errorSf);
|
|
// // 输出code_token
|
|
// cout << "errorSf.code_token: " << errorSf.code_token << endl;
|
|
errHandle();
|
|
printf("error code: %d\n", err_code_1);
|
|
printf("bsurf1: %d\n", bsurf_1);
|
|
}
|
|
|
|
/**
|
|
* 输出
|
|
* Specific Errors:
|
|
* PK_ERROR_zero_interval knot set covers a zero interval
|
|
* PK_ERROR_periodic_open periodic surface is not closed
|
|
* PK_ERROR_periodic_not_smooth periodic surface is not smooth at the seam
|
|
* PK_ERROR_bad_dimension dimension != 3 polynomial or != 4 rational
|
|
* PK_ERROR_cant_make_bspline failed to create the surface
|
|
*/
|
|
printf("PK_ERROR_zero_interval: %d\n", PK_ERROR_zero_interval);
|
|
printf("PK_ERROR_periodic_open: %d\n", PK_ERROR_periodic_open);
|
|
printf("PK_ERROR_periodic_not_smooth: %d\n", PK_ERROR_periodic_not_smooth);
|
|
printf("PK_ERROR_bad_dimension: %d\n", PK_ERROR_bad_dimension);
|
|
printf("PK_ERROR_cant_make_bspline: %d\n", PK_ERROR_cant_make_bspline);
|
|
|
|
|
|
bsurf_sf_2.u_degree = caseReader.srf2.degree_u;
|
|
bsurf_sf_2.v_degree = caseReader.srf2.degree_v;
|
|
bsurf_sf_2.n_u_vertices = dim_2_u;
|
|
bsurf_sf_2.n_v_vertices = dim_2_v;
|
|
bsurf_sf_2.vertex_dim = caseReader.srf2.ptDim;
|
|
if (bsurf_sf_2.vertex_dim == 3)
|
|
bsurf_sf_2.is_rational = PK_LOGICAL_false;
|
|
else if (bsurf_sf_2.vertex_dim == 4)
|
|
bsurf_sf_2.is_rational = PK_LOGICAL_true;
|
|
else
|
|
assert(0);
|
|
bsurf_sf_2.vertex = caseReader.srf2.vertex;
|
|
bsurf_sf_2.form = PK_BSURF_form_unset_c;
|
|
bsurf_sf_2.n_u_knots = caseReader.srf2.knots_num_u;
|
|
bsurf_sf_2.n_v_knots = caseReader.srf2.knots_num_v;
|
|
bsurf_sf_2.u_knot_mult = caseReader.srf2.knots_mult_u;
|
|
bsurf_sf_2.v_knot_mult = caseReader.srf2.knots_mult_v;
|
|
bsurf_sf_2.u_knot = caseReader.srf2.knots_u;
|
|
bsurf_sf_2.v_knot = caseReader.srf2.knots_v;
|
|
bsurf_sf_2.u_knot_type = PK_knot_unset_c;
|
|
bsurf_sf_2.v_knot_type = PK_knot_unset_c;
|
|
// bsurf_sf_2.u_knot_type = PK_knot_bezier_ends_c;
|
|
// bsurf_sf_2.v_knot_type = PK_knot_bezier_ends_c;
|
|
bsurf_sf_2.is_u_periodic = PK_LOGICAL_false;
|
|
bsurf_sf_2.is_v_periodic = PK_LOGICAL_false;
|
|
bsurf_sf_2.is_u_closed = PK_LOGICAL_false;
|
|
bsurf_sf_2.is_v_closed = PK_LOGICAL_false;
|
|
bsurf_sf_2.self_intersecting = PK_LOGICAL_false;
|
|
bsurf_sf_2.convexity = PK_convexity_unset_c;
|
|
auto err_code_2 = PK_BSURF_create(&bsurf_sf_2, &bsurf_2);
|
|
if (err_code_2 != 0) {
|
|
printf("error code: %d\n", err_code_2);
|
|
printf("bsurf2: %d\n", bsurf_2);
|
|
}
|
|
|
|
|
|
// ==========test of sampling==========
|
|
|
|
int level = 10;
|
|
int sampleCnt = pow(2, level - 1) + 1;
|
|
printf("sample cnt: %d\n", sampleCnt);
|
|
double step_u = 1.0 / (sampleCnt - 1);
|
|
double step_v = 1.0 / (sampleCnt - 1);
|
|
|
|
// 二阶导数
|
|
for (int i = 0; i < sampleCnt; i++) {
|
|
double u = step_u * (double) i;
|
|
for (int j = 0; j < sampleCnt; j++) {
|
|
PK_VECTOR_t resTmp[20];
|
|
double v = step_v * (double) j;
|
|
PK_UV_t uv;
|
|
uv.param[0] = u;
|
|
uv.param[1] = v;
|
|
PK_SURF_eval(bsurf_1, uv, 2, 2, PK_LOGICAL_true, resTmp);
|
|
}
|
|
}
|
|
|
|
// timeCostOfScdDer = get_time() - timeCostOfScdDer;
|
|
// printf("time cost of second derivatives: %lf\n", timeCostOfScdDer);
|
|
|
|
auto startDerMom = std::chrono::steady_clock::now();
|
|
for (int i = 0; i < sampleCnt; i++) {
|
|
double u = step_u * (double) i;
|
|
for (int j = 0; j < sampleCnt; j++) {
|
|
PK_VECTOR_t resTmp[20];
|
|
double v = step_v * (double) j;
|
|
PK_UV_t uv;
|
|
uv.param[0] = u;
|
|
uv.param[1] = v;
|
|
PK_SURF_eval(bsurf_1, uv, 1, 1, PK_LOGICAL_true, resTmp);
|
|
}
|
|
}
|
|
auto endDerMom = std::chrono::steady_clock::now();
|
|
std::chrono::duration<double, std::milli> diffDerMom = endDerMom - startDerMom;
|
|
printf("time cost of derivative: %lf ms\n", diffDerMom.count());
|
|
|
|
auto startEvalMom = std::chrono::steady_clock::now();
|
|
for (int i = 0; i < sampleCnt; i++) {
|
|
double u = step_u * (double) i;
|
|
for (int j = 0; j < sampleCnt; j++) {
|
|
PK_VECTOR_t resTmp[20];
|
|
double v = step_v * (double) j;
|
|
PK_UV_t uv;
|
|
uv.param[0] = u;
|
|
uv.param[1] = v;
|
|
PK_SURF_eval(bsurf_1, uv, 0, 0, PK_LOGICAL_true, resTmp);
|
|
}
|
|
}
|
|
auto endEvalMom = std::chrono::steady_clock::now();
|
|
std::chrono::duration<double, std::milli> diffEvalMom = endEvalMom - startEvalMom;
|
|
printf("time cost of evaluations: %lf ms\n", diffEvalMom.count());
|
|
|
|
PK_UV_t uv;
|
|
uv.param[0] = 0.35;
|
|
uv.param[1] = 0.35;
|
|
const int N = 20;
|
|
PK_VECTOR_t res[N];
|
|
for (int i = 0; i < N; i++) {
|
|
res[i].coord[0] = 0;
|
|
res[i].coord[1] = 0;
|
|
res[i].coord[2] = 0;
|
|
}
|
|
// auto err_code_eval = PK_SURF_eval(bsurf_1, uv, 1, 1, PK_LOGICAL_true, res);
|
|
// printf("err code of evaluation: %d\n", err_code_eval);
|
|
// for (int i = 0; i < 10; i++)
|
|
// printf("res %d: (%f, %f, %f)\n", i, res[i].coord[0], res[i].coord[1],
|
|
// res[i].coord[2]);
|
|
|
|
// ==========end of sampling test==========
|
|
|
|
// ==========test of intersection==========
|
|
PK_SURF_intersect_surf_o_t intersect_options;
|
|
PK_SURF_intersect_surf_o_m(intersect_options);
|
|
|
|
// intersect_options.have_uvbox_1 = PK_LOGICAL_false;
|
|
// intersect_options.uvbox_1 = uvbox_of_face1;
|
|
// intersect_options.have_uvbox_2 = PK_LOGICAL_false;
|
|
// intersect_options.uvbox_2 = uvbox_of_face2;
|
|
|
|
int n_vectors = -1;
|
|
PK_VECTOR_t *vectors = NULL;
|
|
int n_curves = -1;
|
|
PK_CURVE_t *curves = NULL;
|
|
PK_INTERVAL_t *bounds = NULL;
|
|
PK_intersect_curve_t *types = NULL;
|
|
|
|
// PK_VECTOR_t point_on_blend_face[1];
|
|
|
|
// clock_t start, finish;
|
|
// double duration;
|
|
// start = clock();
|
|
|
|
|
|
|
|
auto startMom = std::chrono::steady_clock::now();
|
|
|
|
// double timeCostOfIntersect = get_time();
|
|
|
|
PK_ERROR_code_t intersectErrCode =
|
|
PK_SURF_intersect_surf(bsurf_1, bsurf_2, &intersect_options, &n_vectors,
|
|
&vectors, &n_curves, &curves, &bounds, &types);
|
|
|
|
// finish = clock();
|
|
// duration = (double)(finish - start) / CLOCKS_PER_SEC;
|
|
// printf("time cost of intersection counted by clock:%lf ms\n", duration);
|
|
|
|
auto endMom = std::chrono::steady_clock::now();
|
|
std::chrono::duration<double, std::milli> diff = endMom - startMom;
|
|
printf("time cost of intersection counted by chrono: %lf ms\n", diff.count());
|
|
|
|
// timeCostOfIntersect = get_time() - timeCostOfIntersect;
|
|
// printf("time cost of intersect counted by get_time(): %lf\n",
|
|
// timeCostOfIntersect);
|
|
|
|
if (intersectErrCode != 0)printf("PK_ERROR_code_t of intersect = %d\n", intersectErrCode);
|
|
printf("n_vectors=%d\n", n_vectors);
|
|
printf("n_curves=%d\n", n_curves);
|
|
|
|
FILE *fptrCurves;
|
|
fptrCurves = fopen((boost::format("%1%/intersectCases/%2%/curve.txt") % SOURCE_DIR % caseName).str().c_str(), "w");
|
|
|
|
PK_CURVE_make_bcurve_o_t options;
|
|
options.o_t_version = 1;
|
|
options.tolerance = 1.0e-5;
|
|
options.have_degree = PK_LOGICAL_true;
|
|
options.degree = 3;
|
|
options.force_continuity = PK_force_continuity_no_c;
|
|
options.continuity = PK_continuity_g0_c; // force_continuity is false, so this is ignored
|
|
options.force_non_rational = PK_LOGICAL_false;
|
|
options.force_bezier = PK_LOGICAL_false;
|
|
options.update = PK_make_bcurve_update_0_c; // 使用最新的parasolid的模型
|
|
|
|
for (int i = 0; i < n_curves; i++) {
|
|
PK_CURVE_t temp_curve = curves[i];
|
|
// Find the parameter corresponding to the furthest point on the curve:
|
|
double wanted_value = 0.0;
|
|
// First get interval of curve:
|
|
PK_INTERVAL_t temp_interval_of_curve;
|
|
PK_CURVE_ask_interval(curves[i], &temp_interval_of_curve);
|
|
|
|
PK_CURVE_make_bcurve_t makeBcurve = -666;
|
|
PK_BCURVE_t bcurve;
|
|
double achievedTol;
|
|
PK_achieved_cont_t achievedCont;
|
|
|
|
auto makeBcurveErrCode = PK_CURVE_make_bcurve_2(
|
|
/* received arguments */
|
|
temp_curve, temp_interval_of_curve, &options,
|
|
/* returned arguments */
|
|
&makeBcurve, &bcurve, &achievedTol, &achievedCont
|
|
);
|
|
|
|
|
|
if (makeBcurveErrCode != 0) printf("PK_ERROR_code_t of makeBcurveErrCode = %d\n", makeBcurveErrCode);
|
|
else if (i == 0) {
|
|
// print temp_interval_of_curve
|
|
cout << "temp_interval_of_curve: {" << temp_interval_of_curve.value[0] << ", "
|
|
<< temp_interval_of_curve.value[1] << "}" << endl;
|
|
|
|
printf("achievedTol = %f\n", achievedTol);
|
|
printf("achievedCont = %d\n", achievedCont);
|
|
|
|
PK_BCURVE_sf_t temp_sf_bcurve;
|
|
auto askBcurveErrCode = PK_BCURVE_ask(bcurve, &temp_sf_bcurve);
|
|
|
|
if (askBcurveErrCode != 0) printf("PK_ERROR_code_t of askBcurveErrCode = %d\n", askBcurveErrCode);
|
|
|
|
cout << "temp_sf_bcurve: {" << endl;
|
|
cout << " degree = " << temp_sf_bcurve.degree << endl;
|
|
cout << " n_vertices = " << temp_sf_bcurve.n_vertices << endl;
|
|
cout << " vertex_dim = " << temp_sf_bcurve.vertex_dim << endl;
|
|
cout << " is_rational = " << (temp_sf_bcurve.is_rational ? "true" : "false") << endl;
|
|
// for (int i = 0; i < temp_sf_bcurve.n_vertices; i++) {
|
|
// cout << "{";
|
|
// for (int j = 0; j < temp_sf_bcurve.vertex_dim; j++) {
|
|
// cout << temp_sf_bcurve.vertex[i * temp_sf_bcurve.vertex_dim + j];
|
|
// if (j != temp_sf_bcurve.vertex_dim - 1) cout << ", ";
|
|
// }
|
|
// cout << "}, " << endl;
|
|
// }
|
|
cout << " form = " << temp_sf_bcurve.form << endl;
|
|
cout << " n_knots = " << temp_sf_bcurve.n_knots << endl;
|
|
for (int i = 0; i < temp_sf_bcurve.n_knots; i++) {
|
|
cout << " knots[" << i << "] = " << temp_sf_bcurve.knot[i];
|
|
}
|
|
for (int i = 0; i < temp_sf_bcurve.n_knots; i++) {
|
|
cout << " knot_mult[" << i << "] = " << temp_sf_bcurve.knot_mult[i] << ", ";
|
|
}
|
|
cout << endl;
|
|
cout << " knot_type = " << temp_sf_bcurve.knot_type << endl;
|
|
cout << " is_periodic = " << (temp_sf_bcurve.is_periodic ? "true" : "false") << endl;
|
|
cout << " is_closed = " << (temp_sf_bcurve.is_closed ? "true" : "false") << endl;
|
|
cout << " self_intersecting = " << temp_sf_bcurve.self_intersecting << endl;
|
|
cout << "}" << endl;
|
|
}
|
|
|
|
|
|
int temp_n_vectors = -1;
|
|
PK_VECTOR_t *temp_vectors = NULL;
|
|
double *temp_ts = NULL;
|
|
|
|
PK_ERROR_code_t symbol_represent = PK_CURVE_output_vectors(
|
|
temp_curve, temp_interval_of_curve, PK_LOGICAL_false, 0., 0., 0.08,
|
|
&temp_n_vectors, &temp_vectors, &temp_ts);
|
|
if (symbol_represent != 0) {
|
|
printf("represent PK_ERROR_code_t=%d!\n", symbol_represent);
|
|
errHandle();
|
|
continue;
|
|
}
|
|
printf("n_vectors of curve %d = %d\n", i, temp_n_vectors);
|
|
// for (int j = 0; j < temp_n_vectors; j++) {
|
|
// printf("%lf %lf %lf\n", temp_vectors[j].coord[0],
|
|
// temp_vectors[j].coord[1], temp_vectors[j].coord[2]);
|
|
// }
|
|
|
|
if (fptrCurves == nullptr) {
|
|
printf("File open error!");
|
|
continue;
|
|
}
|
|
fprintf(fptrCurves, "n_vectors=%d\n", temp_n_vectors);
|
|
for (int j = 0; j < temp_n_vectors; j++) {
|
|
fprintf(fptrCurves, "%lf %lf %lf\n", temp_vectors[j].coord[0],
|
|
temp_vectors[j].coord[1], temp_vectors[j].coord[2]);
|
|
}
|
|
|
|
}
|
|
fclose(fptrCurves);
|
|
|
|
if (n_vectors > 0) {
|
|
FILE *fptrPoints;
|
|
fptrPoints = fopen((boost::format("%1%/intersectCases/%2%/point.txt") % SOURCE_DIR % caseName).str().c_str(), "w");
|
|
// 奇点
|
|
for (int i = 0; i < n_vectors; i++) {
|
|
if (fptrPoints == nullptr) {
|
|
printf("File open error!");
|
|
continue;
|
|
}
|
|
fprintf(fptrPoints, "%lf %lf %lf\n", vectors[i].coord[0], vectors[i].coord[1], vectors[i].coord[2]);
|
|
}
|
|
fclose(fptrPoints);
|
|
}
|
|
|
|
// ==========end of intersection test==========
|
|
|
|
// printf("STOMOD: Close down the modeller\n");
|
|
STOMOD(&ifail);
|
|
if (report_ifail(ifail, 0) != 0)
|
|
return;
|
|
|
|
}
|
|
|
|
#ifdef PS_IOS
|
|
/* This is for iOS, where building a main program entirely from C is
|
|
hard-to-impossible, and we need to be passed a directory to do file
|
|
i/o in. The Xcode app will have main(), and this function is used
|
|
to pass needed pathnames and run the test.
|
|
|
|
These pathnames have to be passed in by the app that calls
|
|
run_ios_parasolid_test, as ordinary C strings. The first normally has
|
|
to come from a system enquiry function, which is only provided for
|
|
Objective-C or Swift.
|
|
*/
|
|
|
|
int run_ios_parasolid_test(
|
|
const char *homepath, /* App's documents dir, usually with a GUID */
|
|
const char *workdir, /* working dir, eg, "Parasolid/parasolid_test" */
|
|
const char *schemadir /* eg, "schemas", must be subdir of working dir. */
|
|
) {
|
|
extern int implement_ios_paths(const char *, const char *, const char *);
|
|
|
|
if (0 == implement_ios_paths(homepath, workdir, schemadir))
|
|
parasolid_test();
|
|
return 0;
|
|
}
|
|
#else
|
|
|
|
|
|
int main() {
|
|
parasolid_test();
|
|
return 0;
|
|
}
|
|
|
|
#endif /* PS_IOS */
|
|
|