1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00
Files
occt/src/IMeshTools/IMeshTools_ShapeExplorer.cxx
nds 967d2f4f30 0030497: [REGRESSION] Mesh - wrong Poly_Polygon3D within local selection of located shape
The previous code has a condition to avoid processing the same faces if the face has a location.
The similar condition should be applied during the edges processing.
If not doing this, in the previous implementation, IMeshData_Edge instances are created for all edges(even located), but edges of faces located are not filled with curves.
As a result we had wrong local selection of edges.

Limit addition of edges to data model by ones with unique TShape and location using edges map already available in BRepMesh_ShapeVisitor.
2019-02-28 20:24:43 +03:00

114 lines
3.8 KiB
C++

// Created on: 2016-04-07
// Copyright (c) 2016 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <IMeshTools_ShapeExplorer.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopTools_ListOfShape.hxx>
#include <BRepLib.hxx>
#include <BRep_Tool.hxx>
#include <TopTools_MapOfShape.hxx>
#include <Geom_Surface.hxx>
namespace
{
//=======================================================================
// Function: visitEdges
// Purpose : Explodes the given shape on edges according to the specified
// criteria and visits each one in order to add it to data model.
//=======================================================================
void visitEdges (const Handle (IMeshTools_ShapeVisitor)& theVisitor,
const TopoDS_Shape& theShape,
const TopAbs_ShapeEnum theToFind,
const TopAbs_ShapeEnum theToAvoid = TopAbs_SHAPE)
{
TopExp_Explorer aEdgesIt (theShape, theToFind, theToAvoid);
for (; aEdgesIt.More (); aEdgesIt.Next ())
{
const TopoDS_Edge& aEdge = TopoDS::Edge (aEdgesIt.Current ());
if (!BRep_Tool::IsGeometric (aEdge))
{
continue;
}
theVisitor->Visit (aEdge);
}
}
}
//=======================================================================
// Function: Constructor
// Purpose :
//=======================================================================
IMeshTools_ShapeExplorer::IMeshTools_ShapeExplorer (
const TopoDS_Shape& theShape)
: IMeshData_Shape (theShape)
{
}
//=======================================================================
// Function: Destructor
// Purpose :
//=======================================================================
IMeshTools_ShapeExplorer::~IMeshTools_ShapeExplorer ()
{
}
//=======================================================================
// Function: Accept
// Purpose :
//=======================================================================
void IMeshTools_ShapeExplorer::Accept (
const Handle (IMeshTools_ShapeVisitor)& theVisitor)
{
// Explore all free edges in shape.
visitEdges (theVisitor, GetShape (), TopAbs_EDGE, TopAbs_FACE);
// Explore all related to some face edges in shape.
// make array of faces suitable for processing (excluding faces without surface)
TopTools_ListOfShape aFaceList;
BRepLib::ReverseSortFaces (GetShape (), aFaceList);
TopTools_MapOfShape aFaceMap;
TopLoc_Location aDummyLoc;
const TopLoc_Location aEmptyLoc;
TopTools_ListIteratorOfListOfShape aFaceIter (aFaceList);
for (; aFaceIter.More (); aFaceIter.Next ())
{
TopoDS_Shape aFaceNoLoc = aFaceIter.Value ();
aFaceNoLoc.Location (aEmptyLoc);
if (!aFaceMap.Add(aFaceNoLoc))
{
continue; // already processed
}
const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Value ());
const Handle (Geom_Surface)& aSurf = BRep_Tool::Surface (aFace, aDummyLoc);
if (aSurf.IsNull())
{
continue;
}
// Explore all edges in face.
visitEdges (theVisitor, aFace, TopAbs_EDGE);
// Store only forward faces in order to prevent inverse issue.
theVisitor->Visit (TopoDS::Face (aFace.Oriented (TopAbs_FORWARD)));
}
}