Skip to content

Commit

Permalink
Fix XAxis orientation
Browse files Browse the repository at this point in the history
Remove need for XAxisDirection property
  • Loading branch information
WandererFan authored and yorikvanhavre committed Oct 31, 2016
1 parent 2f6a779 commit ce9f4f1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/Mod/TechDraw/App/DrawUtil.cpp
Expand Up @@ -197,4 +197,8 @@ void DrawUtil::dumpEdge(char* label, int i, TopoDS_Edge e)
Base::Console().Message("%s edge:%d start:(%.3f,%.3f,%.3f) end:(%.2f,%.3f,%.3f)\n",label,i,
vStart.X(),vStart.Y(),vStart.Z(),vEnd.X(),vEnd.Y(),vEnd.Z());
}
const char* DrawUtil::printBool(bool b)
{
return (b ? "True" : "False");
}
//==================================
1 change: 1 addition & 0 deletions src/Mod/TechDraw/App/DrawUtil.h
Expand Up @@ -49,6 +49,7 @@ class TechDrawExport DrawUtil {
static void countFaces(const char* label, const TopoDS_Shape& s);
static void countWires(const char* label, const TopoDS_Shape& s);
static void countEdges(const char* label, const TopoDS_Shape& s);
static const char* printBool(bool b);
};

} //end namespace TechDraw
Expand Down
24 changes: 16 additions & 8 deletions src/Mod/TechDraw/App/GeometryObject.cpp
Expand Up @@ -80,8 +80,6 @@ struct EdgePoints {
TopoDS_Edge edge;
};

//debugging routine signatures
const char* _printBool(bool b);

GeometryObject::GeometryObject(DrawViewPart* parent) :
Tolerance(0.05f),
Expand Down Expand Up @@ -166,6 +164,18 @@ void GeometryObject::projectShape(const TopoDS_Shape& input,
const Base::Vector3d& direction,
const Base::Vector3d& xAxis)
{
Base::Vector3d stdZ(0.0,0.0,1.0);
Base::Vector3d flipDirection(direction.x,-direction.y,direction.z);
Base::Vector3d cross = flipDirection;
//special cases
if (flipDirection == stdZ) {
cross = Base::Vector3d(1.0,0.0,0.0);
} else if (flipDirection == (stdZ * -1.0)) {
cross = Base::Vector3d(1.0,0.0,0.0);
} else {
cross.Normalize();
cross = cross.Cross(stdZ);
}
// Clear previous Geometry
clear();

Expand All @@ -176,12 +186,11 @@ void GeometryObject::projectShape(const TopoDS_Shape& input,
brep_hlr = new HLRBRep_Algo();
brep_hlr->Add(input, m_isoCount);

// Project the shape into view space with the object's centroid
// at the origin.
gp_Ax2 viewAxis;
viewAxis = gp_Ax2(inputCenter,
gp_Dir(direction.x, direction.y, direction.z),
gp_Dir(xAxis.x, xAxis.y, xAxis.z));
gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z),
// gp_Dir(xAxis.x, -xAxis.y, xAxis.z));
gp_Dir(cross.x, cross.y, cross.z));
HLRAlgo_Projector projector( viewAxis );
brep_hlr->Projector(projector);
brep_hlr->Update();
Expand Down Expand Up @@ -687,7 +696,7 @@ gp_Pnt TechDrawGeometry::findCentroid(const TopoDS_Shape &shape,
gp_Ax2 viewAxis;
viewAxis = gp_Ax2(gp_Pnt(0, 0, 0),
gp_Dir(direction.x, -direction.y, direction.z),
gp_Dir(xAxis.x, -xAxis.y, xAxis.z)); // Y invert warning!
gp_Dir(xAxis.x, -xAxis.y, xAxis.z));

gp_Trsf tempTransform;
tempTransform.SetTransformation(viewAxis);
Expand Down Expand Up @@ -719,7 +728,6 @@ TopoDS_Shape TechDrawGeometry::mirrorShape(const TopoDS_Shape &input,
try {
// Make tempTransform scale the object around it's centre point and
// mirror about the Y axis
// TODO: is this really always Y axis? sb whatever is vertical direction in projection?
gp_Trsf tempTransform;
tempTransform.SetScale(inputCenter, scale);
gp_Trsf mirrorTransform;
Expand Down

0 comments on commit ce9f4f1

Please sign in to comment.