Sketcher: [skip ci] fix inconsistent indentations in SketchObject::rebuildExternalGeometry
This commit is contained in:
@@ -5752,11 +5752,13 @@ static gp_Vec ProjVecOnPlane_UVN( const gp_Vec& V, const gp_Pln& Pl)
|
||||
}
|
||||
|
||||
// Auxiliary Method: returns vector projection in XYZ space
|
||||
#if 0
|
||||
static gp_Vec ProjVecOnPlane_XYZ( const gp_Vec& V, const gp_Pln& Pl)
|
||||
{
|
||||
return V.Dot(Pl.Position().XDirection()) * Pl.Position().XDirection() +
|
||||
V.Dot(Pl.Position().YDirection()) * Pl.Position().YDirection();
|
||||
V.Dot(Pl.Position().YDirection()) * Pl.Position().YDirection();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Auxiliary Method: returns point projection in UV space of plane
|
||||
static gp_Vec2d ProjPointOnPlane_UV( const gp_Pnt& P, const gp_Pln& Pl)
|
||||
@@ -6051,133 +6053,133 @@ void SketchObject::rebuildExternalGeometry(void)
|
||||
}
|
||||
}
|
||||
else {
|
||||
// creates an ellipse or a segment
|
||||
// creates an ellipse or a segment
|
||||
|
||||
gp_Dir vec1 = sketchPlane.Axis().Direction();
|
||||
gp_Dir vec2 = curve.Circle().Axis().Direction();
|
||||
gp_Circ origCircle = curve.Circle();
|
||||
gp_Dir vec1 = sketchPlane.Axis().Direction();
|
||||
gp_Dir vec2 = curve.Circle().Axis().Direction();
|
||||
gp_Circ origCircle = curve.Circle();
|
||||
|
||||
if (vec1.IsNormal(vec2, Precision::Angular())) { // circle's normal vector in plane:
|
||||
// projection is a line
|
||||
// define center by projection
|
||||
gp_Pnt cnt = origCircle.Location();
|
||||
GeomAPI_ProjectPointOnSurf proj(cnt,gPlane);
|
||||
cnt = proj.NearestPoint();
|
||||
if (vec1.IsNormal(vec2, Precision::Angular())) { // circle's normal vector in plane:
|
||||
// projection is a line
|
||||
// define center by projection
|
||||
gp_Pnt cnt = origCircle.Location();
|
||||
GeomAPI_ProjectPointOnSurf proj(cnt,gPlane);
|
||||
cnt = proj.NearestPoint();
|
||||
|
||||
gp_Dir dirOrientation = gp_Dir(vec1 ^ vec2);
|
||||
gp_Dir dirLine(dirOrientation);
|
||||
gp_Dir dirOrientation = gp_Dir(vec1 ^ vec2);
|
||||
gp_Dir dirLine(dirOrientation);
|
||||
|
||||
Part::GeomLineSegment * projectedSegment = new Part::GeomLineSegment();
|
||||
Geom_Line ligne(cnt, dirLine); // helper object to compute end points
|
||||
gp_Pnt P1, P2; // end points of the segment, OCC style
|
||||
Part::GeomLineSegment * projectedSegment = new Part::GeomLineSegment();
|
||||
Geom_Line ligne(cnt, dirLine); // helper object to compute end points
|
||||
gp_Pnt P1, P2; // end points of the segment, OCC style
|
||||
|
||||
ligne.D0(-origCircle.Radius(), P1);
|
||||
ligne.D0( origCircle.Radius(), P2);
|
||||
ligne.D0(-origCircle.Radius(), P1);
|
||||
ligne.D0( origCircle.Radius(), P2);
|
||||
|
||||
if (!curve.IsClosed()) { // arc of circle
|
||||
if (!curve.IsClosed()) { // arc of circle
|
||||
|
||||
gp_Pnt pntF = curve.Value(curve.FirstParameter()); // start point of arc of circle
|
||||
gp_Pnt pntL = curve.Value(curve.LastParameter()); // end point of arc of circle
|
||||
gp_Pnt pntF = curve.Value(curve.FirstParameter()); // start point of arc of circle
|
||||
gp_Pnt pntL = curve.Value(curve.LastParameter()); // end point of arc of circle
|
||||
|
||||
double alpha = dirOrientation.AngleWithRef(curve.Circle().XAxis().Direction(), curve.Circle().Axis().Direction());
|
||||
double alpha = dirOrientation.AngleWithRef(curve.Circle().XAxis().Direction(), curve.Circle().Axis().Direction());
|
||||
|
||||
double baseAngle = curve.FirstParameter();
|
||||
double baseAngle = curve.FirstParameter();
|
||||
|
||||
int tours = 0;
|
||||
double startAngle = baseAngle + alpha;
|
||||
// bring startAngle back in [-pi/2 , 3pi/2[
|
||||
while(startAngle < -M_PI/2.0 && tours < 10) {
|
||||
startAngle = baseAngle + ++tours*2.0*M_PI + alpha;
|
||||
}
|
||||
while(startAngle >= 3.0*M_PI/2.0 && tours > -10) {
|
||||
startAngle = baseAngle + --tours*2.0*M_PI + alpha;
|
||||
}
|
||||
|
||||
double endAngle = curve.LastParameter() + startAngle - baseAngle; // apply same offset to end angle
|
||||
|
||||
if (startAngle <= 0.0) {
|
||||
if (endAngle <= 0.0) {
|
||||
P1 = ProjPointOnPlane_XYZ(pntF, sketchPlane);
|
||||
P2 = ProjPointOnPlane_XYZ(pntL, sketchPlane);
|
||||
} else {
|
||||
if (endAngle <= fabs(startAngle)) {
|
||||
// P2 = P2 already defined
|
||||
P1 = ProjPointOnPlane_XYZ(pntF, sketchPlane);
|
||||
} else if (endAngle < M_PI) {
|
||||
// P2 = P2, already defined
|
||||
P1 = ProjPointOnPlane_XYZ(pntL, sketchPlane);
|
||||
} else {
|
||||
// P1 = P1, already defined
|
||||
// P2 = P2, already defined
|
||||
}
|
||||
int tours = 0;
|
||||
double startAngle = baseAngle + alpha;
|
||||
// bring startAngle back in [-pi/2 , 3pi/2[
|
||||
while(startAngle < -M_PI/2.0 && tours < 10) {
|
||||
startAngle = baseAngle + ++tours*2.0*M_PI + alpha;
|
||||
}
|
||||
} else if (startAngle < M_PI) {
|
||||
if (endAngle < M_PI) {
|
||||
P1 = ProjPointOnPlane_XYZ(pntF, sketchPlane);
|
||||
P2 = ProjPointOnPlane_XYZ(pntL, sketchPlane);
|
||||
} else if (endAngle < 2.0 * M_PI - startAngle) {
|
||||
P2 = ProjPointOnPlane_XYZ(pntF, sketchPlane);
|
||||
// P1 = P1, already defined
|
||||
} else if (endAngle < 2.0 * M_PI) {
|
||||
P2 = ProjPointOnPlane_XYZ(pntL, sketchPlane);
|
||||
// P1 = P1, already defined
|
||||
} else {
|
||||
// P1 = P1, alreday defined
|
||||
// P2 = P2, already defined
|
||||
while(startAngle >= 3.0*M_PI/2.0 && tours > -10) {
|
||||
startAngle = baseAngle + --tours*2.0*M_PI + alpha;
|
||||
}
|
||||
} else {
|
||||
if (endAngle < 2*M_PI) {
|
||||
P1 = ProjPointOnPlane_XYZ(pntF, sketchPlane);
|
||||
P2 = ProjPointOnPlane_XYZ(pntL, sketchPlane);
|
||||
} else if (endAngle < 4*M_PI - startAngle) {
|
||||
P1 = ProjPointOnPlane_XYZ(pntF, sketchPlane);
|
||||
// P2 = P2, already defined
|
||||
} else if (endAngle < 3*M_PI) {
|
||||
// P1 = P1, already defined
|
||||
P2 = ProjPointOnPlane_XYZ(pntL, sketchPlane);
|
||||
|
||||
double endAngle = curve.LastParameter() + startAngle - baseAngle; // apply same offset to end angle
|
||||
|
||||
if (startAngle <= 0.0) {
|
||||
if (endAngle <= 0.0) {
|
||||
P1 = ProjPointOnPlane_XYZ(pntF, sketchPlane);
|
||||
P2 = ProjPointOnPlane_XYZ(pntL, sketchPlane);
|
||||
} else {
|
||||
if (endAngle <= fabs(startAngle)) {
|
||||
// P2 = P2 already defined
|
||||
P1 = ProjPointOnPlane_XYZ(pntF, sketchPlane);
|
||||
} else if (endAngle < M_PI) {
|
||||
// P2 = P2, already defined
|
||||
P1 = ProjPointOnPlane_XYZ(pntL, sketchPlane);
|
||||
} else {
|
||||
// P1 = P1, already defined
|
||||
// P2 = P2, already defined
|
||||
}
|
||||
}
|
||||
} else if (startAngle < M_PI) {
|
||||
if (endAngle < M_PI) {
|
||||
P1 = ProjPointOnPlane_XYZ(pntF, sketchPlane);
|
||||
P2 = ProjPointOnPlane_XYZ(pntL, sketchPlane);
|
||||
} else if (endAngle < 2.0 * M_PI - startAngle) {
|
||||
P2 = ProjPointOnPlane_XYZ(pntF, sketchPlane);
|
||||
// P1 = P1, already defined
|
||||
} else if (endAngle < 2.0 * M_PI) {
|
||||
P2 = ProjPointOnPlane_XYZ(pntL, sketchPlane);
|
||||
// P1 = P1, already defined
|
||||
} else {
|
||||
// P1 = P1, alreday defined
|
||||
// P2 = P2, already defined
|
||||
}
|
||||
} else {
|
||||
// P1 = P1, already defined
|
||||
// P2 = P2, already defined
|
||||
if (endAngle < 2*M_PI) {
|
||||
P1 = ProjPointOnPlane_XYZ(pntF, sketchPlane);
|
||||
P2 = ProjPointOnPlane_XYZ(pntL, sketchPlane);
|
||||
} else if (endAngle < 4*M_PI - startAngle) {
|
||||
P1 = ProjPointOnPlane_XYZ(pntF, sketchPlane);
|
||||
// P2 = P2, already defined
|
||||
} else if (endAngle < 3*M_PI) {
|
||||
// P1 = P1, already defined
|
||||
P2 = ProjPointOnPlane_XYZ(pntL, sketchPlane);
|
||||
} else {
|
||||
// P1 = P1, already defined
|
||||
// P2 = P2, already defined
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Base::Vector3d p1(P1.X(),P1.Y(),P1.Z()); // ends of segment FCAD style
|
||||
Base::Vector3d p2(P2.X(),P2.Y(),P2.Z());
|
||||
invPlm.multVec(p1,p1);
|
||||
invPlm.multVec(p2,p2);
|
||||
Base::Vector3d p1(P1.X(),P1.Y(),P1.Z()); // ends of segment FCAD style
|
||||
Base::Vector3d p2(P2.X(),P2.Y(),P2.Z());
|
||||
invPlm.multVec(p1,p1);
|
||||
invPlm.multVec(p2,p2);
|
||||
|
||||
projectedSegment->setPoints(p1, p2);
|
||||
projectedSegment->Construction = true;
|
||||
ExternalGeo.push_back(projectedSegment);
|
||||
}
|
||||
else { // general case, full circle
|
||||
gp_Pnt cnt = origCircle.Location();
|
||||
GeomAPI_ProjectPointOnSurf proj(cnt,gPlane);
|
||||
cnt = proj.NearestPoint(); // projection of circle center on sketch plane, 3D space
|
||||
Base::Vector3d p(cnt.X(),cnt.Y(),cnt.Z()); // converting to FCAD style vector
|
||||
invPlm.multVec(p,p); // transforming towards sketch's (x,y) coordinates
|
||||
projectedSegment->setPoints(p1, p2);
|
||||
projectedSegment->Construction = true;
|
||||
ExternalGeo.push_back(projectedSegment);
|
||||
}
|
||||
else { // general case, full circle
|
||||
gp_Pnt cnt = origCircle.Location();
|
||||
GeomAPI_ProjectPointOnSurf proj(cnt,gPlane);
|
||||
cnt = proj.NearestPoint(); // projection of circle center on sketch plane, 3D space
|
||||
Base::Vector3d p(cnt.X(),cnt.Y(),cnt.Z()); // converting to FCAD style vector
|
||||
invPlm.multVec(p,p); // transforming towards sketch's (x,y) coordinates
|
||||
|
||||
|
||||
gp_Vec vecMajorAxis = vec1 ^ vec2; // major axis in 3D space
|
||||
gp_Vec vecMajorAxis = vec1 ^ vec2; // major axis in 3D space
|
||||
|
||||
double minorRadius; // TODO use data type of vectors around...
|
||||
double cosTheta;
|
||||
cosTheta = fabs(vec1.Dot(vec2)); // cos of angle between the two planes, assuming vectirs are normalized to 1
|
||||
minorRadius = origCircle.Radius() * cosTheta;
|
||||
double minorRadius; // TODO use data type of vectors around...
|
||||
double cosTheta;
|
||||
cosTheta = fabs(vec1.Dot(vec2)); // cos of angle between the two planes, assuming vectirs are normalized to 1
|
||||
minorRadius = origCircle.Radius() * cosTheta;
|
||||
|
||||
Base::Vector3d vectorMajorAxis(vecMajorAxis.X(),vecMajorAxis.Y(),vecMajorAxis.Z()); // maj axis into FCAD style vector
|
||||
invRot.multVec(vectorMajorAxis, vectorMajorAxis); // transforming to sketch's (x,y) coordinates
|
||||
vecMajorAxis.SetXYZ(gp_XYZ(vectorMajorAxis[0], vectorMajorAxis[1], vectorMajorAxis[2])); // back to OCC
|
||||
Base::Vector3d vectorMajorAxis(vecMajorAxis.X(),vecMajorAxis.Y(),vecMajorAxis.Z()); // maj axis into FCAD style vector
|
||||
invRot.multVec(vectorMajorAxis, vectorMajorAxis); // transforming to sketch's (x,y) coordinates
|
||||
vecMajorAxis.SetXYZ(gp_XYZ(vectorMajorAxis[0], vectorMajorAxis[1], vectorMajorAxis[2])); // back to OCC
|
||||
|
||||
gp_Ax2 refFrameEllipse(gp_Pnt(gp_XYZ(p[0], p[1], p[2])), gp_Vec(0, 0, 1), vecMajorAxis); // NB: force normal of ellipse to be normal of sketch's plane.
|
||||
Handle(Geom_Ellipse) curve = new Geom_Ellipse(refFrameEllipse, origCircle.Radius(), minorRadius);
|
||||
Part::GeomEllipse* ellipse = new Part::GeomEllipse();
|
||||
ellipse->setHandle(curve);
|
||||
ellipse->Construction = true;
|
||||
gp_Ax2 refFrameEllipse(gp_Pnt(gp_XYZ(p[0], p[1], p[2])), gp_Vec(0, 0, 1), vecMajorAxis); // NB: force normal of ellipse to be normal of sketch's plane.
|
||||
Handle(Geom_Ellipse) curve = new Geom_Ellipse(refFrameEllipse, origCircle.Radius(), minorRadius);
|
||||
Part::GeomEllipse* ellipse = new Part::GeomEllipse();
|
||||
ellipse->setHandle(curve);
|
||||
ellipse->Construction = true;
|
||||
|
||||
ExternalGeo.push_back(ellipse);
|
||||
}
|
||||
ExternalGeo.push_back(ellipse);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (curve.GetType() == GeomAbs_Ellipse) {
|
||||
@@ -6193,17 +6195,16 @@ void SketchObject::rebuildExternalGeometry(void)
|
||||
gp_Vec origAxisMinor = elipsOrig.MinorRadius() * gp_Vec(origAxisMinorDir);
|
||||
|
||||
if (sketchPlane.Position().Direction().IsParallel(elipsOrig.Position().Direction(), Precision::Angular())) {
|
||||
elipsDest = elipsOrig.Translated(origCenter, destCenter);
|
||||
Handle(Geom_Ellipse) curve = new Geom_Ellipse(elipsDest);
|
||||
Part::GeomEllipse* ellipse = new Part::GeomEllipse();
|
||||
ellipse->setHandle(curve);
|
||||
ellipse->Construction = true;
|
||||
elipsDest = elipsOrig.Translated(origCenter, destCenter);
|
||||
Handle(Geom_Ellipse) curve = new Geom_Ellipse(elipsDest);
|
||||
Part::GeomEllipse* ellipse = new Part::GeomEllipse();
|
||||
ellipse->setHandle(curve);
|
||||
ellipse->Construction = true;
|
||||
|
||||
ExternalGeo.push_back(ellipse);
|
||||
ExternalGeo.push_back(ellipse);
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
// look for major axis of projected ellipse
|
||||
//
|
||||
// t is the parameter along the origin ellipse
|
||||
@@ -6227,12 +6228,12 @@ void SketchObject::rebuildExternalGeometry(void)
|
||||
double rDest = destAxisMinor.Magnitude();
|
||||
|
||||
if (RDest < rDest) {
|
||||
double rTmp = rDest;
|
||||
rDest = RDest;
|
||||
RDest = rTmp;
|
||||
gp_Vec axisTmp = destAxisMajor;
|
||||
destAxisMajor = destAxisMinor;
|
||||
destAxisMinor = axisTmp;
|
||||
double rTmp = rDest;
|
||||
rDest = RDest;
|
||||
RDest = rTmp;
|
||||
gp_Vec axisTmp = destAxisMajor;
|
||||
destAxisMajor = destAxisMinor;
|
||||
destAxisMinor = axisTmp;
|
||||
}
|
||||
|
||||
double sens = sketchAx3.Direction().Dot(elipsOrig.Position().Direction());
|
||||
@@ -6241,40 +6242,38 @@ void SketchObject::rebuildExternalGeometry(void)
|
||||
gp_Dir(destAxisMajor));
|
||||
|
||||
if ((RDest - rDest) < (double) Precision::Confusion()) { // projection is a circle
|
||||
Handle(Geom_Circle) curve = new Geom_Circle(destCurveAx2, 0.5 * (rDest + RDest));
|
||||
Part::GeomCircle* circle = new Part::GeomCircle();
|
||||
circle->setHandle(curve);
|
||||
circle->Construction = true;
|
||||
Handle(Geom_Circle) curve = new Geom_Circle(destCurveAx2, 0.5 * (rDest + RDest));
|
||||
Part::GeomCircle* circle = new Part::GeomCircle();
|
||||
circle->setHandle(curve);
|
||||
circle->Construction = true;
|
||||
|
||||
ExternalGeo.push_back(circle);
|
||||
ExternalGeo.push_back(circle);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sketchPlane.Position().Direction().IsNormal(elipsOrig.Position().Direction(), Precision::Angular())) {
|
||||
gp_Vec start = gp_Vec(destCenter.XYZ()) + destAxisMajor;
|
||||
gp_Vec end = gp_Vec(destCenter.XYZ()) - destAxisMajor;
|
||||
else {
|
||||
if (sketchPlane.Position().Direction().IsNormal(elipsOrig.Position().Direction(), Precision::Angular())) {
|
||||
gp_Vec start = gp_Vec(destCenter.XYZ()) + destAxisMajor;
|
||||
gp_Vec end = gp_Vec(destCenter.XYZ()) - destAxisMajor;
|
||||
|
||||
Part::GeomLineSegment * projectedSegment = new Part::GeomLineSegment();
|
||||
projectedSegment->setPoints(Base::Vector3d(start.X(), start.Y(), start.Z()),
|
||||
Base::Vector3d(end.X(), end.Y(), end.Z()));
|
||||
projectedSegment->Construction = true;
|
||||
ExternalGeo.push_back(projectedSegment);
|
||||
}
|
||||
else
|
||||
{
|
||||
Part::GeomLineSegment * projectedSegment = new Part::GeomLineSegment();
|
||||
projectedSegment->setPoints(Base::Vector3d(start.X(), start.Y(), start.Z()),
|
||||
Base::Vector3d(end.X(), end.Y(), end.Z()));
|
||||
projectedSegment->Construction = true;
|
||||
ExternalGeo.push_back(projectedSegment);
|
||||
}
|
||||
else {
|
||||
|
||||
elipsDest.SetPosition(destCurveAx2);
|
||||
elipsDest.SetMajorRadius(destAxisMajor.Magnitude());
|
||||
elipsDest.SetMinorRadius(destAxisMinor.Magnitude());
|
||||
elipsDest.SetPosition(destCurveAx2);
|
||||
elipsDest.SetMajorRadius(destAxisMajor.Magnitude());
|
||||
elipsDest.SetMinorRadius(destAxisMinor.Magnitude());
|
||||
|
||||
|
||||
Handle(Geom_Ellipse) curve = new Geom_Ellipse(elipsDest);
|
||||
Part::GeomEllipse* ellipse = new Part::GeomEllipse();
|
||||
ellipse->setHandle(curve);
|
||||
ellipse->Construction = true;
|
||||
Handle(Geom_Ellipse) curve = new Geom_Ellipse(elipsDest);
|
||||
Part::GeomEllipse* ellipse = new Part::GeomEllipse();
|
||||
ellipse->setHandle(curve);
|
||||
ellipse->Construction = true;
|
||||
|
||||
ExternalGeo.push_back(ellipse);
|
||||
}
|
||||
ExternalGeo.push_back(ellipse);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user