Fix point-on-circle constraints to work with arcs too, and lock
extrudes normal to workplane if a workplane is active when the extrusion is created. [git-p4: depot-paths = "//depot/solvespace/": change = 1724]
This commit is contained in:
parent
65ea276fa4
commit
2ec23ffa3e
|
@ -496,7 +496,7 @@ void Constraint::Generate(IdList<Equation,hEquation> *l) {
|
||||||
case PT_ON_CIRCLE: {
|
case PT_ON_CIRCLE: {
|
||||||
Entity *circle = SS.GetEntity(entityA);
|
Entity *circle = SS.GetEntity(entityA);
|
||||||
hEntity center = circle->point[0];
|
hEntity center = circle->point[0];
|
||||||
Expr *radius = SS.GetEntity(circle->distance)->DistanceGetExpr();
|
Expr *radius = circle->CircleGetRadiusExpr();
|
||||||
AddEq(l, Distance(workplane, ptA, center)->Minus(radius), 0);
|
AddEq(l, Distance(workplane, ptA, center)->Minus(radius), 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ Vector Entity::VectorGetRefPoint(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entity::IsCircle(void) {
|
bool Entity::IsCircle(void) {
|
||||||
return (type == CIRCLE);
|
return (type == CIRCLE) || (type == ARC_OF_CIRCLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Expr *Entity::CircleGetRadiusExpr(void) {
|
Expr *Entity::CircleGetRadiusExpr(void) {
|
||||||
|
|
|
@ -43,8 +43,8 @@ class SEdgeList {
|
||||||
public:
|
public:
|
||||||
SList<SEdge> l;
|
SList<SEdge> l;
|
||||||
|
|
||||||
void InsertEdgeBreaking(SEdge *e);
|
|
||||||
bool AssemblePolygon(SPolygon *dest, SEdge *errorAt);
|
bool AssemblePolygon(SPolygon *dest, SEdge *errorAt);
|
||||||
|
void BreakEdgesInto(SEdgeList *el);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SPoint {
|
class SPoint {
|
||||||
|
|
19
sketch.cpp
19
sketch.cpp
|
@ -74,6 +74,7 @@ void Group::MenuGroup(int id) {
|
||||||
case GraphicsWindow::MNU_GROUP_EXTRUDE:
|
case GraphicsWindow::MNU_GROUP_EXTRUDE:
|
||||||
g.type = EXTRUDE;
|
g.type = EXTRUDE;
|
||||||
g.opA = SS.GW.activeGroup;
|
g.opA = SS.GW.activeGroup;
|
||||||
|
g.wrkpl.entityB = SS.GW.activeWorkplane;
|
||||||
g.name.strcpy("extrude");
|
g.name.strcpy("extrude");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -207,6 +208,7 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
|
||||||
}
|
}
|
||||||
|
|
||||||
void Group::GenerateEquations(IdList<Equation,hEquation> *l) {
|
void Group::GenerateEquations(IdList<Equation,hEquation> *l) {
|
||||||
|
Equation eq;
|
||||||
if(type == ROTATE) {
|
if(type == ROTATE) {
|
||||||
// Normalize the quaternion
|
// Normalize the quaternion
|
||||||
ExprQuaternion q = {
|
ExprQuaternion q = {
|
||||||
|
@ -214,10 +216,25 @@ void Group::GenerateEquations(IdList<Equation,hEquation> *l) {
|
||||||
Expr::FromParam(h.param(4)),
|
Expr::FromParam(h.param(4)),
|
||||||
Expr::FromParam(h.param(5)),
|
Expr::FromParam(h.param(5)),
|
||||||
Expr::FromParam(h.param(6)) };
|
Expr::FromParam(h.param(6)) };
|
||||||
Equation eq;
|
|
||||||
eq.e = (q.Magnitude())->Minus(Expr::FromConstant(1));
|
eq.e = (q.Magnitude())->Minus(Expr::FromConstant(1));
|
||||||
eq.h = h.equation(0);
|
eq.h = h.equation(0);
|
||||||
l->Add(&eq);
|
l->Add(&eq);
|
||||||
|
} else if(type == EXTRUDE) {
|
||||||
|
if(wrkpl.entityB.v != Entity::FREE_IN_3D.v) {
|
||||||
|
Entity *w = SS.GetEntity(wrkpl.entityB);
|
||||||
|
ExprVector u = w->Normal()->NormalExprsU();
|
||||||
|
ExprVector v = w->Normal()->NormalExprsV();
|
||||||
|
ExprVector extruden = {
|
||||||
|
Expr::FromParam(h.param(0)),
|
||||||
|
Expr::FromParam(h.param(1)),
|
||||||
|
Expr::FromParam(h.param(2)) };
|
||||||
|
eq.e = u.Dot(extruden);
|
||||||
|
eq.h = h.equation(0);
|
||||||
|
l->Add(&eq);
|
||||||
|
eq.e = v.Dot(extruden);
|
||||||
|
eq.h = h.equation(1);
|
||||||
|
l->Add(&eq);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
sketch.h
2
sketch.h
|
@ -419,7 +419,7 @@ inline hEntity hGroup::entity(int i)
|
||||||
inline hParam hGroup::param(int i)
|
inline hParam hGroup::param(int i)
|
||||||
{ hParam r; r.v = 0x80000000 | (v << 16) | i; return r; }
|
{ hParam r; r.v = 0x80000000 | (v << 16) | i; return r; }
|
||||||
inline hEquation hGroup::equation(int i)
|
inline hEquation hGroup::equation(int i)
|
||||||
{ if(i != 0) oops(); hEquation r; r.v = v | 0x80000000; return r; }
|
{ hEquation r; r.v = (v << 16) | 0x80000000 | i; return r; }
|
||||||
|
|
||||||
inline bool hRequest::IsFromReferences(void) {
|
inline bool hRequest::IsFromReferences(void) {
|
||||||
if(v == Request::HREQUEST_REFERENCE_XY.v) return true;
|
if(v == Request::HREQUEST_REFERENCE_XY.v) return true;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user