Skip to content

Commit

Permalink
ISSUE #695 removed vertical calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
sebjf committed Sep 17, 2024
1 parent e6bde97 commit 0857ee6
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 68 deletions.
7 changes: 0 additions & 7 deletions bouncer/src/repo/core/model/bson/repo_bson_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,6 @@ RepoCalibration repo::core::model::RepoBSONFactory::makeRepoCalibration(
const repo::lib::RepoUUID& revisionId,
const std::vector<repo::lib::RepoVector3D>& horizontal3d,
const std::vector<repo::lib::RepoVector2D>& horizontal2d,
const std::vector<float>& verticalRange,
const std::string& units)
{
RepoBSONBuilder bsonBuilder;
Expand Down Expand Up @@ -798,12 +797,6 @@ RepoCalibration repo::core::model::RepoBSONFactory::makeRepoCalibration(
}
bsonBuilder.append(REPO_LABEL_HORIZONTAL, horizontalBuilder.obj());

// (Note the vertical range is optional)

if (verticalRange.size() == 2) {
bsonBuilder.appendArray(REPO_LABEL_VERTICALRANGE, verticalRange);
}

bsonBuilder.append(REPO_LABEL_UNITS, units);

return RepoCalibration(bsonBuilder.obj());
Expand Down
1 change: 0 additions & 1 deletion bouncer/src/repo/core/model/bson/repo_bson_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ namespace repo {
const repo::lib::RepoUUID& revisionId,
const std::vector<repo::lib::RepoVector3D>& horizontal3d,
const std::vector<repo::lib::RepoVector2D>& horizontal2d,
const std::vector<float>& verticalRange,
const std::string& units
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,26 +340,17 @@ void FileProcessorDgn::importDrawing(OdDgDatabasePtr pDb, const ODCOLORREF* pPal
// betweeen the SVG and world coordinate systems.
// The graphics system (Gs) view https://docs.opendesign.com/tv/gs_OdGsView.html
// is used to derive points that map between the WCS of the drawing and
// the svg file.
// the svg file for autocalibration.

const OdGsView* pGsView = pDeviceSvg->viewAt(0);
repo::manipulator::modelutility::DrawingCalibration calibration;
updateDrawingHorizontalCalibration(pGsView, calibration);

// Update the calibration vertical range

calibration.verticalRange = { 0, 10 }; // TODO: how do I calculate that?
updateDrawingHorizontalCalibration(pGsView, drawingCollector->calibration);

// And set the calibration units

OdDgElementId elementActId = pDb->getActiveModelId();
OdDgModelPtr pModel = elementActId.safeOpenObject();
repo::manipulator::modelconvertor::ModelUnits units = determineModelUnits(pModel->getMasterUnit());
calibration.units = repo::manipulator::modelconvertor::toUnitsString(units);

// Pass calibration outcome to collector

drawingCollector->calibration = calibration;
drawingCollector->calibration.units = repo::manipulator::modelconvertor::toUnitsString(units);

// The call to update is what will create the svg in the memory stream

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,55 +153,12 @@ void FileProcessorDwg::importDrawing(OdDbDatabasePtr pDb)
// between the SVG and world coordinate systems. The graphics system (Gs) view
// https://docs.opendesign.com/tv/gs_OdGsView.html is used to derive points
// that map between the WCS of the drawing and the space the SVG primitives
// are defined.
// are defined for the purpose of autocalibration.

const OdGsView* pGsView = pDeviceSvg->viewAt(0);
repo::manipulator::modelutility::DrawingCalibration calibration;

updateDrawingHorizontalCalibration(pGsView, calibration);

// Collect the units (we may also need these for the vertical calibration)

updateDrawingHorizontalCalibration(pGsView, drawingCollector->calibration);
repo::manipulator::modelconvertor::ModelUnits units = determineModelUnits(pDb->getINSUNITS());
calibration.units = repo::manipulator::modelconvertor::toUnitsString(units);

// Get the vertical calibration by checking the geometry extents of all
// entities (visual elements).

double zmin = DBL_MAX;
double zmax = DBL_MIN;

OdDbBlockTablePtr pTable = pDb->getBlockTableId().safeOpenObject(OdDb::kForRead);
OdDbBlockTableIteratorPtr blockRecordIter = pTable->newIterator();
for (; !blockRecordIter->done(); blockRecordIter->step()) {

OdDbBlockTableRecordPtr record = blockRecordIter->getRecordId().safeOpenObject();

OdDbObjectIteratorPtr entityIter = record->newIterator();
for (; !entityIter->done(); entityIter->step()) {
OdDbEntityPtr entity = entityIter->entity();

OdGeExtents3d extents;
if (entity->drawable()->getGeomExtents(extents) == eOk) {
zmin = std::min(zmin, extents.minPoint().z);
zmax = std::max(zmax, extents.maxPoint().z);
}
}
}

// If the drawing is all on one plane, then just take this plane.
// Otherwise try and guess the range based on the default floor height.

if (zmin == zmax)
{
calibration.verticalRange = { (float)zmin, scaleFactorFromMetres(units) * FLOOR_HEIGHT_M };
}
else
{
calibration.verticalRange = { (float)zmin, (float)zmax };
}

drawingCollector->calibration = calibration;
drawingCollector->calibration.units = repo::manipulator::modelconvertor::toUnitsString(units);

// Render the SVG

Expand Down
1 change: 0 additions & 1 deletion bouncer/src/repo/manipulator/modelutility/repo_drawing.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace repo {
struct DrawingCalibration {
std::vector<repo::lib::RepoVector3D> horizontalCalibration3d;
std::vector<repo::lib::RepoVector2D> horizontalCalibration2d;
std::vector<float> verticalRange;
std::string units;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ uint8_t DrawingManager::commitImage(
revId,
calibration.horizontalCalibration3d,
calibration.horizontalCalibration2d,
calibration.verticalRange,
calibration.units
);

Expand Down

0 comments on commit 0857ee6

Please sign in to comment.