MeshPart: apply clang format
This commit is contained in:
@@ -27,7 +27,8 @@
|
||||
#include <Base/PyObjectBase.h>
|
||||
|
||||
|
||||
namespace MeshPart {
|
||||
namespace MeshPart
|
||||
{
|
||||
extern PyObject* initModule();
|
||||
}
|
||||
|
||||
@@ -37,9 +38,9 @@ PyMOD_INIT_FUNC(MeshPart)
|
||||
// load dependent module
|
||||
try {
|
||||
Base::Interpreter().loadModule("Part");
|
||||
//Base::Interpreter().loadModule("Mesh");
|
||||
// Base::Interpreter().loadModule("Mesh");
|
||||
}
|
||||
catch(const Base::Exception& e) {
|
||||
catch (const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_ImportError, e.what());
|
||||
PyMOD_Return(nullptr);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <BRepBuilderAPI_MakePolygon.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
#include <BRepBuilderAPI_MakePolygon.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
@@ -33,17 +33,18 @@
|
||||
#include <Base/PyWrapParseTupleAndKeywords.h>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Base/VectorPy.h>
|
||||
#include <Mod/Mesh/App/Core/Algorithm.h>
|
||||
#include <Mod/Mesh/App/Core/MeshKernel.h>
|
||||
#include <Mod/Mesh/App/MeshPy.h>
|
||||
#include <Mod/Part/App/TopoShapeEdgePy.h>
|
||||
#include <Mod/Part/App/TopoShapePy.h>
|
||||
#include <Mod/Part/App/TopoShapeWirePy.h>
|
||||
#include <Mod/Mesh/App/MeshPy.h>
|
||||
#include <Mod/Mesh/App/Core/Algorithm.h>
|
||||
#include <Mod/Mesh/App/Core/MeshKernel.h>
|
||||
|
||||
#include "MeshAlgos.h"
|
||||
#include "Mesher.h"
|
||||
|
||||
|
||||
// clang-format off
|
||||
namespace MeshPart {
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
{
|
||||
@@ -639,3 +640,4 @@ PyObject* initModule()
|
||||
}
|
||||
|
||||
} // namespace MeshPart
|
||||
// clang-format on
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,7 @@
|
||||
#define _CurveProjector_h_
|
||||
|
||||
#ifdef FC_USE_GTS
|
||||
# include <gts.h>
|
||||
#include <gts.h>
|
||||
#endif
|
||||
|
||||
#include <TopoDS_Edge.hxx>
|
||||
@@ -38,10 +38,10 @@ namespace MeshCore
|
||||
class MeshKernel;
|
||||
class MeshGeomFacet;
|
||||
class MeshFacetGrid;
|
||||
}
|
||||
}// namespace MeshCore
|
||||
|
||||
using MeshCore::MeshKernel;
|
||||
using MeshCore::MeshGeomFacet;
|
||||
using MeshCore::MeshKernel;
|
||||
|
||||
namespace MeshPart
|
||||
{
|
||||
@@ -51,35 +51,39 @@ namespace MeshPart
|
||||
class MeshPartExport CurveProjector
|
||||
{
|
||||
public:
|
||||
CurveProjector(const TopoDS_Shape &aShape, const MeshKernel &pMesh);
|
||||
virtual ~CurveProjector() = default;
|
||||
CurveProjector(const TopoDS_Shape& aShape, const MeshKernel& pMesh);
|
||||
virtual ~CurveProjector() = default;
|
||||
|
||||
struct FaceSplitEdge
|
||||
{
|
||||
MeshCore::FacetIndex ulFaceIndex;
|
||||
Base::Vector3f p1,p2;
|
||||
};
|
||||
struct FaceSplitEdge
|
||||
{
|
||||
MeshCore::FacetIndex ulFaceIndex;
|
||||
Base::Vector3f p1, p2;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct TopoDSLess {
|
||||
bool operator()(const T& x, const T& y) const {
|
||||
return x.HashCode(INT_MAX-1) < y.HashCode(INT_MAX-1);
|
||||
template<class T>
|
||||
struct TopoDSLess
|
||||
{
|
||||
bool operator()(const T& x, const T& y) const
|
||||
{
|
||||
return x.HashCode(INT_MAX - 1) < y.HashCode(INT_MAX - 1);
|
||||
}
|
||||
};
|
||||
|
||||
using result_type = std::map<TopoDS_Edge, std::vector<FaceSplitEdge>, TopoDSLess<TopoDS_Edge>>;
|
||||
|
||||
|
||||
result_type& result()
|
||||
{
|
||||
return mvEdgeSplitPoints;
|
||||
}
|
||||
};
|
||||
|
||||
using result_type = std::map<TopoDS_Edge, std::vector<FaceSplitEdge>,TopoDSLess<TopoDS_Edge> >;
|
||||
|
||||
|
||||
result_type &result() {return mvEdgeSplitPoints;}
|
||||
|
||||
void writeIntersectionPointsToFile(const char *name="export_pts.asc");
|
||||
void writeIntersectionPointsToFile(const char* name = "export_pts.asc");
|
||||
|
||||
protected:
|
||||
virtual void Do()=0;
|
||||
const TopoDS_Shape &_Shape;
|
||||
const MeshKernel &_Mesh;
|
||||
result_type mvEdgeSplitPoints;
|
||||
|
||||
virtual void Do() = 0;
|
||||
const TopoDS_Shape& _Shape;
|
||||
const MeshKernel& _Mesh;
|
||||
result_type mvEdgeSplitPoints;
|
||||
};
|
||||
|
||||
|
||||
@@ -88,44 +92,48 @@ protected:
|
||||
class MeshPartExport CurveProjectorShape: public CurveProjector
|
||||
{
|
||||
public:
|
||||
CurveProjectorShape(const TopoDS_Shape &aShape, const MeshKernel &pMesh);
|
||||
~CurveProjectorShape() override = default;
|
||||
CurveProjectorShape(const TopoDS_Shape& aShape, const MeshKernel& pMesh);
|
||||
~CurveProjectorShape() override = default;
|
||||
|
||||
void projectCurve(const TopoDS_Edge& aEdge,
|
||||
std::vector<FaceSplitEdge> &vSplitEdges);
|
||||
|
||||
bool findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,MeshCore::FacetIndex &FaceIndex);
|
||||
void projectCurve(const TopoDS_Edge& aEdge, std::vector<FaceSplitEdge>& vSplitEdges);
|
||||
|
||||
bool findStartPoint(const MeshKernel& MeshK,
|
||||
const Base::Vector3f& Pnt,
|
||||
Base::Vector3f& Rslt,
|
||||
MeshCore::FacetIndex& FaceIndex);
|
||||
|
||||
|
||||
protected:
|
||||
void Do() override;
|
||||
void Do() override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Project by projecting a sampled curve to the mesh
|
||||
*/
|
||||
class MeshPartExport CurveProjectorSimple: public CurveProjector
|
||||
{
|
||||
public:
|
||||
CurveProjectorSimple(const TopoDS_Shape &aShape, const MeshKernel &pMesh);
|
||||
~CurveProjectorSimple() override = default;
|
||||
CurveProjectorSimple(const TopoDS_Shape& aShape, const MeshKernel& pMesh);
|
||||
~CurveProjectorSimple() override = default;
|
||||
|
||||
/// helper to discredicice a Edge...
|
||||
void GetSampledCurves( const TopoDS_Edge& aEdge, std::vector<Base::Vector3f>& rclPoints, unsigned long ulNbOfPoints = 30);
|
||||
/// helper to discredicice a Edge...
|
||||
void GetSampledCurves(const TopoDS_Edge& aEdge,
|
||||
std::vector<Base::Vector3f>& rclPoints,
|
||||
unsigned long ulNbOfPoints = 30);
|
||||
|
||||
|
||||
void projectCurve(const TopoDS_Edge& aEdge,
|
||||
const std::vector<Base::Vector3f> &rclPoints,
|
||||
std::vector<FaceSplitEdge> &vSplitEdges);
|
||||
|
||||
bool findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,MeshCore::FacetIndex &FaceIndex);
|
||||
void projectCurve(const TopoDS_Edge& aEdge,
|
||||
const std::vector<Base::Vector3f>& rclPoints,
|
||||
std::vector<FaceSplitEdge>& vSplitEdges);
|
||||
|
||||
bool findStartPoint(const MeshKernel& MeshK,
|
||||
const Base::Vector3f& Pnt,
|
||||
Base::Vector3f& Rslt,
|
||||
MeshCore::FacetIndex& FaceIndex);
|
||||
|
||||
|
||||
protected:
|
||||
void Do() override;
|
||||
void Do() override;
|
||||
};
|
||||
|
||||
/** Project by projecting a sampled curve to the mesh
|
||||
@@ -133,22 +141,25 @@ protected:
|
||||
class MeshPartExport CurveProjectorWithToolMesh: public CurveProjector
|
||||
{
|
||||
public:
|
||||
struct LineSeg {
|
||||
Base::Vector3f p;
|
||||
Base::Vector3f n;
|
||||
};
|
||||
struct LineSeg
|
||||
{
|
||||
Base::Vector3f p;
|
||||
Base::Vector3f n;
|
||||
};
|
||||
|
||||
CurveProjectorWithToolMesh(const TopoDS_Shape &aShape, const MeshKernel &pMesh,MeshKernel &rToolMesh);
|
||||
~CurveProjectorWithToolMesh() override = default;
|
||||
CurveProjectorWithToolMesh(const TopoDS_Shape& aShape,
|
||||
const MeshKernel& pMesh,
|
||||
MeshKernel& rToolMesh);
|
||||
~CurveProjectorWithToolMesh() override = default;
|
||||
|
||||
|
||||
void makeToolMesh(const TopoDS_Edge& aEdge,std::vector<MeshGeomFacet> &cVAry );
|
||||
void makeToolMesh(const TopoDS_Edge& aEdge, std::vector<MeshGeomFacet>& cVAry);
|
||||
|
||||
|
||||
MeshKernel &ToolMesh;
|
||||
MeshKernel& ToolMesh;
|
||||
|
||||
protected:
|
||||
void Do() override;
|
||||
void Do() override;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -162,7 +173,7 @@ public:
|
||||
struct SplitEdge
|
||||
{
|
||||
MeshCore::PointIndex uE0, uE1; /**< start and endpoint of an edge */
|
||||
Base::Vector3f cPt; /**< Point on edge (\a uE0, \a uE1) */
|
||||
Base::Vector3f cPt; /**< Point on edge (\a uE0, \a uE1) */
|
||||
};
|
||||
struct Edge
|
||||
{
|
||||
@@ -184,49 +195,66 @@ public:
|
||||
* @param dir
|
||||
* @param parameters
|
||||
*/
|
||||
void findSectionParameters(const TopoDS_Edge& edge, const Base::Vector3f& dir, std::set<double>& parameters) const;
|
||||
void discretize(const TopoDS_Edge& aEdge, std::vector<Base::Vector3f>& polyline, std::size_t minPoints=2) const;
|
||||
void findSectionParameters(const TopoDS_Edge& edge,
|
||||
const Base::Vector3f& dir,
|
||||
std::set<double>& parameters) const;
|
||||
void discretize(const TopoDS_Edge& aEdge,
|
||||
std::vector<Base::Vector3f>& polyline,
|
||||
std::size_t minPoints = 2) const;
|
||||
/**
|
||||
* Searches all edges that intersect with the projected curve \a aShape. Therefore \a aShape must
|
||||
* contain shapes of type TopoDS_Edge, other shape types are ignored. A possible solution is
|
||||
* taken if the distance between the curve point and the projected point is <= \a fMaxDist.
|
||||
* Searches all edges that intersect with the projected curve \a aShape. Therefore \a aShape
|
||||
* must contain shapes of type TopoDS_Edge, other shape types are ignored. A possible solution
|
||||
* is taken if the distance between the curve point and the projected point is <= \a fMaxDist.
|
||||
*/
|
||||
void projectToMesh (const TopoDS_Shape &aShape, float fMaxDist, std::vector<PolyLine>& rPolyLines) const;
|
||||
void projectToMesh(const TopoDS_Shape& aShape,
|
||||
float fMaxDist,
|
||||
std::vector<PolyLine>& rPolyLines) const;
|
||||
/**
|
||||
* @brief projectOnMesh
|
||||
* Projects the given points onto the mesh along a given direction. The points can can be projected
|
||||
* will be saved to \a pointsOut
|
||||
* Projects the given points onto the mesh along a given direction. The points can can be
|
||||
* projected will be saved to \a pointsOut
|
||||
* @brief projectOnMesh
|
||||
* @param pointsIn
|
||||
* @param dir
|
||||
* @param tolerance
|
||||
* @param pointsOut
|
||||
*/
|
||||
void projectOnMesh(const std::vector<Base::Vector3f>& pointsIn, const Base::Vector3f& dir,
|
||||
float tolerance, std::vector<Base::Vector3f>& pointsOut) const;
|
||||
void projectOnMesh(const std::vector<Base::Vector3f>& pointsIn,
|
||||
const Base::Vector3f& dir,
|
||||
float tolerance,
|
||||
std::vector<Base::Vector3f>& pointsOut) const;
|
||||
/**
|
||||
* Project all edges of the shape onto the mesh using parallel projection.
|
||||
*/
|
||||
void projectParallelToMesh (const TopoDS_Shape &aShape, const Base::Vector3f& dir, std::vector<PolyLine>& rPolyLines) const;
|
||||
void projectParallelToMesh(const TopoDS_Shape& aShape,
|
||||
const Base::Vector3f& dir,
|
||||
std::vector<PolyLine>& rPolyLines) const;
|
||||
/**
|
||||
* Project all polylines onto the mesh using parallel projection.
|
||||
*/
|
||||
void projectParallelToMesh (const std::vector<PolyLine>& aEdges, const Base::Vector3f& dir, std::vector<PolyLine>& rPolyLines) const;
|
||||
void projectParallelToMesh(const std::vector<PolyLine>& aEdges,
|
||||
const Base::Vector3f& dir,
|
||||
std::vector<PolyLine>& rPolyLines) const;
|
||||
/**
|
||||
* Cuts the mesh at the curve defined by \a aShape. This method call @ref projectToMesh() to get the
|
||||
* split the facet at the found points. @see projectToMesh() for more details.
|
||||
* Cuts the mesh at the curve defined by \a aShape. This method call @ref projectToMesh() to get
|
||||
* the split the facet at the found points. @see projectToMesh() for more details.
|
||||
*/
|
||||
void splitMeshByShape (const TopoDS_Shape &aShape, float fMaxDist) const;
|
||||
void splitMeshByShape(const TopoDS_Shape& aShape, float fMaxDist) const;
|
||||
|
||||
protected:
|
||||
void projectEdgeToEdge(const TopoDS_Edge &aCurve, float fMaxDist, const MeshCore::MeshFacetGrid& rGrid,
|
||||
void projectEdgeToEdge(const TopoDS_Edge& aCurve,
|
||||
float fMaxDist,
|
||||
const MeshCore::MeshFacetGrid& rGrid,
|
||||
std::vector<SplitEdge>& rSplitEdges) const;
|
||||
bool findIntersection(const Edge&, const Edge&, const Base::Vector3f& dir, Base::Vector3f& res) const;
|
||||
bool findIntersection(const Edge&,
|
||||
const Edge&,
|
||||
const Base::Vector3f& dir,
|
||||
Base::Vector3f& res) const;
|
||||
|
||||
private:
|
||||
const MeshKernel& _rcMesh;
|
||||
};
|
||||
|
||||
} // namespace MeshPart
|
||||
}// namespace MeshPart
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# ifdef FC_OS_LINUX
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
#ifdef FC_OS_LINUX
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Builder3D.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Mod/Mesh/App/Core/Evaluation.h>
|
||||
#include <Mod/Mesh/App/Core/Iterator.h>
|
||||
#include <Mod/Mesh/App/Core/MeshKernel.h>
|
||||
@@ -43,66 +43,74 @@ using namespace MeshCore;
|
||||
|
||||
void MeshAlgos::offset(MeshCore::MeshKernel* Mesh, float fSize)
|
||||
{
|
||||
std::vector<Base::Vector3f> normals = Mesh->CalcVertexNormals();
|
||||
std::vector<Base::Vector3f> normals = Mesh->CalcVertexNormals();
|
||||
|
||||
unsigned int i = 0;
|
||||
// go through all the Vertex normals
|
||||
for(std::vector<Base::Vector3f>::iterator It= normals.begin();It != normals.end();++It,i++)
|
||||
// and move each mesh point in the normal direction
|
||||
Mesh->MovePoint(i,It->Normalize() * fSize);
|
||||
Mesh->RecalcBoundBox();
|
||||
unsigned int i = 0;
|
||||
// go through all the Vertex normals
|
||||
for (std::vector<Base::Vector3f>::iterator It = normals.begin(); It != normals.end();
|
||||
++It, i++) {
|
||||
// and move each mesh point in the normal direction
|
||||
Mesh->MovePoint(i, It->Normalize() * fSize);
|
||||
}
|
||||
Mesh->RecalcBoundBox();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MeshAlgos::offsetSpecial2(MeshCore::MeshKernel* Mesh, float fSize)
|
||||
{
|
||||
Base::Builder3D builder;
|
||||
std::vector<Base::Vector3f> PointNormals= Mesh->CalcVertexNormals();
|
||||
std::vector<Base::Vector3f> PointNormals = Mesh->CalcVertexNormals();
|
||||
std::vector<Base::Vector3f> FaceNormals;
|
||||
std::set<MeshCore::FacetIndex> fliped;
|
||||
|
||||
MeshFacetIterator it(*Mesh);
|
||||
for ( it.Init(); it.More(); it.Next() )
|
||||
for (it.Init(); it.More(); it.Next()) {
|
||||
FaceNormals.push_back(it->GetNormal().Normalize());
|
||||
}
|
||||
|
||||
unsigned int i = 0;
|
||||
|
||||
// go through all the Vertex normals
|
||||
for(std::vector<Base::Vector3f>::iterator It= PointNormals.begin();It != PointNormals.end();++It,i++) {
|
||||
Base::Line3f line{Mesh->GetPoint(i), Mesh->GetPoint(i) + It->Normalize() * fSize};
|
||||
for (std::vector<Base::Vector3f>::iterator It = PointNormals.begin(); It != PointNormals.end();
|
||||
++It, i++) {
|
||||
Base::Line3f line {Mesh->GetPoint(i), Mesh->GetPoint(i) + It->Normalize() * fSize};
|
||||
Base::DrawStyle drawStyle;
|
||||
builder.addNode(Base::LineItem{line, drawStyle});
|
||||
builder.addNode(Base::LineItem {line, drawStyle});
|
||||
// and move each mesh point in the normal direction
|
||||
Mesh->MovePoint(i,It->Normalize() * fSize);
|
||||
Mesh->MovePoint(i, It->Normalize() * fSize);
|
||||
}
|
||||
Mesh->RecalcBoundBox();
|
||||
|
||||
MeshTopoAlgorithm alg(*Mesh);
|
||||
|
||||
for(int l= 0; l<1 ;l++){
|
||||
for ( it.Init(),i=0; it.More(); it.Next(),i++ )
|
||||
{
|
||||
if(it->IsFlag(MeshFacet::INVALID))
|
||||
for (int l = 0; l < 1; l++) {
|
||||
for (it.Init(), i = 0; it.More(); it.Next(), i++) {
|
||||
if (it->IsFlag(MeshFacet::INVALID)) {
|
||||
continue;
|
||||
}
|
||||
// calculate the angle between them
|
||||
float angle = acos((FaceNormals[i] * it->GetNormal()) / (it->GetNormal().Length() * FaceNormals[i].Length()));
|
||||
if (angle > 1.6){
|
||||
float angle = acos((FaceNormals[i] * it->GetNormal())
|
||||
/ (it->GetNormal().Length() * FaceNormals[i].Length()));
|
||||
if (angle > 1.6) {
|
||||
Base::DrawStyle drawStyle;
|
||||
drawStyle.pointSize = 4.0F;
|
||||
Base::PointItem item{it->GetGravityPoint(), drawStyle, Base::ColorRGB{1.0F, 0.0F, 0.0F}};
|
||||
Base::PointItem item {it->GetGravityPoint(),
|
||||
drawStyle,
|
||||
Base::ColorRGB {1.0F, 0.0F, 0.0F}};
|
||||
builder.addNode(item);
|
||||
fliped.insert(it.Position());
|
||||
}
|
||||
}
|
||||
|
||||
// if there are no flipped triangles -> stop
|
||||
//int f =fliped.size();
|
||||
if(fliped.empty())
|
||||
// int f =fliped.size();
|
||||
if (fliped.empty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
for(MeshCore::FacetIndex It : fliped)
|
||||
for (MeshCore::FacetIndex It : fliped) {
|
||||
alg.CollapseFacet(It);
|
||||
}
|
||||
fliped.clear();
|
||||
}
|
||||
|
||||
@@ -110,56 +118,59 @@ void MeshAlgos::offsetSpecial2(MeshCore::MeshKernel* Mesh, float fSize)
|
||||
|
||||
// search for intersected facets
|
||||
MeshCore::MeshEvalSelfIntersection eval(*Mesh);
|
||||
std::vector<std::pair<MeshCore::FacetIndex, MeshCore::FacetIndex> > faces;
|
||||
std::vector<std::pair<MeshCore::FacetIndex, MeshCore::FacetIndex>> faces;
|
||||
eval.GetIntersections(faces);
|
||||
|
||||
|
||||
builder.saveToLog();
|
||||
|
||||
}
|
||||
|
||||
void MeshAlgos::offsetSpecial(MeshCore::MeshKernel* Mesh, float fSize, float zmax, float zmin)
|
||||
{
|
||||
std::vector<Base::Vector3f> normals = Mesh->CalcVertexNormals();
|
||||
std::vector<Base::Vector3f> normals = Mesh->CalcVertexNormals();
|
||||
|
||||
unsigned int i = 0;
|
||||
// go through all the Vertex normals
|
||||
for(std::vector<Base::Vector3f>::iterator It= normals.begin();It != normals.end();++It,i++)
|
||||
{
|
||||
Base::Vector3f Pnt = Mesh->GetPoint(i);
|
||||
unsigned int i = 0;
|
||||
// go through all the Vertex normals
|
||||
for (std::vector<Base::Vector3f>::iterator It = normals.begin(); It != normals.end();
|
||||
++It, i++) {
|
||||
Base::Vector3f Pnt = Mesh->GetPoint(i);
|
||||
|
||||
if(Pnt.z < zmax && Pnt.z > zmin)
|
||||
{
|
||||
Pnt.z = 0;
|
||||
Mesh->MovePoint(i,Pnt.Normalize() * fSize);
|
||||
}else
|
||||
// and move each mesh point in the normal direction
|
||||
Mesh->MovePoint(i,It->Normalize() * fSize);
|
||||
}
|
||||
if (Pnt.z < zmax && Pnt.z > zmin) {
|
||||
Pnt.z = 0;
|
||||
Mesh->MovePoint(i, Pnt.Normalize() * fSize);
|
||||
}
|
||||
else {
|
||||
// and move each mesh point in the normal direction
|
||||
Mesh->MovePoint(i, It->Normalize() * fSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MeshAlgos::coarsen(MeshCore::MeshKernel* /*Mesh*/, float /*f*/)
|
||||
{
|
||||
#ifdef FC_USE_GTS
|
||||
GtsSurface * surface;
|
||||
GtsSurface* surface;
|
||||
|
||||
// create a GTS surface
|
||||
surface = MeshAlgos::createGTSSurface(Mesh);
|
||||
// create a GTS surface
|
||||
surface = MeshAlgos::createGTSSurface(Mesh);
|
||||
|
||||
Mesh->Clear();
|
||||
Mesh->Clear();
|
||||
|
||||
guint stop_number=100000;
|
||||
gdouble fold = 3.1415 / 180.;
|
||||
guint stop_number = 100000;
|
||||
gdouble fold = 3.1415 / 180.;
|
||||
|
||||
gts_surface_coarsen (surface,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
(GtsStopFunc)gts_coarsen_stop_number,
|
||||
&stop_number, fold);
|
||||
gts_surface_coarsen(surface,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(GtsStopFunc)gts_coarsen_stop_number,
|
||||
&stop_number,
|
||||
fold);
|
||||
|
||||
// get the standard mesh
|
||||
fillMeshFromGTSSurface(Mesh,surface);
|
||||
// get the standard mesh
|
||||
fillMeshFromGTSSurface(Mesh, surface);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -170,143 +181,142 @@ MeshCore::MeshKernel* MeshAlgos::boolean(MeshCore::MeshKernel* pMesh1,
|
||||
int /*Type*/)
|
||||
{
|
||||
#ifdef FC_USE_GTS
|
||||
GtsSurface * s1, * s2, * s3;
|
||||
GtsSurfaceInter * si;
|
||||
GNode * tree1, * tree2;
|
||||
gboolean check_self_intersection = false;
|
||||
gboolean closed = true, is_open1, is_open2;
|
||||
GtsSurface *s1, *s2, *s3;
|
||||
GtsSurfaceInter* si;
|
||||
GNode *tree1, *tree2;
|
||||
gboolean check_self_intersection = false;
|
||||
gboolean closed = true, is_open1, is_open2;
|
||||
|
||||
|
||||
// create a GTS surface
|
||||
s1 = MeshAlgos::createGTSSurface(pMesh1);
|
||||
s2 = MeshAlgos::createGTSSurface(pMesh2);
|
||||
// create a GTS surface
|
||||
s1 = MeshAlgos::createGTSSurface(pMesh1);
|
||||
s2 = MeshAlgos::createGTSSurface(pMesh2);
|
||||
|
||||
// clear the mesh (memory)
|
||||
//Mesh1.clear();
|
||||
//Mesh2.clear();
|
||||
// clear the mesh (memory)
|
||||
// Mesh1.clear();
|
||||
// Mesh2.clear();
|
||||
|
||||
/* check that the surfaces are orientable manifolds */
|
||||
if (!gts_surface_is_orientable (s1)) {
|
||||
gts_object_destroy (GTS_OBJECT (s1));
|
||||
gts_object_destroy (GTS_OBJECT (s2));
|
||||
throw std::runtime_error("surface 1 is not an orientable manifold\n");
|
||||
}
|
||||
if (!gts_surface_is_orientable (s2)) {
|
||||
gts_object_destroy (GTS_OBJECT (s1));
|
||||
gts_object_destroy (GTS_OBJECT (s2));
|
||||
throw std::runtime_error("surface 2 is not an orientable manifold\n");
|
||||
}
|
||||
|
||||
/* check that the surfaces are not self-intersecting */
|
||||
if (check_self_intersection) {
|
||||
GtsSurface * self_intersects;
|
||||
|
||||
self_intersects = gts_surface_is_self_intersecting (s1);
|
||||
if (self_intersects != NULL) {
|
||||
// if (verbose)
|
||||
// gts_surface_print_stats (self_intersects, stderr);
|
||||
// gts_surface_write (self_intersects, stdout);
|
||||
gts_object_destroy (GTS_OBJECT (self_intersects));
|
||||
gts_object_destroy (GTS_OBJECT (s1));
|
||||
gts_object_destroy (GTS_OBJECT (s2));
|
||||
throw std::runtime_error("surface is self-intersecting\n");
|
||||
/* check that the surfaces are orientable manifolds */
|
||||
if (!gts_surface_is_orientable(s1)) {
|
||||
gts_object_destroy(GTS_OBJECT(s1));
|
||||
gts_object_destroy(GTS_OBJECT(s2));
|
||||
throw std::runtime_error("surface 1 is not an orientable manifold\n");
|
||||
}
|
||||
self_intersects = gts_surface_is_self_intersecting (s2);
|
||||
if (self_intersects != NULL) {
|
||||
// if (verbose)
|
||||
// gts_surface_print_stats (self_intersects, stderr);
|
||||
// gts_surface_write (self_intersects, stdout);
|
||||
gts_object_destroy (GTS_OBJECT (self_intersects));
|
||||
gts_object_destroy (GTS_OBJECT (s1));
|
||||
gts_object_destroy (GTS_OBJECT (s2));
|
||||
throw std::runtime_error("surface is self-intersecting\n");
|
||||
if (!gts_surface_is_orientable(s2)) {
|
||||
gts_object_destroy(GTS_OBJECT(s1));
|
||||
gts_object_destroy(GTS_OBJECT(s2));
|
||||
throw std::runtime_error("surface 2 is not an orientable manifold\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* build bounding box tree for first surface */
|
||||
tree1 = gts_bb_tree_surface (s1);
|
||||
is_open1 = gts_surface_volume (s1) < 0. ? true : false;
|
||||
/* check that the surfaces are not self-intersecting */
|
||||
if (check_self_intersection) {
|
||||
GtsSurface* self_intersects;
|
||||
|
||||
/* build bounding box tree for second surface */
|
||||
tree2 = gts_bb_tree_surface (s2);
|
||||
is_open2 = gts_surface_volume (s2) < 0. ? true : false;
|
||||
|
||||
si = gts_surface_inter_new (gts_surface_inter_class (),
|
||||
s1, s2, tree1, tree2, is_open1, is_open2);
|
||||
g_assert (gts_surface_inter_check (si, &closed));
|
||||
if (!closed) {
|
||||
gts_object_destroy (GTS_OBJECT (s1));
|
||||
gts_object_destroy (GTS_OBJECT (s2));
|
||||
gts_bb_tree_destroy (tree1, true);
|
||||
gts_bb_tree_destroy (tree2, true);
|
||||
throw"the intersection of 1 and 2 is not a closed curve\n";
|
||||
}
|
||||
|
||||
s3 = gts_surface_new (gts_surface_class (),
|
||||
gts_face_class (),
|
||||
gts_edge_class (),
|
||||
gts_vertex_class ());
|
||||
if (Type==0) { // union
|
||||
gts_surface_inter_boolean (si, s3, GTS_1_OUT_2);
|
||||
gts_surface_inter_boolean (si, s3, GTS_2_OUT_1);
|
||||
}
|
||||
else if (Type==1) { // inter
|
||||
gts_surface_inter_boolean (si, s3, GTS_1_IN_2);
|
||||
gts_surface_inter_boolean (si, s3, GTS_2_IN_1);
|
||||
}
|
||||
else if (Type==2) { //diff
|
||||
gts_surface_inter_boolean (si, s3, GTS_1_OUT_2);
|
||||
gts_surface_inter_boolean (si, s3, GTS_2_IN_1);
|
||||
gts_surface_foreach_face (si->s2, (GtsFunc) gts_triangle_revert, NULL);
|
||||
gts_surface_foreach_face (s2, (GtsFunc) gts_triangle_revert, NULL);
|
||||
}
|
||||
else if (Type==3) { // cut inner
|
||||
gts_surface_inter_boolean (si, s3, GTS_1_IN_2);
|
||||
}
|
||||
else if (Type==4) { // cut outer
|
||||
gts_surface_inter_boolean (si, s3, GTS_1_OUT_2);
|
||||
}
|
||||
|
||||
// check that the resulting surface is not self-intersecting
|
||||
if (check_self_intersection) {
|
||||
GtsSurface * self_intersects;
|
||||
|
||||
self_intersects = gts_surface_is_self_intersecting (s3);
|
||||
if (self_intersects != NULL) {
|
||||
// if (verbose)
|
||||
// gts_surface_print_stats (self_intersects, stderr);
|
||||
// gts_surface_write (self_intersects, stdout);
|
||||
gts_object_destroy (GTS_OBJECT (self_intersects));
|
||||
gts_object_destroy (GTS_OBJECT (s1));
|
||||
gts_object_destroy (GTS_OBJECT (s2));
|
||||
gts_object_destroy (GTS_OBJECT (s3));
|
||||
gts_object_destroy (GTS_OBJECT (si));
|
||||
gts_bb_tree_destroy (tree1, true);
|
||||
gts_bb_tree_destroy (tree2, true);
|
||||
throw std::runtime_error("the resulting surface is self-intersecting\n");
|
||||
self_intersects = gts_surface_is_self_intersecting(s1);
|
||||
if (self_intersects != NULL) {
|
||||
// if (verbose)
|
||||
// gts_surface_print_stats (self_intersects, stderr);
|
||||
// gts_surface_write (self_intersects, stdout);
|
||||
gts_object_destroy(GTS_OBJECT(self_intersects));
|
||||
gts_object_destroy(GTS_OBJECT(s1));
|
||||
gts_object_destroy(GTS_OBJECT(s2));
|
||||
throw std::runtime_error("surface is self-intersecting\n");
|
||||
}
|
||||
self_intersects = gts_surface_is_self_intersecting(s2);
|
||||
if (self_intersects != NULL) {
|
||||
// if (verbose)
|
||||
// gts_surface_print_stats (self_intersects, stderr);
|
||||
// gts_surface_write (self_intersects, stdout);
|
||||
gts_object_destroy(GTS_OBJECT(self_intersects));
|
||||
gts_object_destroy(GTS_OBJECT(s1));
|
||||
gts_object_destroy(GTS_OBJECT(s2));
|
||||
throw std::runtime_error("surface is self-intersecting\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
// display summary information about the resulting surface
|
||||
// if (verbose)
|
||||
// gts_surface_print_stats (s3, stderr);
|
||||
// write resulting surface to standard output
|
||||
|
||||
// get the standard mesh
|
||||
fillMeshFromGTSSurface(pResult,s3);
|
||||
/* build bounding box tree for first surface */
|
||||
tree1 = gts_bb_tree_surface(s1);
|
||||
is_open1 = gts_surface_volume(s1) < 0. ? true : false;
|
||||
|
||||
/* build bounding box tree for second surface */
|
||||
tree2 = gts_bb_tree_surface(s2);
|
||||
is_open2 = gts_surface_volume(s2) < 0. ? true : false;
|
||||
|
||||
si = gts_surface_inter_new(gts_surface_inter_class(), s1, s2, tree1, tree2, is_open1, is_open2);
|
||||
g_assert(gts_surface_inter_check(si, &closed));
|
||||
if (!closed) {
|
||||
gts_object_destroy(GTS_OBJECT(s1));
|
||||
gts_object_destroy(GTS_OBJECT(s2));
|
||||
gts_bb_tree_destroy(tree1, true);
|
||||
gts_bb_tree_destroy(tree2, true);
|
||||
throw "the intersection of 1 and 2 is not a closed curve\n";
|
||||
}
|
||||
|
||||
s3 = gts_surface_new(gts_surface_class(),
|
||||
gts_face_class(),
|
||||
gts_edge_class(),
|
||||
gts_vertex_class());
|
||||
if (Type == 0) {// union
|
||||
gts_surface_inter_boolean(si, s3, GTS_1_OUT_2);
|
||||
gts_surface_inter_boolean(si, s3, GTS_2_OUT_1);
|
||||
}
|
||||
else if (Type == 1) {// inter
|
||||
gts_surface_inter_boolean(si, s3, GTS_1_IN_2);
|
||||
gts_surface_inter_boolean(si, s3, GTS_2_IN_1);
|
||||
}
|
||||
else if (Type == 2) {// diff
|
||||
gts_surface_inter_boolean(si, s3, GTS_1_OUT_2);
|
||||
gts_surface_inter_boolean(si, s3, GTS_2_IN_1);
|
||||
gts_surface_foreach_face(si->s2, (GtsFunc)gts_triangle_revert, NULL);
|
||||
gts_surface_foreach_face(s2, (GtsFunc)gts_triangle_revert, NULL);
|
||||
}
|
||||
else if (Type == 3) {// cut inner
|
||||
gts_surface_inter_boolean(si, s3, GTS_1_IN_2);
|
||||
}
|
||||
else if (Type == 4) {// cut outer
|
||||
gts_surface_inter_boolean(si, s3, GTS_1_OUT_2);
|
||||
}
|
||||
|
||||
// check that the resulting surface is not self-intersecting
|
||||
if (check_self_intersection) {
|
||||
GtsSurface* self_intersects;
|
||||
|
||||
self_intersects = gts_surface_is_self_intersecting(s3);
|
||||
if (self_intersects != NULL) {
|
||||
// if (verbose)
|
||||
// gts_surface_print_stats (self_intersects, stderr);
|
||||
// gts_surface_write (self_intersects, stdout);
|
||||
gts_object_destroy(GTS_OBJECT(self_intersects));
|
||||
gts_object_destroy(GTS_OBJECT(s1));
|
||||
gts_object_destroy(GTS_OBJECT(s2));
|
||||
gts_object_destroy(GTS_OBJECT(s3));
|
||||
gts_object_destroy(GTS_OBJECT(si));
|
||||
gts_bb_tree_destroy(tree1, true);
|
||||
gts_bb_tree_destroy(tree2, true);
|
||||
throw std::runtime_error("the resulting surface is self-intersecting\n");
|
||||
}
|
||||
}
|
||||
// display summary information about the resulting surface
|
||||
// if (verbose)
|
||||
// gts_surface_print_stats (s3, stderr);
|
||||
// write resulting surface to standard output
|
||||
|
||||
// get the standard mesh
|
||||
fillMeshFromGTSSurface(pResult, s3);
|
||||
|
||||
|
||||
// destroy surfaces
|
||||
gts_object_destroy (GTS_OBJECT (s1));
|
||||
gts_object_destroy (GTS_OBJECT (s2));
|
||||
// gts_object_destroy (GTS_OBJECT (s3));
|
||||
// gts_object_destroy (GTS_OBJECT (si));
|
||||
// destroy surfaces
|
||||
gts_object_destroy(GTS_OBJECT(s1));
|
||||
gts_object_destroy(GTS_OBJECT(s2));
|
||||
// gts_object_destroy (GTS_OBJECT (s3));
|
||||
// gts_object_destroy (GTS_OBJECT (si));
|
||||
|
||||
// destroy bounding box trees (including bounding boxes)
|
||||
// gts_bb_tree_destroy (tree1, true);
|
||||
// gts_bb_tree_destroy (tree2, true);
|
||||
// destroy bounding box trees (including bounding boxes)
|
||||
// gts_bb_tree_destroy (tree1, true);
|
||||
// gts_bb_tree_destroy (tree2, true);
|
||||
|
||||
#endif
|
||||
return pMesh1;
|
||||
return pMesh1;
|
||||
}
|
||||
|
||||
|
||||
@@ -314,70 +324,70 @@ MeshCore::MeshKernel* MeshAlgos::boolean(MeshCore::MeshKernel* pMesh1,
|
||||
|
||||
|
||||
/// helper function - construct a Edge out of two Vertexes if not already there
|
||||
static GtsEdge * new_edge (GtsVertex * v1, GtsVertex * v2)
|
||||
static GtsEdge* new_edge(GtsVertex* v1, GtsVertex* v2)
|
||||
{
|
||||
GtsSegment * s = gts_vertices_are_connected (v1, v2);
|
||||
if( s == NULL )
|
||||
return gts_edge_new (gts_edge_class (), v1, v2);
|
||||
else
|
||||
return GTS_EDGE (s);
|
||||
GtsSegment* s = gts_vertices_are_connected(v1, v2);
|
||||
if (s == NULL) {
|
||||
return gts_edge_new(gts_edge_class(), v1, v2);
|
||||
}
|
||||
else {
|
||||
return GTS_EDGE(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GtsSurface* MeshAlgos::createGTSSurface(MeshCore::MeshKernel* Mesh)
|
||||
{
|
||||
GtsSurface* Surf = gts_surface_new (gts_surface_class (),
|
||||
gts_face_class (),
|
||||
gts_edge_class (),
|
||||
gts_vertex_class () );
|
||||
GtsSurface* Surf = gts_surface_new(gts_surface_class(),
|
||||
gts_face_class(),
|
||||
gts_edge_class(),
|
||||
gts_vertex_class());
|
||||
|
||||
unsigned long p1,p2,p3;
|
||||
Base::Vector3f Vertex;
|
||||
unsigned long p1, p2, p3;
|
||||
Base::Vector3f Vertex;
|
||||
|
||||
|
||||
// Getting all the points
|
||||
GtsVertex ** aVertex = (GtsVertex **) malloc(Mesh->CountPoints() * sizeof (GtsVertex *));
|
||||
for (unsigned int PIter = 0;PIter < Mesh->CountPoints(); PIter++)
|
||||
{
|
||||
Vertex = Mesh->GetPoint(PIter);
|
||||
aVertex[PIter] = gts_vertex_new (gts_vertex_class (), Vertex.x, Vertex.y, Vertex.z);
|
||||
}
|
||||
// Getting all the points
|
||||
GtsVertex** aVertex = (GtsVertex**)malloc(Mesh->CountPoints() * sizeof(GtsVertex*));
|
||||
for (unsigned int PIter = 0; PIter < Mesh->CountPoints(); PIter++) {
|
||||
Vertex = Mesh->GetPoint(PIter);
|
||||
aVertex[PIter] = gts_vertex_new(gts_vertex_class(), Vertex.x, Vertex.y, Vertex.z);
|
||||
}
|
||||
|
||||
// cycling through the facets
|
||||
for (unsigned int pFIter = 0;pFIter < Mesh->CountFacets(); pFIter++)
|
||||
{
|
||||
// getting the three points of the facet
|
||||
Mesh->GetFacetPoints(pFIter,p1,p2,p3);
|
||||
for (unsigned int pFIter = 0; pFIter < Mesh->CountFacets(); pFIter++) {
|
||||
// getting the three points of the facet
|
||||
Mesh->GetFacetPoints(pFIter, p1, p2, p3);
|
||||
|
||||
// creating the edges and add the face to the surface
|
||||
gts_surface_add_face (Surf,
|
||||
gts_face_new (Surf->face_class,
|
||||
new_edge (aVertex[p1],aVertex[p2]),
|
||||
new_edge (aVertex[p2],aVertex[p3]),
|
||||
new_edge (aVertex[p3],aVertex[p1])));
|
||||
}
|
||||
// creating the edges and add the face to the surface
|
||||
gts_surface_add_face(Surf,
|
||||
gts_face_new(Surf->face_class,
|
||||
new_edge(aVertex[p1], aVertex[p2]),
|
||||
new_edge(aVertex[p2], aVertex[p3]),
|
||||
new_edge(aVertex[p3], aVertex[p1])));
|
||||
}
|
||||
|
||||
Base::Console().Log("GTS [%d faces, %d Points, %d Edges,%s ,%s]\n",gts_surface_face_number(Surf),
|
||||
gts_surface_vertex_number(Surf),
|
||||
gts_surface_edge_number(Surf),
|
||||
gts_surface_is_orientable (Surf)?"orientable":"not orientable",
|
||||
gts_surface_is_self_intersecting(Surf)?"self-intersections":"no self-intersection" );
|
||||
|
||||
return Surf;
|
||||
Base::Console().Log("GTS [%d faces, %d Points, %d Edges,%s ,%s]\n",
|
||||
gts_surface_face_number(Surf),
|
||||
gts_surface_vertex_number(Surf),
|
||||
gts_surface_edge_number(Surf),
|
||||
gts_surface_is_orientable(Surf) ? "orientable" : "not orientable",
|
||||
gts_surface_is_self_intersecting(Surf) ? "self-intersections"
|
||||
: "no self-intersection");
|
||||
|
||||
return Surf;
|
||||
}
|
||||
|
||||
/// helper function for the face (triangle iteration
|
||||
static void onFaces (GtsTriangle * t, std::vector<MeshGeomFacet> *VAry )
|
||||
static void onFaces(GtsTriangle* t, std::vector<MeshGeomFacet>* VAry)
|
||||
{
|
||||
GtsVertex *mv0,*mv1,*mv2;
|
||||
GtsVertex *mv0, *mv1, *mv2;
|
||||
|
||||
gts_triangle_vertices (t,&mv0,&mv1,&mv2);
|
||||
|
||||
VAry->push_back(MeshGeomFacet(Base::Vector3f(mv0->p.x,mv0->p.y,mv0->p.z),
|
||||
Base::Vector3f(mv1->p.x,mv1->p.y,mv1->p.z),
|
||||
Base::Vector3f(mv2->p.x,mv2->p.y,mv2->p.z)));
|
||||
gts_triangle_vertices(t, &mv0, &mv1, &mv2);
|
||||
|
||||
VAry->push_back(MeshGeomFacet(Base::Vector3f(mv0->p.x, mv0->p.y, mv0->p.z),
|
||||
Base::Vector3f(mv1->p.x, mv1->p.y, mv1->p.z),
|
||||
Base::Vector3f(mv2->p.x, mv2->p.y, mv2->p.z)));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -388,55 +398,54 @@ static void onVertices(GtsVertex *v, MeshKernel *pKernel )
|
||||
|
||||
void MeshAlgos::fillMeshFromGTSSurface(MeshCore::MeshKernel* pMesh, GtsSurface* pSurface)
|
||||
{
|
||||
std::vector<MeshGeomFacet> VAry;
|
||||
std::vector<MeshGeomFacet> VAry;
|
||||
|
||||
// remove old mesh
|
||||
pMesh->Clear();
|
||||
// remove old mesh
|
||||
pMesh->Clear();
|
||||
|
||||
// gts_surface_foreach_vertex(pSurface,(GtsFunc) onVertices,&MeshK);
|
||||
gts_surface_foreach_face (pSurface, (GtsFunc) onFaces,&VAry);
|
||||
// gts_surface_foreach_vertex(pSurface,(GtsFunc) onVertices,&MeshK);
|
||||
gts_surface_foreach_face(pSurface, (GtsFunc)onFaces, &VAry);
|
||||
|
||||
// destroy surfaces
|
||||
gts_object_destroy (GTS_OBJECT (pSurface));
|
||||
|
||||
// put the facets the simple way in the mesh, totp is recalculated!
|
||||
(*pMesh) = VAry;
|
||||
// destroy surfaces
|
||||
gts_object_destroy(GTS_OBJECT(pSurface));
|
||||
|
||||
// put the facets the simple way in the mesh, totp is recalculated!
|
||||
(*pMesh) = VAry;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <GeomAPI_IntCS.hxx>
|
||||
#include <GeomLProp_CLProps.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
|
||||
void MeshAlgos::cutByShape(const TopoDS_Shape &aShape,const MeshCore::MeshKernel* pMesh,MeshCore::MeshKernel* pToolMesh)
|
||||
void MeshAlgos::cutByShape(const TopoDS_Shape& aShape,
|
||||
const MeshCore::MeshKernel* pMesh,
|
||||
MeshCore::MeshKernel* pToolMesh)
|
||||
{
|
||||
|
||||
// calculate the projection for each Edge
|
||||
// CurveProjectorShape Project(aShape,*pMesh);
|
||||
CurveProjectorWithToolMesh Project(aShape,*pMesh,*pToolMesh);
|
||||
|
||||
//IntersectionLine Lines;
|
||||
// MeshWithProperty *ResultMesh = new MeshWithProperty();
|
||||
|
||||
|
||||
// boolean(pMesh,ToolMesh,ResultMesh,1);
|
||||
// calculate the projection for each Edge
|
||||
// CurveProjectorShape Project(aShape,*pMesh);
|
||||
CurveProjectorWithToolMesh Project(aShape, *pMesh, *pToolMesh);
|
||||
|
||||
// IntersectionLine Lines;
|
||||
// MeshWithProperty *ResultMesh = new MeshWithProperty();
|
||||
|
||||
|
||||
// boolean(pMesh,ToolMesh,ResultMesh,1);
|
||||
}
|
||||
|
||||
/*
|
||||
void MeshAlgos::doIntersection(const MeshWithProperty &pMesh,const MeshWithProperty ToolMesh,IntersectionLine &Lines)
|
||||
void MeshAlgos::doIntersection(const MeshWithProperty &pMesh,const MeshWithProperty
|
||||
ToolMesh,IntersectionLine &Lines)
|
||||
{
|
||||
|
||||
|
||||
@@ -444,140 +453,145 @@ void MeshAlgos::doIntersection(const MeshWithProperty &pMesh,const MeshWithPrope
|
||||
|
||||
*/
|
||||
|
||||
void MeshAlgos::cutByCurve(MeshCore::MeshKernel* pMesh,const std::vector<CurveProjector::FaceSplitEdge> &vSplitEdges)
|
||||
void MeshAlgos::cutByCurve(MeshCore::MeshKernel* pMesh,
|
||||
const std::vector<CurveProjector::FaceSplitEdge>& vSplitEdges)
|
||||
{
|
||||
MeshTopoAlgorithm cTopAlg(*pMesh);
|
||||
MeshTopoAlgorithm cTopAlg(*pMesh);
|
||||
|
||||
for (const auto & it : vSplitEdges)
|
||||
{
|
||||
cTopAlg.SplitFacet( it.ulFaceIndex, it.p1, it.p2 );
|
||||
}
|
||||
for (const auto& it : vSplitEdges) {
|
||||
cTopAlg.SplitFacet(it.ulFaceIndex, it.p1, it.p2);
|
||||
}
|
||||
}
|
||||
|
||||
class _VertexCompare
|
||||
{
|
||||
public:
|
||||
bool operator () (const TopoDS_Vertex &rclV1, const TopoDS_Vertex &rclV2) const
|
||||
public:
|
||||
bool operator()(const TopoDS_Vertex& rclV1, const TopoDS_Vertex& rclV2) const
|
||||
{
|
||||
if (rclV1.IsSame(rclV2) == Standard_True)
|
||||
return false;
|
||||
if (rclV1.IsSame(rclV2) == Standard_True) {
|
||||
return false;
|
||||
}
|
||||
|
||||
gp_XYZ clP1 = BRep_Tool::Pnt(rclV1).XYZ();
|
||||
gp_XYZ clP2 = BRep_Tool::Pnt(rclV2).XYZ();
|
||||
gp_XYZ clP1 = BRep_Tool::Pnt(rclV1).XYZ();
|
||||
gp_XYZ clP2 = BRep_Tool::Pnt(rclV2).XYZ();
|
||||
|
||||
if (fabs(clP1.X() - clP2.X()) < dE)
|
||||
{
|
||||
if (fabs(clP1.Y() - clP2.Y()) < dE)
|
||||
return clP1.Z() < clP2.Z();
|
||||
else
|
||||
return clP1.Y() < clP2.Y();
|
||||
}
|
||||
else
|
||||
return clP1.X() < clP2.X();
|
||||
if (fabs(clP1.X() - clP2.X()) < dE) {
|
||||
if (fabs(clP1.Y() - clP2.Y()) < dE) {
|
||||
return clP1.Z() < clP2.Z();
|
||||
}
|
||||
else {
|
||||
return clP1.Y() < clP2.Y();
|
||||
}
|
||||
}
|
||||
else {
|
||||
return clP1.X() < clP2.X();
|
||||
}
|
||||
}
|
||||
|
||||
double dE = 1.0e-5;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void MeshAlgos::LoftOnCurve(MeshCore::MeshKernel &ResultMesh, const TopoDS_Shape &Shape, const std::vector<Base::Vector3f> &poly, const Base::Vector3f & up, float MaxSize)
|
||||
void MeshAlgos::LoftOnCurve(MeshCore::MeshKernel& ResultMesh,
|
||||
const TopoDS_Shape& Shape,
|
||||
const std::vector<Base::Vector3f>& poly,
|
||||
const Base::Vector3f& up,
|
||||
float MaxSize)
|
||||
{
|
||||
TopExp_Explorer Ex;
|
||||
Standard_Real fBegin, fEnd;
|
||||
std::vector<MeshGeomFacet> cVAry;
|
||||
std::map<TopoDS_Vertex,std::vector<Base::Vector3f>,_VertexCompare> ConnectMap;
|
||||
TopExp_Explorer Ex;
|
||||
Standard_Real fBegin, fEnd;
|
||||
std::vector<MeshGeomFacet> cVAry;
|
||||
std::map<TopoDS_Vertex, std::vector<Base::Vector3f>, _VertexCompare> ConnectMap;
|
||||
|
||||
for (Ex.Init(Shape, TopAbs_EDGE); Ex.More(); Ex.Next())
|
||||
{
|
||||
// get the edge and the belonging Vertexes
|
||||
TopoDS_Edge Edge = (TopoDS_Edge&)Ex.Current();
|
||||
TopoDS_Vertex V1, V2;
|
||||
TopExp::Vertices(Edge, V1, V2);
|
||||
bool bBegin = false,bEnd = false;
|
||||
// getting the geometric curve and the interval
|
||||
GeomLProp_CLProps prop(BRep_Tool::Curve(Edge,fBegin,fEnd),1,0.0000000001);
|
||||
int res = int((fEnd - fBegin)/MaxSize);
|
||||
// do at least 2 segments
|
||||
if(res < 2)
|
||||
res = 2;
|
||||
gp_Dir Tangent;
|
||||
|
||||
std::vector<Base::Vector3f> prePoint(poly.size());
|
||||
std::vector<Base::Vector3f> actPoint(poly.size());
|
||||
|
||||
// checking if there is already a end to connect
|
||||
if(ConnectMap.find(V1) != ConnectMap.end() ){
|
||||
bBegin = true;
|
||||
prePoint = ConnectMap[V1];
|
||||
}
|
||||
|
||||
if(ConnectMap.find(V2) != ConnectMap.end() )
|
||||
bEnd = true;
|
||||
|
||||
for (long i = 0; i < res; i++)
|
||||
{
|
||||
|
||||
// get point and tangent at the position, up is fix for the moment
|
||||
prop.SetParameter(fBegin + ((fEnd - fBegin) * float(i)) / float(res-1));
|
||||
prop.Tangent(Tangent);
|
||||
Base::Vector3f Tng((float)Tangent.X(),
|
||||
(float)Tangent.Y(),
|
||||
(float)Tangent.Z());
|
||||
Base::Vector3f Ptn((float)prop.Value().X(),
|
||||
(float)prop.Value().Y(),
|
||||
(float)prop.Value().Z());
|
||||
Base::Vector3f Up (up);
|
||||
// normalize and calc the third vector of the plane coordinatesystem
|
||||
Tng.Normalize();
|
||||
Up.Normalize();
|
||||
Base::Vector3f Third(Tng%Up);
|
||||
|
||||
// Base::Console().Log("Pos: %f %f %f \n",Ptn.x,Ptn.y,Ptn.z);
|
||||
|
||||
unsigned int l=0;
|
||||
std::vector<Base::Vector3f>::const_iterator It;
|
||||
|
||||
// got through the profile
|
||||
for(It=poly.begin();It!=poly.end();++It,l++)
|
||||
actPoint[l] = ((Third*It->x)+(Up*It->y)+(Tng*It->z)+Ptn);
|
||||
|
||||
if(i == res-1 && !bEnd)
|
||||
// remember the last row to connect to a otger edge with the same vertex
|
||||
ConnectMap[V2] = actPoint;
|
||||
|
||||
if(i==1 && bBegin)
|
||||
// using the end of an other edge as start
|
||||
prePoint = ConnectMap[V1];
|
||||
|
||||
if(i==0 && !bBegin)
|
||||
// remember the first row for connection to a edge with the same vertex
|
||||
ConnectMap[V1] = actPoint;
|
||||
|
||||
if(i ) // not the first row or something to connect to
|
||||
{
|
||||
for(l=0;l<actPoint.size();l++)
|
||||
{
|
||||
if(l) // not first point in row
|
||||
{
|
||||
if(i == res-1 && bEnd) // if last row and a end to connect
|
||||
actPoint = ConnectMap[V2];
|
||||
|
||||
Base::Vector3f p1 = prePoint[l-1],
|
||||
p2 = actPoint[l-1],
|
||||
p3 = prePoint[l],
|
||||
p4 = actPoint[l];
|
||||
|
||||
cVAry.emplace_back(p1,p2,p3);
|
||||
cVAry.emplace_back(p3,p2,p4);
|
||||
}
|
||||
for (Ex.Init(Shape, TopAbs_EDGE); Ex.More(); Ex.Next()) {
|
||||
// get the edge and the belonging Vertexes
|
||||
TopoDS_Edge Edge = (TopoDS_Edge&)Ex.Current();
|
||||
TopoDS_Vertex V1, V2;
|
||||
TopExp::Vertices(Edge, V1, V2);
|
||||
bool bBegin = false, bEnd = false;
|
||||
// getting the geometric curve and the interval
|
||||
GeomLProp_CLProps prop(BRep_Tool::Curve(Edge, fBegin, fEnd), 1, 0.0000000001);
|
||||
int res = int((fEnd - fBegin) / MaxSize);
|
||||
// do at least 2 segments
|
||||
if (res < 2) {
|
||||
res = 2;
|
||||
}
|
||||
}
|
||||
gp_Dir Tangent;
|
||||
|
||||
prePoint = actPoint;
|
||||
std::vector<Base::Vector3f> prePoint(poly.size());
|
||||
std::vector<Base::Vector3f> actPoint(poly.size());
|
||||
|
||||
// checking if there is already a end to connect
|
||||
if (ConnectMap.find(V1) != ConnectMap.end()) {
|
||||
bBegin = true;
|
||||
prePoint = ConnectMap[V1];
|
||||
}
|
||||
|
||||
if (ConnectMap.find(V2) != ConnectMap.end()) {
|
||||
bEnd = true;
|
||||
}
|
||||
|
||||
for (long i = 0; i < res; i++) {
|
||||
|
||||
// get point and tangent at the position, up is fix for the moment
|
||||
prop.SetParameter(fBegin + ((fEnd - fBegin) * float(i)) / float(res - 1));
|
||||
prop.Tangent(Tangent);
|
||||
Base::Vector3f Tng((float)Tangent.X(), (float)Tangent.Y(), (float)Tangent.Z());
|
||||
Base::Vector3f Ptn((float)prop.Value().X(),
|
||||
(float)prop.Value().Y(),
|
||||
(float)prop.Value().Z());
|
||||
Base::Vector3f Up(up);
|
||||
// normalize and calc the third vector of the plane coordinatesystem
|
||||
Tng.Normalize();
|
||||
Up.Normalize();
|
||||
Base::Vector3f Third(Tng % Up);
|
||||
|
||||
// Base::Console().Log("Pos: %f %f %f \n",Ptn.x,Ptn.y,Ptn.z);
|
||||
|
||||
unsigned int l = 0;
|
||||
std::vector<Base::Vector3f>::const_iterator It;
|
||||
|
||||
// got through the profile
|
||||
for (It = poly.begin(); It != poly.end(); ++It, l++) {
|
||||
actPoint[l] = ((Third * It->x) + (Up * It->y) + (Tng * It->z) + Ptn);
|
||||
}
|
||||
|
||||
if (i == res - 1 && !bEnd) {
|
||||
// remember the last row to connect to a otger edge with the same vertex
|
||||
ConnectMap[V2] = actPoint;
|
||||
}
|
||||
|
||||
if (i == 1 && bBegin) {
|
||||
// using the end of an other edge as start
|
||||
prePoint = ConnectMap[V1];
|
||||
}
|
||||
|
||||
if (i == 0 && !bBegin) {
|
||||
// remember the first row for connection to a edge with the same vertex
|
||||
ConnectMap[V1] = actPoint;
|
||||
}
|
||||
|
||||
if (i)// not the first row or something to connect to
|
||||
{
|
||||
for (l = 0; l < actPoint.size(); l++) {
|
||||
if (l)// not first point in row
|
||||
{
|
||||
if (i == res - 1 && bEnd) {// if last row and a end to connect
|
||||
actPoint = ConnectMap[V2];
|
||||
}
|
||||
|
||||
Base::Vector3f p1 = prePoint[l - 1], p2 = actPoint[l - 1], p3 = prePoint[l],
|
||||
p4 = actPoint[l];
|
||||
|
||||
cVAry.emplace_back(p1, p2, p3);
|
||||
cVAry.emplace_back(p3, p2, p4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prePoint = actPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ResultMesh.AddFacets(cVAry);
|
||||
|
||||
ResultMesh.AddFacets(cVAry);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#define _MeshAlgos_h_
|
||||
|
||||
#ifdef FC_USE_GTS
|
||||
# include <gts.h>
|
||||
#include <gts.h>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
@@ -50,61 +50,72 @@ namespace MeshPart
|
||||
class MeshPartExport MeshAlgos
|
||||
{
|
||||
public:
|
||||
/** Calculate per Vertex normals and adds the Normal property bag
|
||||
*/
|
||||
static void offset(MeshCore::MeshKernel* Mesh, float fSize);
|
||||
static void offsetSpecial2(MeshCore::MeshKernel* Mesh, float fSize);
|
||||
static void offsetSpecial(MeshCore::MeshKernel* Mesh, float fSize, float zmax, float zmin);
|
||||
/** Calculate per Vertex normals and adds the Normal property bag
|
||||
*/
|
||||
static void offset(MeshCore::MeshKernel* Mesh, float fSize);
|
||||
static void offsetSpecial2(MeshCore::MeshKernel* Mesh, float fSize);
|
||||
static void offsetSpecial(MeshCore::MeshKernel* Mesh, float fSize, float zmax, float zmin);
|
||||
|
||||
/** Coarsen the mesh
|
||||
*/
|
||||
static void coarsen(MeshCore::MeshKernel* Mesh, float f);
|
||||
/** Coarsen the mesh
|
||||
*/
|
||||
static void coarsen(MeshCore::MeshKernel* Mesh, float f);
|
||||
|
||||
/** makes a boolean add
|
||||
* The int Type stears the boolean oberation: 0=add;1=intersection;2=diff
|
||||
*/
|
||||
static MeshCore::MeshKernel* boolean(MeshCore::MeshKernel* Mesh1, MeshCore::MeshKernel* Mesh2, MeshCore::MeshKernel* pResult, int Type=0);
|
||||
/** makes a boolean add
|
||||
* The int Type stears the boolean oberation: 0=add;1=intersection;2=diff
|
||||
*/
|
||||
static MeshCore::MeshKernel* boolean(MeshCore::MeshKernel* Mesh1,
|
||||
MeshCore::MeshKernel* Mesh2,
|
||||
MeshCore::MeshKernel* pResult,
|
||||
int Type = 0);
|
||||
|
||||
#ifdef FC_USE_GTS
|
||||
|
||||
/** Creates a GTS Surface from a MeshKernel
|
||||
*/
|
||||
static GtsSurface* createGTSSurface(MeshCore::MeshKernel* Mesh);
|
||||
/** Creates a GTS Surface from a MeshKernel
|
||||
*/
|
||||
static GtsSurface* createGTSSurface(MeshCore::MeshKernel* Mesh);
|
||||
|
||||
/** Creates a GTS Surface from a MeshKernel
|
||||
*/
|
||||
/** Creates a GTS Surface from a MeshKernel
|
||||
*/
|
||||
|
||||
static void fillMeshFromGTSSurface(MeshCore::MeshKernel* pMesh, GtsSurface* pSurface);
|
||||
static void fillMeshFromGTSSurface(MeshCore::MeshKernel* pMesh, GtsSurface* pSurface);
|
||||
#endif
|
||||
|
||||
static void cutByShape(const TopoDS_Shape &aShape,const MeshCore::MeshKernel* pMesh,MeshCore::MeshKernel* pToolMesh);
|
||||
static void cutByShape(const TopoDS_Shape& aShape,
|
||||
const MeshCore::MeshKernel* pMesh,
|
||||
MeshCore::MeshKernel* pToolMesh);
|
||||
|
||||
/// helper to discredicice a Edge...
|
||||
static void GetSampledCurves( const TopoDS_Edge& aEdge, std::vector<Base::Vector3f>& rclPoints, unsigned long ulNbOfPoints = 30);
|
||||
/// helper to discredicice a Edge...
|
||||
static void GetSampledCurves(const TopoDS_Edge& aEdge,
|
||||
std::vector<Base::Vector3f>& rclPoints,
|
||||
unsigned long ulNbOfPoints = 30);
|
||||
|
||||
/// creates a mesh loft on base of a curve and an up vector
|
||||
static void LoftOnCurve(MeshCore::MeshKernel &ResultMesh,const TopoDS_Shape &Shape, const std::vector<Base::Vector3f> &poly,
|
||||
const Base::Vector3f & up = Base::Vector3f(0,0,1), float MaxSize = 0.1);
|
||||
/// creates a mesh loft on base of a curve and an up vector
|
||||
static void LoftOnCurve(MeshCore::MeshKernel& ResultMesh,
|
||||
const TopoDS_Shape& Shape,
|
||||
const std::vector<Base::Vector3f>& poly,
|
||||
const Base::Vector3f& up = Base::Vector3f(0, 0, 1),
|
||||
float MaxSize = 0.1);
|
||||
|
||||
/*
|
||||
struct FaceSplitEdge
|
||||
{
|
||||
unsigned long ulFaceIndex;
|
||||
Base::Vector3f p1,p2;
|
||||
};
|
||||
|
||||
static void projectCurve( MeshWithProperty* pMesh,
|
||||
const TopoDS_Edge& aEdge,
|
||||
const std::vector<Base::Vector3f> &rclPoints,
|
||||
std::vector<FaceSplitEdge> &vSplitEdges);
|
||||
*/
|
||||
static void cutByCurve(MeshCore::MeshKernel* pMesh,const std::vector<CurveProjector::FaceSplitEdge> &vSplitEdges);
|
||||
/*
|
||||
static bool projectPointToMesh(MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,unsigned long &FaceIndex);
|
||||
*/
|
||||
/*
|
||||
struct FaceSplitEdge
|
||||
{
|
||||
unsigned long ulFaceIndex;
|
||||
Base::Vector3f p1,p2;
|
||||
};
|
||||
|
||||
static void projectCurve( MeshWithProperty* pMesh,
|
||||
const TopoDS_Edge& aEdge,
|
||||
const std::vector<Base::Vector3f> &rclPoints,
|
||||
std::vector<FaceSplitEdge> &vSplitEdges);
|
||||
*/
|
||||
static void cutByCurve(MeshCore::MeshKernel* pMesh,
|
||||
const std::vector<CurveProjector::FaceSplitEdge>& vSplitEdges);
|
||||
/*
|
||||
static bool projectPointToMesh(MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f
|
||||
&Rslt,unsigned long &FaceIndex);
|
||||
*/
|
||||
};
|
||||
|
||||
} // namespace MeshPart
|
||||
}// namespace MeshPart
|
||||
|
||||
#endif
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "MeshFlatteningNurbs.h"
|
||||
|
||||
|
||||
// clang-format off
|
||||
using Vector3 = Eigen::Vector3d;
|
||||
using Vector2 = Eigen::Vector2d;
|
||||
|
||||
@@ -75,5 +76,6 @@ public:
|
||||
spMat A; // mapping between nurbs(poles) and mesh(vertices) computed with nurbs-basis-functions and uv_mesh
|
||||
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
#endif // MESHFLATTENING
|
||||
#endif// MESHFLATTENING
|
||||
|
||||
@@ -22,17 +22,23 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <map>
|
||||
# include <memory>
|
||||
# include <stdexcept>
|
||||
# include <vector>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Edge.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#endif
|
||||
|
||||
// boost is purposely not in the precompiled headers, see
|
||||
// https://github.com/FreeCAD/FreeCAD/pull/7979#issuecomment-1358123252
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Geometry>
|
||||
#include <Eigen/Sparse>
|
||||
#include <Mod/Part/App/TopoShapeEdgePy.h>
|
||||
#include <Mod/Part/App/TopoShapeFacePy.h>
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/call.hpp>
|
||||
#include <boost/python/class.hpp>
|
||||
@@ -40,18 +46,13 @@
|
||||
#include <boost/python/module.hpp>
|
||||
#include <boost/python/return_value_policy.hpp>
|
||||
#include <boost/python/wrapper.hpp>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Geometry>
|
||||
#include <Eigen/Sparse>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Mod/Part/App/TopoShapeEdgePy.h>
|
||||
#include <Mod/Part/App/TopoShapeFacePy.h>
|
||||
|
||||
#include "MeshFlattening.h"
|
||||
#include "MeshFlatteningLscmRelax.h"
|
||||
#include "MeshFlatteningNurbs.h"
|
||||
|
||||
|
||||
// clang-format off
|
||||
namespace py = boost::python;
|
||||
|
||||
const TopoDS_Face& getTopoDSFace(const py::object& face)
|
||||
@@ -261,3 +262,4 @@ BOOST_PYTHON_MODULE(flatmesh)
|
||||
fm::eigen_matrix<ColMat<long, 1>>::to_python_converter();
|
||||
fm::eigen_matrix<ColMat<long, 3>>::to_python_converter();
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
@@ -22,16 +22,16 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <array>
|
||||
# include <cmath>
|
||||
# include <iostream>
|
||||
# include <map>
|
||||
# include <set>
|
||||
# include <vector>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#endif
|
||||
|
||||
#ifndef M_PI
|
||||
# define M_PI 3.14159265358979323846f
|
||||
#define M_PI 3.14159265358979323846f
|
||||
#endif
|
||||
|
||||
#include <Eigen/SparseCholesky>
|
||||
@@ -43,6 +43,7 @@
|
||||
// area constrained (scale the final unwrapped mesh to the original area)
|
||||
// FEM approach
|
||||
|
||||
// clang-format off
|
||||
namespace lscmrelax
|
||||
{
|
||||
|
||||
@@ -715,3 +716,4 @@ Eigen::MatrixXd LscmRelax::get_nullspace()
|
||||
|
||||
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
// clang-format off
|
||||
// LeastSquareConformalMapping + fem relaxing
|
||||
// ------------------------------------------
|
||||
//
|
||||
@@ -123,3 +124,4 @@ public:
|
||||
}
|
||||
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
@@ -22,13 +22,14 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <cmath>
|
||||
# include <iostream>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#include "MeshFlatteningNurbs.h"
|
||||
|
||||
|
||||
// clang-format off
|
||||
namespace nurbs{
|
||||
|
||||
double divide(double a, double b)
|
||||
@@ -516,3 +517,4 @@ Eigen::VectorXd NurbsBase1D::getUMesh(int num_u_points)
|
||||
|
||||
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
// clang-format off
|
||||
#ifndef NURBS_H
|
||||
#define NURBS_H
|
||||
|
||||
@@ -115,3 +116,4 @@ struct NurbsBase1D
|
||||
}
|
||||
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
// clang-format off
|
||||
#ifdef _MSC_VER
|
||||
# define strdup _strdup
|
||||
#endif
|
||||
@@ -162,3 +163,4 @@ PYBIND11_MODULE(flatmesh, m)
|
||||
.def_readonly("A", &FaceUnwrapper::A);
|
||||
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <algorithm>
|
||||
#include <algorithm>
|
||||
|
||||
# include <BRepMesh_IncrementalMesh.hxx>
|
||||
# include <BRepTools.hxx>
|
||||
# include <Standard_Version.hxx>
|
||||
# include <TopoDS_Shape.hxx>
|
||||
#include <BRepMesh_IncrementalMesh.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
@@ -40,47 +40,47 @@
|
||||
|
||||
#ifdef HAVE_SMESH
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Woverloaded-virtual"
|
||||
# pragma clang diagnostic ignored "-Wextra-semi"
|
||||
#elif defined (__GNUC__)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Woverloaded-virtual"
|
||||
#pragma clang diagnostic ignored "-Wextra-semi"
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
|
||||
#include <SMESH_Gen.hxx>
|
||||
#include <StdMeshers_MaxLength.hxx>
|
||||
#include <SMESH_Mesh.hxx>
|
||||
#include <SMESHDS_Mesh.hxx>
|
||||
#include <SMESH_Gen.hxx>
|
||||
#include <SMESH_Mesh.hxx>
|
||||
#include <StdMeshers_MaxLength.hxx>
|
||||
|
||||
#if SMESH_VERSION_MAJOR < 7
|
||||
#include <StdMeshers_TrianglePreference.hxx>
|
||||
#endif
|
||||
|
||||
#include <StdMeshers_LocalLength.hxx>
|
||||
#include <StdMeshers_NumberOfSegments.hxx>
|
||||
#include <StdMeshers_AutomaticLength.hxx>
|
||||
#include <StdMeshers_MEFISTO_2D.hxx>
|
||||
#include <StdMeshers_Deflection1D.hxx>
|
||||
#include <StdMeshers_Arithmetic1D.hxx>
|
||||
#include <StdMeshers_AutomaticLength.hxx>
|
||||
#include <StdMeshers_Deflection1D.hxx>
|
||||
#include <StdMeshers_LocalLength.hxx>
|
||||
#include <StdMeshers_MEFISTO_2D.hxx>
|
||||
#include <StdMeshers_MaxElementArea.hxx>
|
||||
#include <StdMeshers_Regular_1D.hxx>
|
||||
#include <StdMeshers_NumberOfSegments.hxx>
|
||||
#include <StdMeshers_QuadranglePreference.hxx>
|
||||
#include <StdMeshers_Quadrangle_2D.hxx>
|
||||
#include <StdMeshers_Regular_1D.hxx>
|
||||
|
||||
#include <StdMeshers_LengthFromEdges.hxx>
|
||||
#include <StdMeshers_NotConformAllowed.hxx>
|
||||
#if defined(HAVE_NETGEN)
|
||||
#include <NETGENPlugin_NETGEN_2D.hxx>
|
||||
#include <NETGENPlugin_Hypothesis_2D.hxx>
|
||||
#include <NETGENPlugin_NETGEN_2D.hxx>
|
||||
#include <NETGENPlugin_SimpleHypothesis_2D.hxx>
|
||||
#endif // HAVE_NETGEN
|
||||
#endif// HAVE_NETGEN
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic pop
|
||||
#elif defined (__GNUC__)
|
||||
# pragma GCC diagnostic pop
|
||||
#pragma clang diagnostic pop
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#endif // HAVE_SMESH
|
||||
#endif// HAVE_SMESH
|
||||
|
||||
using namespace MeshPart;
|
||||
|
||||
@@ -94,8 +94,9 @@ MeshingOutput::MeshingOutput()
|
||||
|
||||
int MeshingOutput::overflow(int c)
|
||||
{
|
||||
if (c != EOF)
|
||||
if (c != EOF) {
|
||||
buffer.push_back((char)c);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -108,7 +109,7 @@ int MeshingOutput::sync()
|
||||
std::string sub;
|
||||
if (pos != std::string::npos) {
|
||||
// chop the last newline
|
||||
sub = buffer.substr(pos+3, buffer.size()-pos-4);
|
||||
sub = buffer.substr(pos + 3, buffer.size() - pos - 4);
|
||||
}
|
||||
else {
|
||||
sub = buffer;
|
||||
@@ -122,16 +123,20 @@ int MeshingOutput::sync()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
namespace MeshPart {
|
||||
namespace MeshPart
|
||||
{
|
||||
|
||||
struct Vertex {
|
||||
struct Vertex
|
||||
{
|
||||
static const double deflection;
|
||||
Standard_Real x,y,z;
|
||||
Standard_Real x, y, z;
|
||||
Standard_Integer i = 0;
|
||||
mutable MeshCore::MeshPoint p;
|
||||
|
||||
Vertex(Standard_Real X, Standard_Real Y, Standard_Real Z)
|
||||
: x(X),y(Y),z(Z)
|
||||
: x(X)
|
||||
, y(Y)
|
||||
, z(Z)
|
||||
{
|
||||
p.x = static_cast<float>(x);
|
||||
p.y = static_cast<float>(y);
|
||||
@@ -143,15 +148,18 @@ struct Vertex {
|
||||
return p;
|
||||
}
|
||||
|
||||
bool operator < (const Vertex &v) const
|
||||
bool operator<(const Vertex& v) const
|
||||
{
|
||||
if (fabs ( this->x - v.x) >= deflection)
|
||||
if (fabs(this->x - v.x) >= deflection) {
|
||||
return this->x < v.x;
|
||||
if (fabs ( this->y - v.y) >= deflection)
|
||||
}
|
||||
if (fabs(this->y - v.y) >= deflection) {
|
||||
return this->y < v.y;
|
||||
if (fabs ( this->z - v.z) >= deflection)
|
||||
}
|
||||
if (fabs(this->z - v.z) >= deflection) {
|
||||
return this->z < v.z;
|
||||
return false; // points are considered to be equal
|
||||
}
|
||||
return false;// points are considered to be equal
|
||||
}
|
||||
};
|
||||
|
||||
@@ -159,20 +167,21 @@ const double Vertex::deflection = gp::Resolution();
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class BrepMesh {
|
||||
class BrepMesh
|
||||
{
|
||||
bool segments;
|
||||
std::vector<uint32_t> colors;
|
||||
|
||||
public:
|
||||
BrepMesh(bool s, const std::vector<uint32_t>& c)
|
||||
: segments(s)
|
||||
, colors(c)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
Mesh::MeshObject* create(const std::vector<Part::TopoShape::Domain>& domains) const
|
||||
{
|
||||
std::map<uint32_t, std::vector<std::size_t> > colorMap;
|
||||
for (std::size_t i=0; i<colors.size(); i++) {
|
||||
std::map<uint32_t, std::vector<std::size_t>> colorMap;
|
||||
for (std::size_t i = 0; i < colors.size(); i++) {
|
||||
colorMap[colors[i]].push_back(i);
|
||||
}
|
||||
|
||||
@@ -180,8 +189,9 @@ public:
|
||||
|
||||
MeshCore::MeshFacetArray faces;
|
||||
std::size_t numTriangles = 0;
|
||||
for (const auto& it : domains)
|
||||
for (const auto& it : domains) {
|
||||
numTriangles += it.facets.size();
|
||||
}
|
||||
faces.reserve(numTriangles);
|
||||
|
||||
std::set<Vertex> vertices;
|
||||
@@ -189,7 +199,7 @@ public:
|
||||
Standard_Real x2, y2, z2;
|
||||
Standard_Real x3, y3, z3;
|
||||
|
||||
std::vector< std::vector<MeshCore::FacetIndex> > meshSegments;
|
||||
std::vector<std::vector<MeshCore::FacetIndex>> meshSegments;
|
||||
std::size_t numMeshFaces = 0;
|
||||
|
||||
for (const auto& domain : domains) {
|
||||
@@ -212,7 +222,7 @@ public:
|
||||
MeshCore::MeshFacet face;
|
||||
|
||||
// 1st vertex
|
||||
Vertex v1(x1,y1,z1);
|
||||
Vertex v1(x1, y1, z1);
|
||||
it = vertices.find(v1);
|
||||
if (it == vertices.end()) {
|
||||
v1.i = vertices.size();
|
||||
@@ -224,7 +234,7 @@ public:
|
||||
}
|
||||
|
||||
// 2nd vertex
|
||||
Vertex v2(x2,y2,z2);
|
||||
Vertex v2(x2, y2, z2);
|
||||
it = vertices.find(v2);
|
||||
if (it == vertices.end()) {
|
||||
v2.i = vertices.size();
|
||||
@@ -236,7 +246,7 @@ public:
|
||||
}
|
||||
|
||||
// 3rd vertex
|
||||
Vertex v3(x3,y3,z3);
|
||||
Vertex v3(x3, y3, z3);
|
||||
it = vertices.find(v3);
|
||||
if (it == vertices.end()) {
|
||||
v3.i = vertices.size();
|
||||
@@ -248,9 +258,9 @@ public:
|
||||
}
|
||||
|
||||
// make sure that we don't insert invalid facets
|
||||
if (face._aulPoints[0] != face._aulPoints[1] &&
|
||||
face._aulPoints[1] != face._aulPoints[2] &&
|
||||
face._aulPoints[2] != face._aulPoints[0]) {
|
||||
if (face._aulPoints[0] != face._aulPoints[1]
|
||||
&& face._aulPoints[1] != face._aulPoints[2]
|
||||
&& face._aulPoints[2] != face._aulPoints[0]) {
|
||||
faces.push_back(face);
|
||||
numDomainFaces++;
|
||||
}
|
||||
@@ -259,7 +269,9 @@ public:
|
||||
// add a segment for the face
|
||||
if (createSegm || this->segments) {
|
||||
std::vector<MeshCore::FacetIndex> segment(numDomainFaces);
|
||||
std::generate(segment.begin(), segment.end(), Base::iotaGen<MeshCore::FacetIndex>(numMeshFaces));
|
||||
std::generate(segment.begin(),
|
||||
segment.end(),
|
||||
Base::iotaGen<MeshCore::FacetIndex>(numMeshFaces));
|
||||
numMeshFaces += numDomainFaces;
|
||||
meshSegments.push_back(segment);
|
||||
}
|
||||
@@ -267,8 +279,9 @@ public:
|
||||
|
||||
MeshCore::MeshPointArray verts;
|
||||
verts.resize(vertices.size());
|
||||
for (const auto& it : vertices)
|
||||
for (const auto& it : vertices) {
|
||||
verts[it.i] = it.toPoint();
|
||||
}
|
||||
|
||||
MeshCore::MeshKernel kernel;
|
||||
kernel.Adopt(verts, faces, true);
|
||||
@@ -300,14 +313,13 @@ public:
|
||||
return meshdata;
|
||||
}
|
||||
};
|
||||
}
|
||||
}// namespace MeshPart
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Mesher::Mesher(const TopoDS_Shape& s)
|
||||
: shape(s)
|
||||
{
|
||||
}
|
||||
: shape(s)
|
||||
{}
|
||||
|
||||
Mesher::~Mesher() = default;
|
||||
|
||||
@@ -337,8 +349,9 @@ Mesh::MeshObject* Mesher::createMesh() const
|
||||
#else
|
||||
std::list<SMESH_Hypothesis*> hypoth;
|
||||
|
||||
if (!Mesher::_mesh_gen)
|
||||
if (!Mesher::_mesh_gen) {
|
||||
Mesher::_mesh_gen = new SMESH_Gen();
|
||||
}
|
||||
SMESH_Gen* meshgen = Mesher::_mesh_gen;
|
||||
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
@@ -348,137 +361,147 @@ Mesh::MeshObject* Mesher::createMesh() const
|
||||
#endif
|
||||
|
||||
|
||||
int hyp=0;
|
||||
int hyp = 0;
|
||||
|
||||
switch (method) {
|
||||
#if defined (HAVE_NETGEN)
|
||||
case Netgen: {
|
||||
#if defined(HAVE_NETGEN)
|
||||
case Netgen: {
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
NETGENPlugin_Hypothesis_2D* hyp2d = new NETGENPlugin_Hypothesis_2D(hyp++,meshgen);
|
||||
NETGENPlugin_Hypothesis_2D* hyp2d = new NETGENPlugin_Hypothesis_2D(hyp++, meshgen);
|
||||
#else
|
||||
NETGENPlugin_Hypothesis_2D* hyp2d = new NETGENPlugin_Hypothesis_2D(hyp++,0,meshgen);
|
||||
NETGENPlugin_Hypothesis_2D* hyp2d = new NETGENPlugin_Hypothesis_2D(hyp++, 0, meshgen);
|
||||
#endif
|
||||
|
||||
if (fineness >=0 && fineness < 5) {
|
||||
hyp2d->SetFineness(NETGENPlugin_Hypothesis_2D::Fineness(fineness));
|
||||
}
|
||||
// user defined values
|
||||
else {
|
||||
if (growthRate > 0)
|
||||
hyp2d->SetGrowthRate(growthRate);
|
||||
if (nbSegPerEdge > 0)
|
||||
hyp2d->SetNbSegPerEdge(nbSegPerEdge);
|
||||
if (nbSegPerRadius > 0)
|
||||
hyp2d->SetNbSegPerRadius(nbSegPerRadius);
|
||||
}
|
||||
if (fineness >= 0 && fineness < 5) {
|
||||
hyp2d->SetFineness(NETGENPlugin_Hypothesis_2D::Fineness(fineness));
|
||||
}
|
||||
// user defined values
|
||||
else {
|
||||
if (growthRate > 0) {
|
||||
hyp2d->SetGrowthRate(growthRate);
|
||||
}
|
||||
if (nbSegPerEdge > 0) {
|
||||
hyp2d->SetNbSegPerEdge(nbSegPerEdge);
|
||||
}
|
||||
if (nbSegPerRadius > 0) {
|
||||
hyp2d->SetNbSegPerRadius(nbSegPerRadius);
|
||||
}
|
||||
}
|
||||
|
||||
if (maxLen > 0)
|
||||
hyp2d->SetMaxSize(maxLen);
|
||||
if (minLen > 0)
|
||||
hyp2d->SetMinSize(minLen);
|
||||
if (maxLen > 0) {
|
||||
hyp2d->SetMaxSize(maxLen);
|
||||
}
|
||||
if (minLen > 0) {
|
||||
hyp2d->SetMinSize(minLen);
|
||||
}
|
||||
|
||||
hyp2d->SetQuadAllowed(allowquad);
|
||||
hyp2d->SetOptimize(optimize);
|
||||
hyp2d->SetSecondOrder(secondOrder); // apply bisecting to create four triangles out of one
|
||||
hypoth.push_back(hyp2d);
|
||||
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
NETGENPlugin_NETGEN_2D* alg2d = new NETGENPlugin_NETGEN_2D(hyp++,meshgen);
|
||||
#else
|
||||
NETGENPlugin_NETGEN_2D* alg2d = new NETGENPlugin_NETGEN_2D(hyp++,0,meshgen);
|
||||
#endif
|
||||
hypoth.push_back(alg2d);
|
||||
} break;
|
||||
#endif
|
||||
#if defined (HAVE_MEFISTO)
|
||||
case Mefisto: {
|
||||
if (maxLength > 0) {
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_MaxLength* hyp1d = new StdMeshers_MaxLength(hyp++, meshgen);
|
||||
#else
|
||||
StdMeshers_MaxLength* hyp1d = new StdMeshers_MaxLength(hyp++, 0, meshgen);
|
||||
#endif
|
||||
hyp1d->SetLength(maxLength);
|
||||
hypoth.push_back(hyp1d);
|
||||
}
|
||||
else if (localLength > 0) {
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_LocalLength* hyp1d = new StdMeshers_LocalLength(hyp++,meshgen);
|
||||
#else
|
||||
StdMeshers_LocalLength* hyp1d = new StdMeshers_LocalLength(hyp++,0,meshgen);
|
||||
#endif
|
||||
hyp1d->SetLength(localLength);
|
||||
hypoth.push_back(hyp1d);
|
||||
}
|
||||
else if (maxArea > 0) {
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_MaxElementArea* hyp2d = new StdMeshers_MaxElementArea(hyp++,meshgen);
|
||||
#else
|
||||
StdMeshers_MaxElementArea* hyp2d = new StdMeshers_MaxElementArea(hyp++,0,meshgen);
|
||||
#endif
|
||||
hyp2d->SetMaxArea(maxArea);
|
||||
hyp2d->SetQuadAllowed(allowquad);
|
||||
hyp2d->SetOptimize(optimize);
|
||||
hyp2d->SetSecondOrder(
|
||||
secondOrder);// apply bisecting to create four triangles out of one
|
||||
hypoth.push_back(hyp2d);
|
||||
}
|
||||
else if (deflection > 0) {
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_Deflection1D* hyp1d = new StdMeshers_Deflection1D(hyp++,meshgen);
|
||||
#else
|
||||
StdMeshers_Deflection1D* hyp1d = new StdMeshers_Deflection1D(hyp++,0,meshgen);
|
||||
#endif
|
||||
hyp1d->SetDeflection(deflection);
|
||||
hypoth.push_back(hyp1d);
|
||||
}
|
||||
else if (minLen > 0 && maxLen > 0) {
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_Arithmetic1D* hyp1d = new StdMeshers_Arithmetic1D(hyp++,meshgen);
|
||||
#else
|
||||
StdMeshers_Arithmetic1D* hyp1d = new StdMeshers_Arithmetic1D(hyp++,0,meshgen);
|
||||
#endif
|
||||
hyp1d->SetLength(minLen, false);
|
||||
hyp1d->SetLength(maxLen, true);
|
||||
hypoth.push_back(hyp1d);
|
||||
}
|
||||
else {
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_AutomaticLength* hyp1d = new StdMeshers_AutomaticLength(hyp++,meshgen);
|
||||
#else
|
||||
StdMeshers_AutomaticLength* hyp1d = new StdMeshers_AutomaticLength(hyp++,0,meshgen);
|
||||
#endif
|
||||
hypoth.push_back(hyp1d);
|
||||
}
|
||||
|
||||
{
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_NumberOfSegments* hyp1d = new StdMeshers_NumberOfSegments(hyp++,meshgen);
|
||||
NETGENPlugin_NETGEN_2D* alg2d = new NETGENPlugin_NETGEN_2D(hyp++, meshgen);
|
||||
#else
|
||||
StdMeshers_NumberOfSegments* hyp1d = new StdMeshers_NumberOfSegments(hyp++,0,meshgen);
|
||||
NETGENPlugin_NETGEN_2D* alg2d = new NETGENPlugin_NETGEN_2D(hyp++, 0, meshgen);
|
||||
#endif
|
||||
hyp1d->SetNumberOfSegments(1);
|
||||
hypoth.push_back(hyp1d);
|
||||
}
|
||||
hypoth.push_back(alg2d);
|
||||
} break;
|
||||
#endif
|
||||
#if defined(HAVE_MEFISTO)
|
||||
case Mefisto: {
|
||||
if (maxLength > 0) {
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_MaxLength* hyp1d = new StdMeshers_MaxLength(hyp++, meshgen);
|
||||
#else
|
||||
StdMeshers_MaxLength* hyp1d = new StdMeshers_MaxLength(hyp++, 0, meshgen);
|
||||
#endif
|
||||
hyp1d->SetLength(maxLength);
|
||||
hypoth.push_back(hyp1d);
|
||||
}
|
||||
else if (localLength > 0) {
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_LocalLength* hyp1d = new StdMeshers_LocalLength(hyp++, meshgen);
|
||||
#else
|
||||
StdMeshers_LocalLength* hyp1d = new StdMeshers_LocalLength(hyp++, 0, meshgen);
|
||||
#endif
|
||||
hyp1d->SetLength(localLength);
|
||||
hypoth.push_back(hyp1d);
|
||||
}
|
||||
else if (maxArea > 0) {
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_MaxElementArea* hyp2d = new StdMeshers_MaxElementArea(hyp++, meshgen);
|
||||
#else
|
||||
StdMeshers_MaxElementArea* hyp2d = new StdMeshers_MaxElementArea(hyp++, 0, meshgen);
|
||||
#endif
|
||||
hyp2d->SetMaxArea(maxArea);
|
||||
hypoth.push_back(hyp2d);
|
||||
}
|
||||
else if (deflection > 0) {
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_Deflection1D* hyp1d = new StdMeshers_Deflection1D(hyp++, meshgen);
|
||||
#else
|
||||
StdMeshers_Deflection1D* hyp1d = new StdMeshers_Deflection1D(hyp++, 0, meshgen);
|
||||
#endif
|
||||
hyp1d->SetDeflection(deflection);
|
||||
hypoth.push_back(hyp1d);
|
||||
}
|
||||
else if (minLen > 0 && maxLen > 0) {
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_Arithmetic1D* hyp1d = new StdMeshers_Arithmetic1D(hyp++, meshgen);
|
||||
#else
|
||||
StdMeshers_Arithmetic1D* hyp1d = new StdMeshers_Arithmetic1D(hyp++, 0, meshgen);
|
||||
#endif
|
||||
hyp1d->SetLength(minLen, false);
|
||||
hyp1d->SetLength(maxLen, true);
|
||||
hypoth.push_back(hyp1d);
|
||||
}
|
||||
else {
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_AutomaticLength* hyp1d = new StdMeshers_AutomaticLength(hyp++, meshgen);
|
||||
#else
|
||||
StdMeshers_AutomaticLength* hyp1d =
|
||||
new StdMeshers_AutomaticLength(hyp++, 0, meshgen);
|
||||
#endif
|
||||
hypoth.push_back(hyp1d);
|
||||
}
|
||||
|
||||
if (regular) {
|
||||
{
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_Regular_1D* hyp1d = new StdMeshers_Regular_1D(hyp++,meshgen);
|
||||
StdMeshers_NumberOfSegments* hyp1d =
|
||||
new StdMeshers_NumberOfSegments(hyp++, meshgen);
|
||||
#else
|
||||
StdMeshers_Regular_1D* hyp1d = new StdMeshers_Regular_1D(hyp++,0,meshgen);
|
||||
StdMeshers_NumberOfSegments* hyp1d =
|
||||
new StdMeshers_NumberOfSegments(hyp++, 0, meshgen);
|
||||
#endif
|
||||
hypoth.push_back(hyp1d);
|
||||
}
|
||||
hyp1d->SetNumberOfSegments(1);
|
||||
hypoth.push_back(hyp1d);
|
||||
}
|
||||
|
||||
if (regular) {
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_Regular_1D* hyp1d = new StdMeshers_Regular_1D(hyp++, meshgen);
|
||||
#else
|
||||
StdMeshers_Regular_1D* hyp1d = new StdMeshers_Regular_1D(hyp++, 0, meshgen);
|
||||
#endif
|
||||
hypoth.push_back(hyp1d);
|
||||
}
|
||||
#if SMESH_VERSION_MAJOR < 7
|
||||
StdMeshers_TrianglePreference* hyp2d_1 = new StdMeshers_TrianglePreference(hyp++,0,meshgen);
|
||||
hypoth.push_back(hyp2d_1);
|
||||
StdMeshers_TrianglePreference* hyp2d_1 =
|
||||
new StdMeshers_TrianglePreference(hyp++, 0, meshgen);
|
||||
hypoth.push_back(hyp2d_1);
|
||||
#endif
|
||||
#if SMESH_VERSION_MAJOR >= 9
|
||||
StdMeshers_MEFISTO_2D* alg2d = new StdMeshers_MEFISTO_2D(hyp++,meshgen);
|
||||
StdMeshers_MEFISTO_2D* alg2d = new StdMeshers_MEFISTO_2D(hyp++, meshgen);
|
||||
#else
|
||||
StdMeshers_MEFISTO_2D* alg2d = new StdMeshers_MEFISTO_2D(hyp++,0,meshgen);
|
||||
StdMeshers_MEFISTO_2D* alg2d = new StdMeshers_MEFISTO_2D(hyp++, 0, meshgen);
|
||||
#endif
|
||||
hypoth.push_back(alg2d);
|
||||
} break;
|
||||
hypoth.push_back(alg2d);
|
||||
} break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Set new cout
|
||||
@@ -487,8 +510,9 @@ Mesh::MeshObject* Mesher::createMesh() const
|
||||
|
||||
// Apply the hypothesis and create the mesh
|
||||
mesh->ShapeToMesh(shape);
|
||||
for (int i=0; i<hyp;i++)
|
||||
for (int i = 0; i < hyp; i++) {
|
||||
mesh->AddHypothesis(shape, i);
|
||||
}
|
||||
meshgen->Compute(*mesh, mesh->GetShapeToMesh());
|
||||
|
||||
// Restore old cout
|
||||
@@ -502,11 +526,12 @@ Mesh::MeshObject* Mesher::createMesh() const
|
||||
mesh->ShapeToMesh(aNull);
|
||||
mesh->Clear();
|
||||
delete mesh;
|
||||
for (auto it : hypoth)
|
||||
for (auto it : hypoth) {
|
||||
delete it;
|
||||
}
|
||||
|
||||
return meshdata;
|
||||
#endif // HAVE_SMESH
|
||||
#endif// HAVE_SMESH
|
||||
}
|
||||
|
||||
Mesh::MeshObject* Mesher::createFrom(SMESH_Mesh* mesh) const
|
||||
@@ -520,9 +545,9 @@ Mesh::MeshObject* Mesher::createFrom(SMESH_Mesh* mesh) const
|
||||
verts.reserve(mesh->NbNodes());
|
||||
faces.reserve(mesh->NbFaces());
|
||||
|
||||
int index=0;
|
||||
int index = 0;
|
||||
std::map<const SMDS_MeshNode*, int> mapNodeIndex;
|
||||
for (;aNodeIter->more();) {
|
||||
for (; aNodeIter->more();) {
|
||||
const SMDS_MeshNode* aNode = aNodeIter->next();
|
||||
MeshCore::MeshPoint p;
|
||||
p.Set((float)aNode->X(), (float)aNode->Y(), (float)aNode->Z());
|
||||
@@ -530,11 +555,11 @@ Mesh::MeshObject* Mesher::createFrom(SMESH_Mesh* mesh) const
|
||||
mapNodeIndex[aNode] = index++;
|
||||
}
|
||||
|
||||
for (;aFaceIter->more();) {
|
||||
for (; aFaceIter->more();) {
|
||||
const SMDS_MeshFace* aFace = aFaceIter->next();
|
||||
if (aFace->NbNodes() == 3) {
|
||||
MeshCore::MeshFacet f;
|
||||
for (int i=0; i<3;i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
const SMDS_MeshNode* node = aFace->GetNode(i);
|
||||
f._aulPoints[i] = mapNodeIndex[node];
|
||||
}
|
||||
@@ -617,12 +642,12 @@ Mesh::MeshObject* Mesher::createFrom(SMESH_Mesh* mesh) const
|
||||
|
||||
// Two solutions are possible:
|
||||
// <4,6,7>, <4,5,6> or <4,5,7>, <5,6,7>
|
||||
Base::Vector3d v4(node4->X(),node4->Y(),node4->Z());
|
||||
Base::Vector3d v5(node5->X(),node5->Y(),node5->Z());
|
||||
Base::Vector3d v6(node6->X(),node6->Y(),node6->Z());
|
||||
Base::Vector3d v7(node7->X(),node7->Y(),node7->Z());
|
||||
double dist46 = Base::DistanceP2(v4,v6);
|
||||
double dist57 = Base::DistanceP2(v5,v7);
|
||||
Base::Vector3d v4(node4->X(), node4->Y(), node4->Z());
|
||||
Base::Vector3d v5(node5->X(), node5->Y(), node5->Z());
|
||||
Base::Vector3d v6(node6->X(), node6->Y(), node6->Z());
|
||||
Base::Vector3d v7(node7->X(), node7->Y(), node7->Z());
|
||||
double dist46 = Base::DistanceP2(v4, v6);
|
||||
double dist57 = Base::DistanceP2(v5, v7);
|
||||
if (dist46 > dist57) {
|
||||
f5._aulPoints[0] = mapNodeIndex[node4];
|
||||
f5._aulPoints[1] = mapNodeIndex[node6];
|
||||
|
||||
@@ -28,23 +28,28 @@
|
||||
#include <Base/Stream.h>
|
||||
|
||||
#ifdef HAVE_SMESH
|
||||
# include <SMESH_Version.h>
|
||||
#include <SMESH_Version.h>
|
||||
#endif
|
||||
|
||||
class TopoDS_Shape;
|
||||
class SMESH_Gen;
|
||||
class SMESH_Mesh;
|
||||
|
||||
namespace Mesh { class MeshObject; }
|
||||
namespace MeshPart {
|
||||
namespace Mesh
|
||||
{
|
||||
class MeshObject;
|
||||
}
|
||||
namespace MeshPart
|
||||
{
|
||||
|
||||
class Mesher
|
||||
{
|
||||
public:
|
||||
enum Method {
|
||||
enum Method
|
||||
{
|
||||
None = 0,
|
||||
Mefisto = 1,
|
||||
#if defined (HAVE_NETGEN)
|
||||
#if defined(HAVE_NETGEN)
|
||||
Netgen = 2,
|
||||
#endif
|
||||
Standard = 3
|
||||
@@ -54,83 +59,155 @@ public:
|
||||
~Mesher();
|
||||
|
||||
void setMethod(Method m)
|
||||
{ method = m; }
|
||||
{
|
||||
method = m;
|
||||
}
|
||||
Method getMethod() const
|
||||
{ return method; }
|
||||
{
|
||||
return method;
|
||||
}
|
||||
|
||||
/** @name Mefisto settings */
|
||||
//@{
|
||||
void setMaxLength(double s)
|
||||
{ maxLength = s; }
|
||||
{
|
||||
maxLength = s;
|
||||
}
|
||||
double getMaxLength() const
|
||||
{ return maxLength; }
|
||||
{
|
||||
return maxLength;
|
||||
}
|
||||
void setMaxArea(double s)
|
||||
{ maxArea = s; }
|
||||
{
|
||||
maxArea = s;
|
||||
}
|
||||
double getMaxArea() const
|
||||
{ return maxArea; }
|
||||
{
|
||||
return maxArea;
|
||||
}
|
||||
void setLocalLength(double s)
|
||||
{ localLength = s; }
|
||||
{
|
||||
localLength = s;
|
||||
}
|
||||
double getLocalLength() const
|
||||
{ return localLength; }
|
||||
{
|
||||
return localLength;
|
||||
}
|
||||
void setDeflection(double s)
|
||||
{ deflection = s; }
|
||||
{
|
||||
deflection = s;
|
||||
}
|
||||
double getDeflection() const
|
||||
{ return deflection; }
|
||||
{
|
||||
return deflection;
|
||||
}
|
||||
void setAngularDeflection(double s)
|
||||
{ angularDeflection = s; }
|
||||
{
|
||||
angularDeflection = s;
|
||||
}
|
||||
double getAngularDeflection() const
|
||||
{ return angularDeflection; }
|
||||
{
|
||||
return angularDeflection;
|
||||
}
|
||||
void setMinMaxLengths(double f, double l)
|
||||
{ minLen = f; maxLen = l; }
|
||||
{
|
||||
minLen = f;
|
||||
maxLen = l;
|
||||
}
|
||||
void getMinMaxLengths(double& f, double& l) const
|
||||
{ f = minLen; l= maxLen; }
|
||||
{
|
||||
f = minLen;
|
||||
l = maxLen;
|
||||
}
|
||||
void setRegular(bool s)
|
||||
{ regular = s; }
|
||||
{
|
||||
regular = s;
|
||||
}
|
||||
bool isRegular() const
|
||||
{ return regular; }
|
||||
{
|
||||
return regular;
|
||||
}
|
||||
void setRelative(bool s)
|
||||
{ relative = s; }
|
||||
{
|
||||
relative = s;
|
||||
}
|
||||
bool isRelative() const
|
||||
{ return relative; }
|
||||
{
|
||||
return relative;
|
||||
}
|
||||
void setSegments(bool s)
|
||||
{ segments = s; }
|
||||
{
|
||||
segments = s;
|
||||
}
|
||||
bool isSegments() const
|
||||
{ return segments; }
|
||||
{
|
||||
return segments;
|
||||
}
|
||||
void setColors(const std::vector<uint32_t>& c)
|
||||
{ colors = c; }
|
||||
{
|
||||
colors = c;
|
||||
}
|
||||
//@}
|
||||
|
||||
#if defined (HAVE_NETGEN)
|
||||
#if defined(HAVE_NETGEN)
|
||||
/** @name Netgen settings */
|
||||
//@{
|
||||
void setFineness(int s)
|
||||
{ fineness = s; }
|
||||
{
|
||||
fineness = s;
|
||||
}
|
||||
int getFineness() const
|
||||
{ return fineness; }
|
||||
{
|
||||
return fineness;
|
||||
}
|
||||
void setGrowthRate(double r)
|
||||
{ growthRate = r; }
|
||||
{
|
||||
growthRate = r;
|
||||
}
|
||||
double getGrowthRate() const
|
||||
{ return growthRate; }
|
||||
{
|
||||
return growthRate;
|
||||
}
|
||||
void setNbSegPerEdge(double v)
|
||||
{ nbSegPerEdge = v;}
|
||||
{
|
||||
nbSegPerEdge = v;
|
||||
}
|
||||
double getNbSegPerEdge() const
|
||||
{ return nbSegPerEdge; }
|
||||
{
|
||||
return nbSegPerEdge;
|
||||
}
|
||||
void setNbSegPerRadius(double v)
|
||||
{ nbSegPerRadius = v; }
|
||||
{
|
||||
nbSegPerRadius = v;
|
||||
}
|
||||
double getNbSegPerRadius() const
|
||||
{ return nbSegPerRadius; }
|
||||
{
|
||||
return nbSegPerRadius;
|
||||
}
|
||||
void setSecondOrder(bool on)
|
||||
{ secondOrder = on; }
|
||||
{
|
||||
secondOrder = on;
|
||||
}
|
||||
bool getSecondOrder() const
|
||||
{ return secondOrder; }
|
||||
{
|
||||
return secondOrder;
|
||||
}
|
||||
void setOptimize(bool on)
|
||||
{ optimize = on;}
|
||||
{
|
||||
optimize = on;
|
||||
}
|
||||
bool getOptimize() const
|
||||
{ return optimize; }
|
||||
{
|
||||
return optimize;
|
||||
}
|
||||
void setQuadAllowed(bool on)
|
||||
{ allowquad = on;}
|
||||
{
|
||||
allowquad = on;
|
||||
}
|
||||
bool isQuadAllowed() const
|
||||
{ return allowquad; }
|
||||
{
|
||||
return allowquad;
|
||||
}
|
||||
//@}
|
||||
#endif
|
||||
|
||||
@@ -142,31 +219,31 @@ private:
|
||||
|
||||
private:
|
||||
const TopoDS_Shape& shape;
|
||||
Method method{None};
|
||||
double maxLength{0};
|
||||
double maxArea{0};
|
||||
double localLength{0};
|
||||
double deflection{0};
|
||||
double angularDeflection{0.5};
|
||||
double minLen{0}, maxLen{0};
|
||||
bool relative{false};
|
||||
bool regular{false};
|
||||
bool segments{false};
|
||||
#if defined (HAVE_NETGEN)
|
||||
int fineness{5};
|
||||
double growthRate{0};
|
||||
double nbSegPerEdge{0};
|
||||
double nbSegPerRadius{0};
|
||||
bool secondOrder{false};
|
||||
bool optimize{true};
|
||||
bool allowquad{false};
|
||||
Method method {None};
|
||||
double maxLength {0};
|
||||
double maxArea {0};
|
||||
double localLength {0};
|
||||
double deflection {0};
|
||||
double angularDeflection {0.5};
|
||||
double minLen {0}, maxLen {0};
|
||||
bool relative {false};
|
||||
bool regular {false};
|
||||
bool segments {false};
|
||||
#if defined(HAVE_NETGEN)
|
||||
int fineness {5};
|
||||
double growthRate {0};
|
||||
double nbSegPerEdge {0};
|
||||
double nbSegPerRadius {0};
|
||||
bool secondOrder {false};
|
||||
bool optimize {true};
|
||||
bool allowquad {false};
|
||||
#endif
|
||||
std::vector<uint32_t> colors;
|
||||
|
||||
static SMESH_Gen *_mesh_gen;
|
||||
static SMESH_Gen* _mesh_gen;
|
||||
};
|
||||
|
||||
class MeshingOutput : public std::streambuf
|
||||
class MeshingOutput: public std::streambuf
|
||||
{
|
||||
public:
|
||||
MeshingOutput();
|
||||
@@ -179,6 +256,6 @@ private:
|
||||
std::string buffer;
|
||||
};
|
||||
|
||||
} // namespace MeshPart
|
||||
}// namespace MeshPart
|
||||
|
||||
#endif // MESHPART_MESHER_H
|
||||
#endif// MESHPART_MESHER_H
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
#include <FCConfig.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(disable : 4244)
|
||||
# pragma warning(disable : 4275)
|
||||
# pragma warning(disable : 4290)
|
||||
# pragma warning(disable : 4522)
|
||||
#pragma warning(disable : 4244)
|
||||
#pragma warning(disable : 4275)
|
||||
#pragma warning(disable : 4290)
|
||||
#pragma warning(disable : 4522)
|
||||
#endif
|
||||
|
||||
#ifdef _PreComp_
|
||||
@@ -49,24 +49,23 @@
|
||||
#include <vector>
|
||||
|
||||
// OpenCasCade
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <BndLib_Add3dCurve.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepBuilderAPI_MakePolygon.hxx>
|
||||
#include <BRepBuilderAPI_MakeVertex.hxx>
|
||||
#include <BRepExtrema_DistShapeShape.hxx>
|
||||
#include <BRepMesh_IncrementalMesh.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BndLib_Add3dCurve.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <GCPnts_AbscissaPoint.hxx>
|
||||
#include <GCPnts_UniformDeflection.hxx>
|
||||
#include <GCPnts_UniformAbscissa.hxx>
|
||||
#include <GCPnts_UniformDeflection.hxx>
|
||||
#include <GeomAPI_IntCS.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <GeomAPI_IntCS.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
@@ -77,6 +76,7 @@
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
|
||||
#endif // _PreComp_
|
||||
#endif// _PreComp_
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user