Skip to content

Commit

Permalink
Issue #695 scaled values of the 2D points in the drawing with the pix…
Browse files Browse the repository at this point in the history
…el density so both sets of vectors are in the same unit.
  • Loading branch information
FJThiel committed Sep 2, 2024
1 parent 2ec278f commit 0f0682a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,14 @@ void FileProcessorDgn::importDrawing(OdDgDatabasePtr pDb, const ODCOLORREF* pPal
OdGePoint3d aS = worldToDeviceMatrix * a;
OdGePoint3d bS = worldToDeviceMatrix * b;

// Convert to 2D by dropping z component (note: have not thought about it. Just conceptually).
repo::lib::RepoVector2D aS2d = repo::lib::RepoVector2D(aS.x, aS.y);
repo::lib::RepoVector2D bS2d = repo::lib::RepoVector2D(bS.x, bS.y);
// Get pixel density to apply it to SVG coordinates for converting from pixel to unit values
OdGePoint2d pixelDensity;
pGsView->getNumPixelsInUnitSquare(OdGePoint3d::kOrigin, pixelDensity, false);

// Convert to 2D by dropping z component and applying the density values
// (note: have not thought about it. Just conceptually).
repo::lib::RepoVector2D aS2d = repo::lib::RepoVector2D(aS.x / pixelDensity.x, aS.y / pixelDensity.y);
repo::lib::RepoVector2D bS2d = repo::lib::RepoVector2D(bS.x / pixelDensity.x, bS.y / pixelDensity.y);

// Convert 3d vectors from ODA format to 3d repo format
repo::lib::RepoVector3D a3d = repo::lib::RepoVector3D(a.x, a.y, a.z);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,14 @@ void FileProcessorDwg::importDrawing(OdDbDatabasePtr pDb)
OdGePoint3d aS = worldToDeviceMatrix * a;
OdGePoint3d bS = worldToDeviceMatrix * b;

// Convert to 2D by dropping z component (note: have not thought about it. Just conceptually).
repo::lib::RepoVector2D aS2d = repo::lib::RepoVector2D(aS.x, aS.y);
repo::lib::RepoVector2D bS2d = repo::lib::RepoVector2D(bS.x, bS.y);
// Get pixel density to apply it to SVG coordinates for converting from pixel to unit values
OdGePoint2d pixelDensity;
pGsView->getNumPixelsInUnitSquare(OdGePoint3d::kOrigin, pixelDensity, false);

// Convert to 2D by dropping z component and applying the density values
// (note: have not thought about it. Just conceptually).
repo::lib::RepoVector2D aS2d = repo::lib::RepoVector2D(aS.x / pixelDensity.x, aS.y / pixelDensity.y);
repo::lib::RepoVector2D bS2d = repo::lib::RepoVector2D(bS.x / pixelDensity.x, bS.y / pixelDensity.y);

// Convert 3d vectors from ODA format to 3d repo format
repo::lib::RepoVector3D a3d = repo::lib::RepoVector3D(a.x, a.y, a.z);
Expand Down

0 comments on commit 0f0682a

Please sign in to comment.