diff --git a/modules/opencascade/CMakeLists.txt b/modules/opencascade/CMakeLists.txt index 1c15bc43e5..8fc8795d34 100644 --- a/modules/opencascade/CMakeLists.txt +++ b/modules/opencascade/CMakeLists.txt @@ -16,6 +16,7 @@ add_library(sphinxsys_opencascade opencascade/surface_shape.h opencascade/vector.cpp opencascade/vector.h + opencascade/opencascade.h ) target_include_directories(sphinxsys_opencascade PUBLIC $) target_link_libraries(sphinxsys_opencascade PUBLIC sphinxsys_3d) diff --git a/modules/opencascade/opencascade/opencascade.h b/modules/opencascade/opencascade/opencascade.h new file mode 100644 index 0000000000..ac27d2e9f8 --- /dev/null +++ b/modules/opencascade/opencascade/opencascade.h @@ -0,0 +1,44 @@ +/* ------------------------------------------------------------------------- * + * SPHinXsys * + * ------------------------------------------------------------------------- * + * SPHinXsys (pronunciation: s'finksis) is an acronym from Smoothed Particle * + * Hydrodynamics for industrial compleX systems. It provides C++ APIs for * + * physical accurate simulation and aims to model coupled industrial dynamic * + * systems including fluid, solid, multi-body dynamics and beyond with SPH * + * (smoothed particle hydrodynamics), a meshless computational method using * + * particle discretization. * + * * + * SPHinXsys is partially funded by German Research Foundation * + * (Deutsche Forschungsgemeinschaft) DFG HU1527/6-1, HU1527/10-1, * + * HU1527/12-1 and HU1527/12-4. * + * * + * Portions copyright (c) 2017-2023 Technical University of Munich and * + * the authors' affiliations. * + * * + * Licensed under the Apache License, Version 2.0 (the "License"); you may * + * not use this file except in compliance with the License. You may obtain a * + * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. * + * * + * ------------------------------------------------------------------------- */ + + +#ifndef OPENCASCADE_H +#define OPENCASCADE_H + +#ifdef __linux__ +#pragma GCC system_header // for GCC/CLANG +#elif _WIN32 +#pragma warning(push, 0) // for MSVC +#endif + +#include "opencascade/STEPCAFControl_Reader.hxx" +#include"opencascade/TopExp_Explorer.hxx" +#include"opencascade/TopoDS.hxx" +#include"opencascade/BRep_Builder.hxx" +#include"opencascade/GeomAPI_ProjectPointOnSurf.hxx" +#include "opencascade/gp_Pnt.hxx" + +#ifdef _WIN32 +#pragma warning(pop) // for MSVC +#endif +#endif // OPENCASCADE_H \ No newline at end of file diff --git a/modules/opencascade/opencascade/relax_dynamics_surface.cpp b/modules/opencascade/opencascade/relax_dynamics_surface.cpp index 3a53ad459e..83213c404d 100644 --- a/modules/opencascade/opencascade/relax_dynamics_surface.cpp +++ b/modules/opencascade/opencascade/relax_dynamics_surface.cpp @@ -1,12 +1,5 @@ -#include "relax_dynamics.h" -#include "base_particles.hpp" -#include "particle_generator_lattice.h" -#include "level_set_shape.h" -#include "surface_shape.h" #include "relax_dynamics_surface.h" -#include -#include //========================================================================================================// namespace SPH { @@ -15,7 +8,7 @@ namespace SPH { //=================================================================================================// ShapeSurfaceBounding2::ShapeSurfaceBounding2(RealBody &real_body_) - : LocalDynamics(real_body_), RelaxDataDelegateSimple(real_body_), pos_(particles_->pos_) /*, surface_shape_(DynamicCast(this, sph_body_.body_shape_))*/ + : LocalDynamics(real_body_), RelaxDataDelegateSimple(real_body_), pos_(particles_->pos_) { shape_ = real_body_.body_shape_; diff --git a/modules/opencascade/opencascade/relax_dynamics_surface.h b/modules/opencascade/opencascade/relax_dynamics_surface.h index 44bf001ea0..35d4de8855 100644 --- a/modules/opencascade/opencascade/relax_dynamics_surface.h +++ b/modules/opencascade/opencascade/relax_dynamics_surface.h @@ -32,6 +32,7 @@ #include "sphinxsys.h" #include "vector.h" +#include "surface_shape.h" namespace SPH { diff --git a/modules/opencascade/opencascade/surface_shape.cpp b/modules/opencascade/opencascade/surface_shape.cpp index 174253b372..464a34e878 100644 --- a/modules/opencascade/opencascade/surface_shape.cpp +++ b/modules/opencascade/opencascade/surface_shape.cpp @@ -1,12 +1,5 @@ #include "surface_shape.h" -#include -#include -#include -#include -#include -#include - namespace SPH { //=================================================================================================// @@ -15,9 +8,8 @@ Vecd SurfaceShape::findClosestPoint(const Vecd &input_pnt) Vecd closest_pnt; gp_Pnt point1 = EigenToOcct(input_pnt); - gp_Pnt point2; Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Tree; - point2 = GeomAPI_ProjectPointOnSurf(point1, surface_, Algo); + gp_Pnt point2 = GeomAPI_ProjectPointOnSurf(point1, surface_, Algo); closest_pnt[0] = point2.X(); closest_pnt[1] = point2.Y(); closest_pnt[2] = point2.Z(); @@ -30,7 +22,7 @@ bool SurfaceShape::checkContain(const Vecd &pnt, bool BOUNDARY_INCLUDED) { retur BoundingBox SurfaceShape::findBounds() { return BoundingBox(); } //=================================================================================================// -Vecd SurfaceShape::findActualPoint(Standard_Real u, Standard_Real v) +Vecd SurfaceShape::getCartesianPoint(Standard_Real u, Standard_Real v) { gp_Pnt point; Vec3d actual_pnt; @@ -46,6 +38,12 @@ SurfaceShapeSTEP:: SurfaceShapeSTEP(Standard_CString &filepathname, const std::string &shape_name) : SurfaceShape(shape_name) { + if (!std::filesystem::exists(filepathname)) + { + std::cout << "\n Error: the input file:" << filepathname << " is not exists" << std::endl; + std::cout << __FILE__ << ':' << __LINE__ << std::endl; + throw; + } STEPControl_Reader step_reader; step_reader.ReadFile(filepathname); diff --git a/modules/opencascade/opencascade/surface_shape.h b/modules/opencascade/opencascade/surface_shape.h index 424fbbf0e6..021e16c846 100644 --- a/modules/opencascade/opencascade/surface_shape.h +++ b/modules/opencascade/opencascade/surface_shape.h @@ -15,9 +15,7 @@ #include "sphinxsys.h" #include "vector.h" - -#include -#include +#include"opencascade.h" #include #include @@ -27,8 +25,6 @@ namespace fs = std::filesystem; namespace SPH { - - class SurfaceShape : public Shape { public: @@ -36,7 +32,7 @@ namespace SPH : Shape(shape_name){}; virtual bool checkContain(const Vecd &pnt, bool BOUNDARY_INCLUDED = true) override; virtual Vecd findClosestPoint(const Vecd &input_pnt) override; - Vecd findActualPoint(Standard_Real u, Standard_Real v); + Vecd getCartesianPoint(Standard_Real u, Standard_Real v); Handle_Geom_Surface surface_; protected: diff --git a/modules/opencascade/opencascade/vector.h b/modules/opencascade/opencascade/vector.h index 9f83e253fc..f43e8f3ea6 100644 --- a/modules/opencascade/opencascade/vector.h +++ b/modules/opencascade/opencascade/vector.h @@ -29,7 +29,7 @@ #define VECTOR_H #include "base_data_type.h" -#include +#include"opencascade.h" namespace SPH { diff --git a/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp b/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp index 3377cc79f7..369b72eafa 100644 --- a/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp +++ b/modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp @@ -69,24 +69,24 @@ class CylinderParticleGenerator : public SurfaceParticleGenerator for (size_t k = 0; k <= 1 / DELTA1; k++) { Standard_Real u = u1 + k * DELTA1; - points.push_back(a->findActualPoint(u, 0)); + points.push_back(a->getCartesianPoint(u, 0)); } for (size_t k = 0; k <= 1 / DELTA1-1; k++) { Standard_Real v = v1 + k * DELTA1; - points.push_back(a->findActualPoint(0, v)); + points.push_back(a->getCartesianPoint(0, v)); } for (size_t n = 0; n <= 1 / DELTA2 - 2; n++) { Standard_Real u = u2 + n * DELTA2; - points.push_back(a->findActualPoint(u, 1)); + points.push_back(a->getCartesianPoint(u, 1)); } for (size_t n = 0; n <= 1 / DELTA2 - 1; n++) { Standard_Real v = v2 + n * DELTA2; - points.push_back(a->findActualPoint(1, v)); + points.push_back(a->getCartesianPoint(1, v)); } for (size_t k = 0; k <= 8; k++) @@ -99,7 +99,7 @@ class CylinderParticleGenerator : public SurfaceParticleGenerator for (size_t n = 0; n <= 20; n++) { Standard_Real u = u1 + n * UDELTA; - points.push_back(a->findActualPoint(u, v)); + points.push_back(a->getCartesianPoint(u, v)); } }