refactor: moved comb_boundary_inside outside of Comb to gcodePlanner (CURA-522)

Esse commit está contido em:
Tim Kuipers
2015-12-02 14:05:48 +01:00
commit 5c3727d532
4 arquivos alterados com 33 adições e 55 exclusões
+2 -41
Ver Arquivo
@@ -14,45 +14,6 @@ bool Comb::moveInsideBoundary(Point* p, int distance)
return PolygonUtils::moveInside(boundary_inside, *p, distance) != NO_INDEX;
}
Polygons Comb::getLayerSecondWalls()
{
if (layer_nr < 0)
{ // when a raft is present
return storage.raftOutline.offset(MM2INT(0.1));
}
else
{
Polygons layer_walls;
for (SliceMeshStorage& mesh : storage.meshes)
{
for (SliceLayerPart& part : mesh.layers[layer_nr].parts)
{
// we want the 2nd inner walls
if (part.insets.size() >= 2) {
layer_walls.add(part.insets[1]);
continue;
}
// but we'll also take the inner wall if the 2nd doesn't exist
if (part.insets.size() >= 1) {
layer_walls.add(part.insets[0]);
continue;
}
// and if there is no walls, we'll try to move inside from the outline
Polygons newOutline = part.outline.offset(-offset_from_outlines);
if(newOutline.polygonLength() > 0) {
layer_walls.add(newOutline);
continue;
}
// offset_from_outlines was so large that it completely destroyed our isle,
// so we'll just use the regular outline
layer_walls.add(part.outline);
continue;
}
}
return layer_walls;
}
}
// boundary_outside is only computed when it's needed!
Polygons* Comb::getBoundaryOutside()
{
@@ -64,7 +25,7 @@ Polygons* Comb::getBoundaryOutside()
return boundary_outside;
}
Comb::Comb(SliceDataStorage& storage, int layer_nr, int64_t comb_boundary_offset, bool travel_avoid_other_parts, int64_t travel_avoid_distance)
Comb::Comb(SliceDataStorage& storage, int layer_nr, Polygons& comb_boundary_inside, int64_t comb_boundary_offset, bool travel_avoid_other_parts, int64_t travel_avoid_distance)
: storage(storage)
, layer_nr(layer_nr)
, offset_from_outlines(comb_boundary_offset) // between second wall and infill / other walls
@@ -72,7 +33,7 @@ Comb::Comb(SliceDataStorage& storage, int layer_nr, int64_t comb_boundary_offset
, offset_from_outlines_outside(travel_avoid_distance)
, avoid_other_parts(travel_avoid_other_parts)
// , boundary_inside( boundary.offset(-offset_from_outlines) ) // TODO: make inside boundary configurable?
, boundary_inside( getLayerSecondWalls() )
, boundary_inside( comb_boundary_inside )
, boundary_outside(nullptr)
, partsView_inside( boundary_inside.splitIntoPartsView() ) // !! changes the order of boundary_inside !!
{
+3 -7
Ver Arquivo
@@ -216,14 +216,9 @@ private:
bool avoid_other_parts; //!< Whether to perform inverse combing a.k.a. avoid parts.
Polygons boundary_inside; //!< The boundary within which to comb.
Polygons& boundary_inside; //!< The boundary within which to comb.
Polygons* boundary_outside; //!< The boundary outside of which to stay to avoid collision with other layer parts. This is a pointer cause we only compute it when we move outside the boundary (so not when there is only a single part in the layer)
PartsView partsView_inside; //!< Structured indices onto boundary_inside which shows which polygons belong to which part.
/*!
* Collects the inner most walls for every mesh in the layer (not support) or computes them from the outlines using Comb::offset_from_outlines.
*/
Polygons getLayerSecondWalls();
/*!
* Get the boundary_outside, which is an offset from the outlines of all meshes in the layer. Calculate it when it hasn't been calculated yet.
@@ -235,11 +230,12 @@ public:
* Initializes the combing areas for every mesh in the layer (not support)
* \param storage Where the layer polygon data is stored
* \param layer_nr The number of the layer for which to generate the combing areas.
* \param comb_boundary_inside The comb boundary within which to comb within layer parts.
* \param offset_from_outlines The offset from the outline polygon, to create the combing boundary in case there is no second wall.
* \param travel_avoid_other_parts Whether to avoid other layer parts when traveling through air.
* \param travel_avoid_distance The distance by which to avoid other layer parts when traveling through air.
*/
Comb(SliceDataStorage& storage, int layer_nr, int64_t offset_from_outlines, bool travel_avoid_other_parts, int64_t travel_avoid_distance);
Comb(SliceDataStorage& storage, int layer_nr, Polygons& comb_boundary_inside, int64_t offset_from_outlines, bool travel_avoid_other_parts, int64_t travel_avoid_distance);
~Comb();
+19 -7
Ver Arquivo
@@ -68,7 +68,7 @@ GCodePlanner::GCodePlanner(CommandSocket* commandSocket, SliceDataStorage& stora
{
was_inside = true; // means it will try to get inside the comb boundary first
is_inside = true; // means it will try to get inside the comb boundary
comb = new Comb(storage, layer_nr, comb_boundary_offset, travel_avoid_other_parts, travel_avoid_distance);
comb = new Comb(storage, layer_nr, comb_boundary_inside, comb_boundary_offset, travel_avoid_other_parts, travel_avoid_distance);
}
else
comb = nullptr;
@@ -80,12 +80,24 @@ GCodePlanner::~GCodePlanner()
delete comb;
}
/*!
* Set whether the next destination is inside a layer part or not.
*
* Features like infill, walls, skin etc. are considered inside.
* Features like prime tower and support are considered outside.
*/
Polygons GCodePlanner::computeCombBoundaryInside()
{
if (layer_nr < 0)
{ // when a raft is present
return storage.raftOutline.offset(MM2INT(0.1));
}
else
{
Polygons layer_walls;
for (SliceMeshStorage& mesh : storage.meshes)
{
SliceLayer& layer = mesh.layers[layer_nr];
layer.getSecondOrInnermostWalls(layer_walls);
}
return layer_walls;
}
}
void GCodePlanner::setIsInside(bool _is_inside)
{
is_inside = _is_inside;
+9
Ver Arquivo
@@ -252,6 +252,7 @@ private:
bool was_inside; //!< Whether the last planned (extrusion) move was inside a layer part
bool is_inside; //!< Whether the destination of the next planned travel move is inside a layer part
Comb* comb;
Polygons comb_boundary_inside; //!< The boundary within which to comb, or to move into when performing a retraction.
RetractionConfig* last_retraction_config;
@@ -297,6 +298,14 @@ public:
GCodePlanner(CommandSocket* commandSocket, SliceDataStorage& storage, unsigned int layer_nr, int z, int layer_height, Point last_position, int current_extruder, FanSpeedLayerTimeSettings& fan_speed_layer_time_settings, bool retraction_combing, int64_t comb_boundary_offset, bool travel_avoid_other_parts, int64_t travel_avoid_distance);
~GCodePlanner();
private:
/*!
* Compute the boundary within which to comb, or to move into when performing a retraction.
* \return the comb_boundary_inside
*/
Polygons computeCombBoundaryInside();
public:
int getLayerNr()
{
return layer_nr;