Skip to content

Commit

Permalink
new after changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanjiajy committed Jul 26, 2023
1 parent d1232ef commit 130c1e2
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 30 deletions.
1 change: 1 addition & 0 deletions modules/opencascade/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/opencascade>)
target_link_libraries(sphinxsys_opencascade PUBLIC sphinxsys_3d)
Expand Down
44 changes: 44 additions & 0 deletions modules/opencascade/opencascade/opencascade.h
Original file line number Diff line number Diff line change
@@ -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
9 changes: 1 addition & 8 deletions modules/opencascade/opencascade/relax_dynamics_surface.cpp
Original file line number Diff line number Diff line change
@@ -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 <opencascade/GeomAPI_ProjectPointOnSurf.hxx>
#include <opencascade/gp_Pnt.hxx>
//========================================================================================================//
namespace SPH
{
Expand All @@ -15,7 +8,7 @@ namespace SPH
{
//=================================================================================================//
ShapeSurfaceBounding2::ShapeSurfaceBounding2(RealBody &real_body_)
: LocalDynamics(real_body_), RelaxDataDelegateSimple(real_body_), pos_(particles_->pos_) /*, surface_shape_(DynamicCast<SurfaceShape>(this, sph_body_.body_shape_))*/
: LocalDynamics(real_body_), RelaxDataDelegateSimple(real_body_), pos_(particles_->pos_)
{
shape_ = real_body_.body_shape_;

Expand Down
1 change: 1 addition & 0 deletions modules/opencascade/opencascade/relax_dynamics_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "sphinxsys.h"
#include "vector.h"
#include "surface_shape.h"

namespace SPH
{
Expand Down
18 changes: 8 additions & 10 deletions modules/opencascade/opencascade/surface_shape.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
#include "surface_shape.h"

#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>

namespace SPH
{
//=================================================================================================//
Expand All @@ -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();
Expand All @@ -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;
Expand All @@ -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);

Expand Down
8 changes: 2 additions & 6 deletions modules/opencascade/opencascade/surface_shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

#include "sphinxsys.h"
#include "vector.h"

#include <opencascade/Standard_TypeDef.hxx>
#include <opencascade/Geom_Surface.hxx>
#include"opencascade.h"

#include <iostream>
#include <string>
Expand All @@ -27,16 +25,14 @@ namespace fs = std::filesystem;

namespace SPH
{


class SurfaceShape : public Shape
{
public:
explicit SurfaceShape(const std::string &shape_name)
: 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:
Expand Down
2 changes: 1 addition & 1 deletion modules/opencascade/opencascade/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define VECTOR_H

#include "base_data_type.h"
#include <opencascade/gp_Pnt.hxx>
#include"opencascade.h"

namespace SPH
{
Expand Down
10 changes: 5 additions & 5 deletions modules/opencascade/tests/test_3d_aortic_valve/aortic_valve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand All @@ -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));
}
}

Expand Down

0 comments on commit 130c1e2

Please sign in to comment.