|
@ -19,11 +19,9 @@ inline Vec2 get2DRepOf3DPt(const Vec3 &pt3D, const Vec3 &u, const Vec3 &v, const |
|
|
Vec3 OP = pt3D - localO; |
|
|
Vec3 OP = pt3D - localO; |
|
|
return {OP.dot(u), OP.dot(v)}; |
|
|
return {OP.dot(u), OP.dot(v)}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
inline Vec2 get2DRepOf3DDir(const Vec3 &dir, const Vec3 &u, const Vec3 &v) { |
|
|
inline Vec2 get2DRepOf3DDir(const Vec3 &dir, const Vec3 &u, const Vec3 &v) { |
|
|
return Vec2{dir.dot(u), dir.dot(v)}.normalize(); |
|
|
return Vec2{dir.dot(u), dir.dot(v)}.normalize(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class IExtrudedSolid : public ISolid { |
|
|
class IExtrudedSolid : public ISolid { |
|
|
public: |
|
|
public: |
|
|
std::vector<Polyline> _profiles; // TODO: may be replaced by const ref to profile
|
|
|
std::vector<Polyline> _profiles; // TODO: may be replaced by const ref to profile
|
|
@ -51,7 +49,6 @@ private: |
|
|
std::vector<std::vector<CircularArc<Vec2>>> _localArcs2d; |
|
|
std::vector<std::vector<CircularArc<Vec2>>> _localArcs2d; |
|
|
// Pt2Array _localCircleCenter2D;
|
|
|
// Pt2Array _localCircleCenter2D;
|
|
|
// Pt2Array _localInCircleDir;
|
|
|
// Pt2Array _localInCircleDir;
|
|
|
|
|
|
|
|
|
public: |
|
|
public: |
|
|
ExtrudedSolidPolyline(std::vector<Polyline> profiles, Polyline axis, real rScale) |
|
|
ExtrudedSolidPolyline(std::vector<Polyline> profiles, Polyline axis, real rScale) |
|
|
: IExtrudedSolid(std::move(profiles), rScale), _axis(std::move(axis)) { |
|
|
: IExtrudedSolid(std::move(profiles), rScale), _axis(std::move(axis)) { |
|
@ -90,11 +87,17 @@ public: |
|
|
ClosestDescOnSeg closestDescToAxis = _axis.getClosestParam(p); |
|
|
ClosestDescOnSeg closestDescToAxis = _axis.getClosestParam(p); |
|
|
// TNB coordinate system
|
|
|
// TNB coordinate system
|
|
|
auto t = closestDescToAxis.t; |
|
|
auto t = closestDescToAxis.t; |
|
|
|
|
|
Vec3 Q = _axis.eval(t); // closest point on axis
|
|
|
|
|
|
Vec3 QP = p - Q; |
|
|
Vec3 T = _axis.der1(t).normalize(); |
|
|
Vec3 T = _axis.der1(t).normalize(); |
|
|
|
|
|
if (_axis.isEndParm(t) && fabs(QP.dot(T)) > EPS) { |
|
|
|
|
|
// project p to the plane passing through Q and perpendicular to T
|
|
|
|
|
|
Vec3 projP = p + T * (-QP.dot(T)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Vec3 N = _axis.der2(t).normalize(); |
|
|
Vec3 N = _axis.der2(t).normalize(); |
|
|
Vec3 B = T.cross(N); |
|
|
Vec3 B = T.cross(N); |
|
|
Vec3 Q = _axis.eval(t); |
|
|
|
|
|
Vec3 QP = p - Q; |
|
|
|
|
|
auto p2D = get2DRepOf3DPt(QP, N, B, Q); |
|
|
auto p2D = get2DRepOf3DPt(QP, N, B, Q); |
|
|
// PMC
|
|
|
// PMC
|
|
|
PtBoundaryRelation ptProfileRelation = Inside; |
|
|
PtBoundaryRelation ptProfileRelation = Inside; |
|
@ -109,6 +112,7 @@ public: |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// distance
|
|
|
// distance
|
|
|
ClosestDescOnSeg closestDescToProfile{}; |
|
|
ClosestDescOnSeg closestDescToProfile{}; |
|
|
for (int i = 0; i < _localArcs2d.size(); ++i) { |
|
|
for (int i = 0; i < _localArcs2d.size(); ++i) { |
|
@ -122,7 +126,7 @@ public: |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private: |
|
|
private: |
|
|
/**
|
|
|
/** 低于2Dprofile的内外部判定
|
|
|
* in + in = out |
|
|
* in + in = out |
|
|
* in + out = in |
|
|
* in + out = in |
|
|
* out + in = in |
|
|
* out + in = in |
|
|