Cleanups per pesc0 review notes; general code tightening
This commit is contained in:
@@ -11,37 +11,50 @@ double getVolume(TopoDS_Shape shape)
|
||||
return prop.Mass();
|
||||
}
|
||||
|
||||
void PartTestHelperClass::createTestFile()
|
||||
void PartTestHelperClass::createTestDoc()
|
||||
{
|
||||
_docName = App::GetApplication().getUniqueDocumentName("test");
|
||||
_doc = App::GetApplication().newDocument(_docName.c_str(), "testUser");
|
||||
_box1obj = static_cast<Part::Box*>(_doc->addObject("Part::Box"));
|
||||
_box2obj = static_cast<Part::Box*>(_doc->addObject("Part::Box"));
|
||||
_box3obj = static_cast<Part::Box*>(_doc->addObject("Part::Box"));
|
||||
_box4obj = static_cast<Part::Box*>(_doc->addObject("Part::Box"));
|
||||
_box5obj = static_cast<Part::Box*>(_doc->addObject("Part::Box"));
|
||||
_box6obj = static_cast<Part::Box*>(_doc->addObject("Part::Box"));
|
||||
for (auto _box : {_box1obj, _box2obj, _box3obj, _box4obj, _box5obj, _box6obj}) {
|
||||
_box->Length.setValue(1);
|
||||
_box->Width.setValue(2);
|
||||
_box->Height.setValue(3);
|
||||
}
|
||||
_box1obj->Placement.setValue(
|
||||
Base::Placement(Base::Vector3d(), Base::Rotation(), Base::Vector3d()));
|
||||
_box2obj->Placement.setValue(
|
||||
Base::Placement(Base::Vector3d(0, 1, 0), Base::Rotation(), Base::Vector3d()));
|
||||
_box3obj->Placement.setValue(
|
||||
Base::Placement(Base::Vector3d(0, 3, 0), Base::Rotation(), Base::Vector3d()));
|
||||
_box4obj->Placement.setValue(
|
||||
Base::Placement(Base::Vector3d(0, 2, 0), Base::Rotation(), Base::Vector3d()));
|
||||
_box5obj->Placement.setValue(
|
||||
Base::Placement(Base::Vector3d(0, 2 + Base::Precision::Confusion(), 0),
|
||||
Base::Rotation(),
|
||||
Base::Vector3d()));
|
||||
_box6obj->Placement.setValue(
|
||||
Base::Placement(Base::Vector3d(0, 2 - Base::Precision::Confusion() * 1000, 0),
|
||||
Base::Rotation(),
|
||||
Base::Vector3d()));
|
||||
_docName = App::GetApplication().getUniqueDocumentName("test");
|
||||
_doc = App::GetApplication().newDocument(_docName.c_str(), "testUser");
|
||||
std::array<Base::Vector3d, 6> box_origins = {
|
||||
Base::Vector3d(), // First box at 0,0,0
|
||||
Base::Vector3d(0, 1, 0), // Overlap with first box
|
||||
Base::Vector3d(0, 3, 0), // Don't Overlap with first box
|
||||
Base::Vector3d(0, 2, 0), // Touch the first box
|
||||
Base::Vector3d(0, 2 + Base::Precision::Confusion(), 0), // Just Outside of touching
|
||||
// For just inside of touching, go enough that precision rounding doesn't make us overlap.
|
||||
Base::Vector3d(0, 2 - Base::Precision::Confusion() * 1000, 0)
|
||||
};
|
||||
|
||||
// for (auto& [box, origin] : zip(_boxes, box_origins) ) {
|
||||
// for ( int i : range(0,_boxes.size())) {
|
||||
for ( unsigned i=0; i < _boxes.size(); i++ ) {
|
||||
auto box = _boxes[i] = static_cast<Part::Box*>(_doc->addObject("Part::Box"));
|
||||
box->Length.setValue(1);
|
||||
box->Width.setValue(2);
|
||||
box->Height.setValue(3);
|
||||
box->Placement.setValue(Base::Placement(box_origins[i], Base::Rotation(), Base::Vector3d() ) );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace PartTestHelpers
|
||||
}
|
||||
|
||||
// https://google.github.io/googletest/advanced.html#teaching-googletest-how-to-print-your-values
|
||||
namespace Part
|
||||
{
|
||||
void PrintTo(ShapeHistory sh, std::ostream* os)
|
||||
{
|
||||
const char* types[] =
|
||||
{"Compound", "CompSolid", "Solid", "Shell", "Face", "Wire", "Edge", "Vertex", "Shape"};
|
||||
*os << "History for " << types[sh.type] << " is ";
|
||||
for (const auto& it : sh.shapeMap) {
|
||||
int old_shape_index = it.first;
|
||||
*os << " " << old_shape_index << ": ";
|
||||
if (!it.second.empty()) {
|
||||
for (auto it2 : it.second) {
|
||||
*os << it2 << " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
*os << std::endl;
|
||||
}
|
||||
} // namespace Part
|
||||
|
||||
Reference in New Issue
Block a user