benchmark_occ: add command line options --step and --linear_deflection

This commit is contained in:
Hugues Delorme 2016-06-15 18:06:23 +02:00
parent 15558b4085
commit 806e2121c3
2 changed files with 39 additions and 12 deletions

View File

@ -90,6 +90,9 @@ find_library(
find_library(
LIB_OPENCASCADE_TKMESH TKMesh ${LIBDIR_OPENCASCADE}
DOC "Path to the TKMesh import library")
find_library(
LIB_OPENCASCADE_TKSTEP TKSTEP ${LIBDIR_OPENCASCADE}
DOC "Path to the TKMesh import library")
target_link_libraries(
benchmark_opencascade
@ -99,4 +102,5 @@ target_link_libraries(
${LIB_OPENCASCADE_TKXSBASE}
${LIB_OPENCASCADE_TKIGES}
${LIB_OPENCASCADE_TKBREP}
${LIB_OPENCASCADE_TKMESH})
${LIB_OPENCASCADE_TKMESH}
${LIB_OPENCASCADE_TKSTEP})

View File

@ -28,6 +28,8 @@
#include <Transfer_TransientProcess.hxx>
#include <XSControl_WorkSession.hxx>
#include <STEPControl_Reader.hxx>
#include <gmio_core/error.h>
#include <gmio_core/version.h>
#include <gmio_stl/stl_io.h>
@ -37,6 +39,7 @@
#include "../commons/benchmark_tools.h"
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
@ -106,6 +109,12 @@ void readInputIgesShape(const char* filepath)
inputShape = loadShapeFromFile<IGESControl_Reader>(filepath, indicator);
}
void readInputStepShape(const char* filepath)
{
Handle_Message_ProgressIndicator indicator = new ProgressIndicator;
inputShape = loadShapeFromFile<STEPControl_Reader>(filepath, indicator);
}
} // namespace BmkBRep
namespace BmkOcc {
@ -227,10 +236,16 @@ int main(int argc, char** argv)
{
const char* stl_filepath = nullptr;
const char* igs_filepath = nullptr;
const char* stp_filepath = nullptr;
double linear_deflection = 0.1;
int iarg = 1;
while (iarg < argc) {
if (std::strcmp(argv[iarg], "--iges") == 0)
igs_filepath = argv[++iarg];
else if (std::strcmp(argv[iarg], "--step") == 0)
stp_filepath = argv[++iarg];
else if (std::strcmp(argv[iarg], "--linear-deflection") == 0)
linear_deflection = std::atof(argv[++iarg]);
else
stl_filepath = argv[iarg];
++iarg;
@ -246,18 +261,26 @@ int main(int argc, char** argv)
if (igs_filepath != nullptr) {
std::cout << "IGES input file: " << igs_filepath << std::endl;
BmkBRep::readInputIgesShape(igs_filepath);
for (TopExp_Explorer topExp(BmkBRep::inputShape, TopAbs_FACE);
topExp.More();
topExp.Next())
{
const TopoDS_Face& face = TopoDS::Face(topExp.Current());
TopLoc_Location location;
const auto& poly = BRep_Tool::Triangulation(face, location);
if (poly.IsNull() || poly->Triangles().Length() <= 0)
BRepMesh_IncrementalMesh(face, 0.01);
}
std::cout << std::endl << "Meshing done" << std::endl;
}
else if (stp_filepath != nullptr) {
std::cout << "STEP input file: " << stp_filepath << std::endl;
BmkBRep::readInputStepShape(stp_filepath);
}
std::cout << std::endl << "Meshing with linear deflection="
<< linear_deflection
<< " ..." << std::endl;
for (TopExp_Explorer expl(BmkBRep::inputShape, TopAbs_FACE);
expl.More();
expl.Next())
{
const TopoDS_Face& face = TopoDS::Face(expl.Current());
TopLoc_Location location;
const auto& poly = BRep_Tool::Triangulation(face, location);
if (poly.IsNull() || poly->Triangles().Length() <= 0)
BRepMesh_IncrementalMesh(face, linear_deflection);
}
std::cout << std::endl << "Meshing done" << std::endl;
/* Declare benchmarks */
const benchmark_cmp_arg cmp_args[] = {