mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-28 20:45:37 +05:00
Issue 0020899: EDF 1434: Bad color in the pre-visualization of the 3D sketcher
This commit is contained in:
parent
01f5a34efc
commit
0b3222f523
@ -39,14 +39,17 @@
|
|||||||
#include <LightApp_Application.h>
|
#include <LightApp_Application.h>
|
||||||
#include <LightApp_SelectionMgr.h>
|
#include <LightApp_SelectionMgr.h>
|
||||||
|
|
||||||
#include <BRep_Tool.hxx>
|
//#include <BRep_Tool.hxx>
|
||||||
#include <TopExp.hxx>
|
//#include <TopExp.hxx>
|
||||||
#include <TopExp_Explorer.hxx>
|
//#include <TopExp_Explorer.hxx>
|
||||||
#include <TopoDS_Vertex.hxx>
|
//#include <TopoDS_Vertex.hxx>
|
||||||
#include <TopoDS.hxx>
|
//#include <TopoDS.hxx>
|
||||||
#include <TColStd_IndexedMapOfInteger.hxx>
|
#include <TColStd_IndexedMapOfInteger.hxx>
|
||||||
#include <BRepBuilderAPI_Transform.hxx>
|
//#include <BRepBuilderAPI_Transform.hxx>
|
||||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
//#include <BRepBuilderAPI_MakeWire.hxx>
|
||||||
|
#include <BRepBuilderAPI_MakeVertex.hxx>
|
||||||
|
#include <BRepBuilderAPI_MakePolygon.hxx>
|
||||||
|
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||||
|
|
||||||
class Locker
|
class Locker
|
||||||
{
|
{
|
||||||
@ -596,13 +599,48 @@ void EntityGUI_3DSketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
|
|||||||
// Function : createShapes
|
// Function : createShapes
|
||||||
// Purpose : Create applyed wire, and last segment from entry object
|
// Purpose : Create applyed wire, and last segment from entry object
|
||||||
//================================================================
|
//================================================================
|
||||||
bool EntityGUI_3DSketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
|
bool EntityGUI_3DSketcherDlg::createShapes( GEOM::GEOM_Object_ptr /*theObject*/,
|
||||||
TopoDS_Shape& theApplyedWire,
|
TopoDS_Shape& theApplyedWire,
|
||||||
TopoDS_Shape& theLastSegment )
|
TopoDS_Shape& theLastSegment )
|
||||||
{
|
{
|
||||||
|
QList<gp_Pnt> points;
|
||||||
|
foreach( XYZ xyz, myPointsList) {
|
||||||
|
gp_Pnt p(xyz.x, xyz.y, xyz.z);
|
||||||
|
if ( points.isEmpty() || points.last().Distance(p) > gp::Resolution())
|
||||||
|
points << p;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( points.count() == 1 ) {
|
||||||
|
// only one point is created
|
||||||
|
BRepBuilderAPI_MakeVertex mkVertex (points.last());
|
||||||
|
theApplyedWire = mkVertex.Shape();
|
||||||
|
}
|
||||||
|
else if ( points.count() > 1 ) {
|
||||||
|
// wire is created
|
||||||
|
BRepBuilderAPI_MakePolygon mkWire;
|
||||||
|
foreach( gp_Pnt p, points )
|
||||||
|
mkWire.Add(p);
|
||||||
|
theApplyedWire = mkWire.Shape();
|
||||||
|
}
|
||||||
|
|
||||||
|
XYZ curxyz = getCurrentPoint();
|
||||||
|
gp_Pnt curpnt(curxyz.x, curxyz.y, curxyz.z);
|
||||||
|
|
||||||
|
if ( points.isEmpty() || points.last().Distance(curpnt) <= gp::Resolution() ) {
|
||||||
|
BRepBuilderAPI_MakeVertex mkVertex (curpnt);
|
||||||
|
theLastSegment = mkVertex.Shape();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BRepBuilderAPI_MakeEdge mkEdge(points.last(), curpnt);
|
||||||
|
theLastSegment = mkEdge.Shape();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* VSR: old algorithm does not work properly, see bug 0020899
|
||||||
TopoDS_Shape aShape;
|
TopoDS_Shape aShape;
|
||||||
if ( !GEOMBase::GetShape( theObject, aShape ) ||
|
if ( !GEOMBase::GetShape( theObject, aShape ) )
|
||||||
aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
|
return false;
|
||||||
|
|
||||||
|
if( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
theApplyedWire = aShape;
|
theApplyedWire = aShape;
|
||||||
@ -629,6 +667,7 @@ bool EntityGUI_3DSketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
|
|||||||
TopExp_Explorer vertexExp( theLastSegment, TopAbs_VERTEX );
|
TopExp_Explorer vertexExp( theLastSegment, TopAbs_VERTEX );
|
||||||
theApplyedWire = vertexExp.Current();
|
theApplyedWire = vertexExp.Current();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -69,24 +69,31 @@ Standard_Integer GEOMImpl_3DSketcherDriver::Execute(TFunction_Logbook& log) cons
|
|||||||
TopoDS_Shape aShape;
|
TopoDS_Shape aShape;
|
||||||
|
|
||||||
Handle(TColStd_HArray1OfReal) aCoordsArray = aCI.GetCoordinates();
|
Handle(TColStd_HArray1OfReal) aCoordsArray = aCI.GetCoordinates();
|
||||||
|
|
||||||
BRepBuilderAPI_MakePolygon aMakePoly;
|
|
||||||
int anArrayLength = aCoordsArray->Length();
|
int anArrayLength = aCoordsArray->Length();
|
||||||
double x, y, z;
|
|
||||||
gp_Pnt aPnt;
|
std::list<gp_Pnt> points;
|
||||||
|
|
||||||
for (int i = 0; i <= (anArrayLength-3); i += 3) {
|
for (int i = 0; i <= (anArrayLength-3); i += 3) {
|
||||||
x = aCoordsArray->Value(i+1);
|
gp_Pnt aPnt = gp_Pnt(aCoordsArray->Value(i+1), aCoordsArray->Value(i+2), aCoordsArray->Value(i+3));
|
||||||
y = aCoordsArray->Value(i+2);
|
if (points.empty() || aPnt.Distance(points.back()) > gp::Resolution())
|
||||||
z = aCoordsArray->Value(i+3);
|
points.push_back(aPnt);
|
||||||
aPnt = gp_Pnt(x, y, z);
|
|
||||||
aMakePoly.Add(aPnt);
|
|
||||||
}
|
}
|
||||||
if ( anArrayLength == 3) { // Only Start Point
|
|
||||||
BRepBuilderAPI_MakeVertex mkVertex (aPnt);
|
if ( points.size() == 1) { // Only Start Point
|
||||||
|
BRepBuilderAPI_MakeVertex mkVertex (points.back());
|
||||||
aShape = mkVertex.Shape();
|
aShape = mkVertex.Shape();
|
||||||
}
|
}
|
||||||
else { // Make Wire
|
else if ( points.size() > 1) { // Make Wire
|
||||||
if (aCoordsArray->Value(1) == x && aCoordsArray->Value(2) == y && aCoordsArray->Value(3) == z)
|
BRepBuilderAPI_MakePolygon aMakePoly;
|
||||||
|
std::list<gp_Pnt>::iterator it;
|
||||||
|
for (it = points.begin(); it != points.end(); ++it) {
|
||||||
|
aMakePoly.Add(*it);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (points.size() > 2 &&
|
||||||
|
points.back().X() == points.front().X() &&
|
||||||
|
points.back().Y() == points.front().Y() &&
|
||||||
|
points.back().Z() == points.front().Z())
|
||||||
aMakePoly.Close();
|
aMakePoly.Close();
|
||||||
|
|
||||||
if (aMakePoly.IsDone())
|
if (aMakePoly.IsDone())
|
||||||
|
Loading…
Reference in New Issue
Block a user