mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-05-11 00:40:49 +05:00
Fix regresion of MirrorPlane, initiated by Projection implementation.
This commit is contained in:
parent
7bb904513a
commit
a17a4190b9
@ -18,7 +18,6 @@
|
|||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
//
|
//
|
||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
|
||||||
|
|
||||||
#ifdef WNT
|
#ifdef WNT
|
||||||
#pragma warning( disable:4786 )
|
#pragma warning( disable:4786 )
|
||||||
@ -68,6 +67,7 @@
|
|||||||
#include <GEOMImpl_TranslateDriver.hxx>
|
#include <GEOMImpl_TranslateDriver.hxx>
|
||||||
#include <GEOMImpl_RotateDriver.hxx>
|
#include <GEOMImpl_RotateDriver.hxx>
|
||||||
#include <GEOMImpl_MirrorDriver.hxx>
|
#include <GEOMImpl_MirrorDriver.hxx>
|
||||||
|
#include <GEOMImpl_ProjectionDriver.hxx>
|
||||||
#include <GEOMImpl_OffsetDriver.hxx>
|
#include <GEOMImpl_OffsetDriver.hxx>
|
||||||
#include <GEOMImpl_ScaleDriver.hxx>
|
#include <GEOMImpl_ScaleDriver.hxx>
|
||||||
#include <GEOMImpl_PositionDriver.hxx>
|
#include <GEOMImpl_PositionDriver.hxx>
|
||||||
@ -147,6 +147,7 @@ GEOMImpl_Gen::GEOMImpl_Gen()
|
|||||||
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_TranslateDriver::GetID(), new GEOMImpl_TranslateDriver());
|
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_TranslateDriver::GetID(), new GEOMImpl_TranslateDriver());
|
||||||
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_RotateDriver::GetID(), new GEOMImpl_RotateDriver());
|
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_RotateDriver::GetID(), new GEOMImpl_RotateDriver());
|
||||||
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MirrorDriver::GetID(), new GEOMImpl_MirrorDriver());
|
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MirrorDriver::GetID(), new GEOMImpl_MirrorDriver());
|
||||||
|
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ProjectionDriver::GetID(), new GEOMImpl_ProjectionDriver());
|
||||||
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_OffsetDriver::GetID(), new GEOMImpl_OffsetDriver());
|
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_OffsetDriver::GetID(), new GEOMImpl_OffsetDriver());
|
||||||
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ScaleDriver::GetID(), new GEOMImpl_ScaleDriver());
|
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ScaleDriver::GetID(), new GEOMImpl_ScaleDriver());
|
||||||
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PositionDriver::GetID(), new GEOMImpl_PositionDriver());
|
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PositionDriver::GetID(), new GEOMImpl_PositionDriver());
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <GEOMImpl_TranslateDriver.hxx>
|
#include <GEOMImpl_TranslateDriver.hxx>
|
||||||
#include <GEOMImpl_MirrorDriver.hxx>
|
#include <GEOMImpl_MirrorDriver.hxx>
|
||||||
|
#include <GEOMImpl_ProjectionDriver.hxx>
|
||||||
#include <GEOMImpl_OffsetDriver.hxx>
|
#include <GEOMImpl_OffsetDriver.hxx>
|
||||||
#include <GEOMImpl_ScaleDriver.hxx>
|
#include <GEOMImpl_ScaleDriver.hxx>
|
||||||
#include <GEOMImpl_RotateDriver.hxx>
|
#include <GEOMImpl_RotateDriver.hxx>
|
||||||
@ -1196,10 +1197,10 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ProjectShapeCopy
|
|||||||
|
|
||||||
//Add a Projection function
|
//Add a Projection function
|
||||||
Handle(GEOM_Function) aFunction =
|
Handle(GEOM_Function) aFunction =
|
||||||
aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), PROJECTION_COPY);
|
aCopy->AddFunction(GEOMImpl_ProjectionDriver::GetID(), PROJECTION_COPY);
|
||||||
|
|
||||||
//Check if the function is set correctly
|
//Check if the function is set correctly
|
||||||
if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
|
if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) return NULL;
|
||||||
|
|
||||||
GEOMImpl_IMirror aTI (aFunction);
|
GEOMImpl_IMirror aTI (aFunction);
|
||||||
aTI.SetPlane(theTarget->GetLastFunction());
|
aTI.SetPlane(theTarget->GetLastFunction());
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include <BRepBuilderAPI_Transform.hxx>
|
#include <BRepBuilderAPI_Transform.hxx>
|
||||||
#include <BRepBuilderAPI_MakeVertex.hxx>
|
#include <BRepBuilderAPI_MakeVertex.hxx>
|
||||||
#include <BRepClass_FaceClassifier.hxx>
|
#include <BRepClass_FaceClassifier.hxx>
|
||||||
#include <BRepOffsetAPI_NormalProjection.hxx>
|
|
||||||
#include <BRepTools.hxx>
|
#include <BRepTools.hxx>
|
||||||
|
|
||||||
#include <TopAbs.hxx>
|
#include <TopAbs.hxx>
|
||||||
@ -43,7 +42,6 @@
|
|||||||
#include <TopoDS_Vertex.hxx>
|
#include <TopoDS_Vertex.hxx>
|
||||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
|
|
||||||
#include <GeomAPI_ProjectPointOnSurf.hxx>
|
|
||||||
#include <Geom_Plane.hxx>
|
#include <Geom_Plane.hxx>
|
||||||
|
|
||||||
#include <gp_Trsf.hxx>
|
#include <gp_Trsf.hxx>
|
||||||
@ -93,120 +91,6 @@ Standard_Integer GEOMImpl_MirrorDriver::Execute(TFunction_Logbook& log) const
|
|||||||
TopoDS_Shape anOriginal = anOriginalFunction->GetValue();
|
TopoDS_Shape anOriginal = anOriginalFunction->GetValue();
|
||||||
if (anOriginal.IsNull()) return 0;
|
if (anOriginal.IsNull()) return 0;
|
||||||
|
|
||||||
// Projection
|
|
||||||
if (aType == PROJECTION_COPY) {
|
|
||||||
// Source shape (point, edge or wire)
|
|
||||||
if (anOriginal.ShapeType() != TopAbs_VERTEX &&
|
|
||||||
anOriginal.ShapeType() != TopAbs_EDGE &&
|
|
||||||
anOriginal.ShapeType() != TopAbs_WIRE) {
|
|
||||||
Standard_ConstructionError::Raise
|
|
||||||
("Projection aborted : the source shape is neither a vertex, nor an edge or a wire");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Target face
|
|
||||||
Handle(GEOM_Function) aTargetFunction = TI.GetPlane();
|
|
||||||
if (aTargetFunction.IsNull()) return 0;
|
|
||||||
TopoDS_Shape aFaceShape = aTargetFunction->GetValue();
|
|
||||||
//if (aFaceShape.IsNull() || aFaceShape.ShapeType() != TopAbs_FACE) {
|
|
||||||
// Standard_ConstructionError::Raise
|
|
||||||
// ("Projection aborted : the target shape is not a face");
|
|
||||||
//}
|
|
||||||
|
|
||||||
Standard_Real tol = 1.e-4;
|
|
||||||
|
|
||||||
if (anOriginal.ShapeType() == TopAbs_VERTEX) {
|
|
||||||
if (aFaceShape.IsNull() || aFaceShape.ShapeType() != TopAbs_FACE) {
|
|
||||||
Standard_ConstructionError::Raise
|
|
||||||
("Projection aborted : the target shape is not a face");
|
|
||||||
}
|
|
||||||
TopoDS_Face aFace = TopoDS::Face(aFaceShape);
|
|
||||||
Handle(Geom_Surface) surface = BRep_Tool::Surface(aFace);
|
|
||||||
double U1, U2, V1, V2;
|
|
||||||
//surface->Bounds(U1, U2, V1, V2);
|
|
||||||
BRepTools::UVBounds(aFace, U1, U2, V1, V2);
|
|
||||||
|
|
||||||
// projector
|
|
||||||
GeomAPI_ProjectPointOnSurf proj;
|
|
||||||
proj.Init(surface, U1, U2, V1, V2, tol);
|
|
||||||
|
|
||||||
gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(anOriginal));
|
|
||||||
proj.Perform(aPnt);
|
|
||||||
if (!proj.IsDone()) {
|
|
||||||
Standard_ConstructionError::Raise
|
|
||||||
("Projection aborted : GeomAPI_ProjectPointOnSurf failed");
|
|
||||||
}
|
|
||||||
int nbPoints = proj.NbPoints();
|
|
||||||
if (nbPoints < 1) {
|
|
||||||
Standard_ConstructionError::Raise("No solution found");
|
|
||||||
}
|
|
||||||
|
|
||||||
Quantity_Parameter U, V;
|
|
||||||
proj.LowerDistanceParameters(U, V);
|
|
||||||
gp_Pnt2d aProjPnt (U, V);
|
|
||||||
|
|
||||||
// classifier
|
|
||||||
BRepClass_FaceClassifier aClsf (aFace, aProjPnt, tol);
|
|
||||||
if (aClsf.State() != TopAbs_IN && aClsf.State() != TopAbs_ON) {
|
|
||||||
bool isSol = false;
|
|
||||||
double minDist = RealLast();
|
|
||||||
for (int i = 1; i <= nbPoints; i++) {
|
|
||||||
Quantity_Parameter Ui, Vi;
|
|
||||||
proj.Parameters(i, Ui, Vi);
|
|
||||||
aProjPnt = gp_Pnt2d(Ui, Vi);
|
|
||||||
aClsf.Perform(aFace, aProjPnt, tol);
|
|
||||||
if (aClsf.State() == TopAbs_IN || aClsf.State() == TopAbs_ON) {
|
|
||||||
isSol = true;
|
|
||||||
double dist = proj.Distance(i);
|
|
||||||
if (dist < minDist) {
|
|
||||||
minDist = dist;
|
|
||||||
U = Ui;
|
|
||||||
V = Vi;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!isSol) {
|
|
||||||
Standard_ConstructionError::Raise("No solution found");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gp_Pnt surfPnt = surface->Value(U, V);
|
|
||||||
|
|
||||||
aShape = BRepBuilderAPI_MakeVertex(surfPnt).Shape();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//see BRepTest_BasicCommands.cxx for example of BRepOffsetAPI_NormalProjection
|
|
||||||
BRepOffsetAPI_NormalProjection OrtProj (aFaceShape);
|
|
||||||
OrtProj.Add(anOriginal);
|
|
||||||
|
|
||||||
//Standard_Real tol = 1.e-4;
|
|
||||||
//Standard_Real tol2d = Pow(tol, 2./3);
|
|
||||||
//GeomAbs_Shape Continuity = GeomAbs_C2;
|
|
||||||
//Standard_Integer MaxDeg = 14;
|
|
||||||
//Standard_Integer MaxSeg = 16;
|
|
||||||
//OrtProj.SetParams(tol, tol2d, Continuity, MaxDeg, MaxSeg);
|
|
||||||
try {
|
|
||||||
OrtProj.Build();
|
|
||||||
} catch (Standard_Failure) {
|
|
||||||
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
|
|
||||||
TCollection_AsciiString aMsg (aFail->GetMessageString());
|
|
||||||
if (!aMsg.Length())
|
|
||||||
aMsg = "Projection aborted : possibly the source shape intersects the cylinder's axis";
|
|
||||||
Standard_ConstructionError::Raise(aMsg.ToCString());
|
|
||||||
}
|
|
||||||
if (!OrtProj.IsDone()) {
|
|
||||||
Standard_ConstructionError::Raise
|
|
||||||
("Projection aborted : BRepOffsetAPI_NormalProjection failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
aShape = OrtProj.Shape();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aShape.IsNull()) return 0;
|
|
||||||
aFunction->SetValue(aShape);
|
|
||||||
log.SetTouched(Label());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bug 12158: Check for standalone (not included in faces) degenerated edges
|
// Bug 12158: Check for standalone (not included in faces) degenerated edges
|
||||||
TopTools_IndexedDataMapOfShapeListOfShape aEFMap;
|
TopTools_IndexedDataMapOfShapeListOfShape aEFMap;
|
||||||
TopExp::MapShapesAndAncestors(anOriginal, TopAbs_EDGE, TopAbs_FACE, aEFMap);
|
TopExp::MapShapesAndAncestors(anOriginal, TopAbs_EDGE, TopAbs_FACE, aEFMap);
|
||||||
|
255
src/GEOMImpl/GEOMImpl_ProjectionDriver.cxx
Normal file
255
src/GEOMImpl/GEOMImpl_ProjectionDriver.cxx
Normal file
@ -0,0 +1,255 @@
|
|||||||
|
// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||||
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2.1 of the License.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
//
|
||||||
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
|
|
||||||
|
#include <Standard_Stream.hxx>
|
||||||
|
|
||||||
|
#include <GEOMImpl_ProjectionDriver.hxx>
|
||||||
|
|
||||||
|
#include <GEOMImpl_IMirror.hxx>
|
||||||
|
#include <GEOMImpl_Types.hxx>
|
||||||
|
#include <GEOM_Function.hxx>
|
||||||
|
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRepBuilderAPI_Transform.hxx>
|
||||||
|
#include <BRepBuilderAPI_MakeVertex.hxx>
|
||||||
|
#include <BRepClass_FaceClassifier.hxx>
|
||||||
|
#include <BRepOffsetAPI_NormalProjection.hxx>
|
||||||
|
#include <BRepTools.hxx>
|
||||||
|
|
||||||
|
#include <TopAbs.hxx>
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
|
|
||||||
|
#include <GeomAPI_ProjectPointOnSurf.hxx>
|
||||||
|
#include <Geom_Plane.hxx>
|
||||||
|
|
||||||
|
#include <gp_Trsf.hxx>
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
#include <gp_Vec.hxx>
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetID
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
const Standard_GUID& GEOMImpl_ProjectionDriver::GetID()
|
||||||
|
{
|
||||||
|
static Standard_GUID aProjectionDriver ("FF1BBB70-5D14-4df2-980B-3A668264EA16");
|
||||||
|
return aProjectionDriver;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GEOMImpl_ProjectionDriver
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
GEOMImpl_ProjectionDriver::GEOMImpl_ProjectionDriver()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Execute
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer GEOMImpl_ProjectionDriver::Execute(TFunction_Logbook& log) const
|
||||||
|
{
|
||||||
|
if (Label().IsNull()) return 0;
|
||||||
|
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
|
||||||
|
|
||||||
|
if (aFunction.IsNull()) return 0;
|
||||||
|
|
||||||
|
TopoDS_Shape aShape;
|
||||||
|
gp_Trsf aTrsf;
|
||||||
|
|
||||||
|
GEOMImpl_IMirror TI (aFunction);
|
||||||
|
Standard_Integer aType = aFunction->GetType();
|
||||||
|
|
||||||
|
Handle(GEOM_Function) anOriginalFunction = TI.GetOriginal();
|
||||||
|
if (anOriginalFunction.IsNull()) return 0;
|
||||||
|
|
||||||
|
TopoDS_Shape anOriginal = anOriginalFunction->GetValue();
|
||||||
|
if (anOriginal.IsNull()) return 0;
|
||||||
|
|
||||||
|
// Projection
|
||||||
|
if (aType == PROJECTION_COPY) {
|
||||||
|
// Source shape (point, edge or wire)
|
||||||
|
if (anOriginal.ShapeType() != TopAbs_VERTEX &&
|
||||||
|
anOriginal.ShapeType() != TopAbs_EDGE &&
|
||||||
|
anOriginal.ShapeType() != TopAbs_WIRE) {
|
||||||
|
Standard_ConstructionError::Raise
|
||||||
|
("Projection aborted : the source shape is neither a vertex, nor an edge or a wire");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Target face
|
||||||
|
Handle(GEOM_Function) aTargetFunction = TI.GetPlane();
|
||||||
|
if (aTargetFunction.IsNull()) return 0;
|
||||||
|
TopoDS_Shape aFaceShape = aTargetFunction->GetValue();
|
||||||
|
//if (aFaceShape.IsNull() || aFaceShape.ShapeType() != TopAbs_FACE) {
|
||||||
|
// Standard_ConstructionError::Raise
|
||||||
|
// ("Projection aborted : the target shape is not a face");
|
||||||
|
//}
|
||||||
|
|
||||||
|
Standard_Real tol = 1.e-4;
|
||||||
|
|
||||||
|
if (anOriginal.ShapeType() == TopAbs_VERTEX) {
|
||||||
|
if (aFaceShape.IsNull() || aFaceShape.ShapeType() != TopAbs_FACE) {
|
||||||
|
Standard_ConstructionError::Raise
|
||||||
|
("Projection aborted : the target shape is not a face");
|
||||||
|
}
|
||||||
|
TopoDS_Face aFace = TopoDS::Face(aFaceShape);
|
||||||
|
Handle(Geom_Surface) surface = BRep_Tool::Surface(aFace);
|
||||||
|
double U1, U2, V1, V2;
|
||||||
|
//surface->Bounds(U1, U2, V1, V2);
|
||||||
|
BRepTools::UVBounds(aFace, U1, U2, V1, V2);
|
||||||
|
|
||||||
|
// projector
|
||||||
|
GeomAPI_ProjectPointOnSurf proj;
|
||||||
|
proj.Init(surface, U1, U2, V1, V2, tol);
|
||||||
|
|
||||||
|
gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(anOriginal));
|
||||||
|
proj.Perform(aPnt);
|
||||||
|
if (!proj.IsDone()) {
|
||||||
|
Standard_ConstructionError::Raise
|
||||||
|
("Projection aborted : GeomAPI_ProjectPointOnSurf failed");
|
||||||
|
}
|
||||||
|
int nbPoints = proj.NbPoints();
|
||||||
|
if (nbPoints < 1) {
|
||||||
|
Standard_ConstructionError::Raise("No solution found");
|
||||||
|
}
|
||||||
|
|
||||||
|
Quantity_Parameter U, V;
|
||||||
|
proj.LowerDistanceParameters(U, V);
|
||||||
|
gp_Pnt2d aProjPnt (U, V);
|
||||||
|
|
||||||
|
// classifier
|
||||||
|
BRepClass_FaceClassifier aClsf (aFace, aProjPnt, tol);
|
||||||
|
if (aClsf.State() != TopAbs_IN && aClsf.State() != TopAbs_ON) {
|
||||||
|
bool isSol = false;
|
||||||
|
double minDist = RealLast();
|
||||||
|
for (int i = 1; i <= nbPoints; i++) {
|
||||||
|
Quantity_Parameter Ui, Vi;
|
||||||
|
proj.Parameters(i, Ui, Vi);
|
||||||
|
aProjPnt = gp_Pnt2d(Ui, Vi);
|
||||||
|
aClsf.Perform(aFace, aProjPnt, tol);
|
||||||
|
if (aClsf.State() == TopAbs_IN || aClsf.State() == TopAbs_ON) {
|
||||||
|
isSol = true;
|
||||||
|
double dist = proj.Distance(i);
|
||||||
|
if (dist < minDist) {
|
||||||
|
minDist = dist;
|
||||||
|
U = Ui;
|
||||||
|
V = Vi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isSol) {
|
||||||
|
Standard_ConstructionError::Raise("No solution found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gp_Pnt surfPnt = surface->Value(U, V);
|
||||||
|
|
||||||
|
aShape = BRepBuilderAPI_MakeVertex(surfPnt).Shape();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//see BRepTest_BasicCommands.cxx for example of BRepOffsetAPI_NormalProjection
|
||||||
|
BRepOffsetAPI_NormalProjection OrtProj (aFaceShape);
|
||||||
|
OrtProj.Add(anOriginal);
|
||||||
|
|
||||||
|
//Standard_Real tol = 1.e-4;
|
||||||
|
//Standard_Real tol2d = Pow(tol, 2./3);
|
||||||
|
//GeomAbs_Shape Continuity = GeomAbs_C2;
|
||||||
|
//Standard_Integer MaxDeg = 14;
|
||||||
|
//Standard_Integer MaxSeg = 16;
|
||||||
|
//OrtProj.SetParams(tol, tol2d, Continuity, MaxDeg, MaxSeg);
|
||||||
|
try {
|
||||||
|
OrtProj.Build();
|
||||||
|
} catch (Standard_Failure) {
|
||||||
|
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
|
||||||
|
TCollection_AsciiString aMsg (aFail->GetMessageString());
|
||||||
|
if (!aMsg.Length())
|
||||||
|
aMsg = "Projection aborted : possibly the source shape intersects the cylinder's axis";
|
||||||
|
Standard_ConstructionError::Raise(aMsg.ToCString());
|
||||||
|
}
|
||||||
|
if (!OrtProj.IsDone()) {
|
||||||
|
Standard_ConstructionError::Raise
|
||||||
|
("Projection aborted : BRepOffsetAPI_NormalProjection failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
aShape = OrtProj.Shape();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aShape.IsNull()) return 0;
|
||||||
|
|
||||||
|
aFunction->SetValue(aShape);
|
||||||
|
log.SetTouched(Label());
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GEOMImpl_ProjectionDriver_Type_
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_EXPORT Handle_Standard_Type& GEOMImpl_ProjectionDriver_Type_()
|
||||||
|
{
|
||||||
|
|
||||||
|
static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
|
||||||
|
if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
|
||||||
|
static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
|
||||||
|
if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
|
||||||
|
static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
|
||||||
|
if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
|
||||||
|
|
||||||
|
|
||||||
|
static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
|
||||||
|
static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_ProjectionDriver",
|
||||||
|
sizeof(GEOMImpl_ProjectionDriver),
|
||||||
|
1,
|
||||||
|
(Standard_Address)_Ancestors,
|
||||||
|
(Standard_Address)NULL);
|
||||||
|
|
||||||
|
return _aType;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : DownCast
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
const Handle(GEOMImpl_ProjectionDriver) Handle(GEOMImpl_ProjectionDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
|
||||||
|
{
|
||||||
|
Handle(GEOMImpl_ProjectionDriver) _anOtherObject;
|
||||||
|
|
||||||
|
if (!AnObject.IsNull()) {
|
||||||
|
if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_ProjectionDriver))) {
|
||||||
|
_anOtherObject = Handle(GEOMImpl_ProjectionDriver)((Handle(GEOMImpl_ProjectionDriver)&)AnObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _anOtherObject;
|
||||||
|
}
|
160
src/GEOMImpl/GEOMImpl_ProjectionDriver.hxx
Normal file
160
src/GEOMImpl/GEOMImpl_ProjectionDriver.hxx
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||||
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2.1 of the License.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
//
|
||||||
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
|
|
||||||
|
// File : GEOMImpl_ProjectionDriver.hxx
|
||||||
|
// Module : GEOMImpl
|
||||||
|
|
||||||
|
#ifndef _GEOMImpl_ProjectionDriver_HeaderFile
|
||||||
|
#define _GEOMImpl_ProjectionDriver_HeaderFile
|
||||||
|
|
||||||
|
#ifndef _TColStd_SequenceOfExtendedString_HeaderFile
|
||||||
|
#include <TColStd_SequenceOfExtendedString.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_TypeMismatch_HeaderFile
|
||||||
|
#include <Standard_TypeMismatch.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _Standard_HeaderFile
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _Standard_Macro_HeaderFile
|
||||||
|
#include <Standard_Macro.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_HeaderFile
|
||||||
|
#include <Standard.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_GUID_HeaderFile
|
||||||
|
#include <Standard_GUID.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _Handle_TFunction_Driver_HeaderFile
|
||||||
|
#include <Handle_TFunction_Driver.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class Standard_Transient;
|
||||||
|
class Handle_Standard_Type;
|
||||||
|
class Handle(TFunction_Driver);
|
||||||
|
class GEOMImpl_ProjectionDriver;
|
||||||
|
|
||||||
|
Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_ProjectionDriver);
|
||||||
|
|
||||||
|
class Handle(GEOMImpl_ProjectionDriver) : public Handle(TFunction_Driver) {
|
||||||
|
public:
|
||||||
|
inline void* operator new(size_t,void* anAddress)
|
||||||
|
{
|
||||||
|
return anAddress;
|
||||||
|
}
|
||||||
|
inline void* operator new(size_t size)
|
||||||
|
{
|
||||||
|
return Standard::Allocate(size);
|
||||||
|
}
|
||||||
|
inline void operator delete(void *anAddress)
|
||||||
|
{
|
||||||
|
if (anAddress) Standard::Free((Standard_Address&)anAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(GEOMImpl_ProjectionDriver)():Handle(TFunction_Driver)() {}
|
||||||
|
Handle(GEOMImpl_ProjectionDriver)(const Handle(GEOMImpl_ProjectionDriver)& aHandle) : Handle(TFunction_Driver)(aHandle)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(GEOMImpl_ProjectionDriver)(const GEOMImpl_ProjectionDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(GEOMImpl_ProjectionDriver)& operator=(const Handle(GEOMImpl_ProjectionDriver)& aHandle)
|
||||||
|
{
|
||||||
|
Assign(aHandle.Access());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(GEOMImpl_ProjectionDriver)& operator=(const GEOMImpl_ProjectionDriver* anItem)
|
||||||
|
{
|
||||||
|
Assign((Standard_Transient *)anItem);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
GEOMImpl_ProjectionDriver* operator->()
|
||||||
|
{
|
||||||
|
return (GEOMImpl_ProjectionDriver *)ControlAccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
GEOMImpl_ProjectionDriver* operator->() const
|
||||||
|
{
|
||||||
|
return (GEOMImpl_ProjectionDriver *)ControlAccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_EXPORT ~Handle(GEOMImpl_ProjectionDriver)() {};
|
||||||
|
|
||||||
|
Standard_EXPORT static const Handle(GEOMImpl_ProjectionDriver) DownCast(const Handle(Standard_Transient)& AnObject);
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef _TFunction_Driver_HeaderFile
|
||||||
|
#include <TFunction_Driver.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _TFunction_Logbook_HeaderFile
|
||||||
|
#include <TFunction_Logbook.hxx>
|
||||||
|
#endif
|
||||||
|
#ifndef _Standard_CString_HeaderFile
|
||||||
|
#include <Standard_CString.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class TColStd_SequenceOfExtendedString;
|
||||||
|
|
||||||
|
|
||||||
|
class GEOMImpl_ProjectionDriver : public TFunction_Driver {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
inline void* operator new(size_t,void* anAddress)
|
||||||
|
{
|
||||||
|
return anAddress;
|
||||||
|
}
|
||||||
|
inline void* operator new(size_t size)
|
||||||
|
{
|
||||||
|
return Standard::Allocate(size);
|
||||||
|
}
|
||||||
|
inline void operator delete(void *anAddress)
|
||||||
|
{
|
||||||
|
if (anAddress) Standard::Free((Standard_Address&)anAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methods PUBLIC
|
||||||
|
//
|
||||||
|
Standard_EXPORT GEOMImpl_ProjectionDriver();
|
||||||
|
Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const;
|
||||||
|
Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {}
|
||||||
|
Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; }
|
||||||
|
Standard_EXPORT static const Standard_GUID& GetID();
|
||||||
|
Standard_EXPORT ~GEOMImpl_ProjectionDriver() {};
|
||||||
|
|
||||||
|
|
||||||
|
// Type management
|
||||||
|
//
|
||||||
|
Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_ProjectionDriver_Type_();
|
||||||
|
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_ProjectionDriver) ; }
|
||||||
|
Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_ProjectionDriver) == AType || TFunction_Driver::IsKind(AType)); }
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -69,4 +69,6 @@ FF1BBB68-5D14-4df2-980B-3A668264EA16 // Sub shape GUID
|
|||||||
|
|
||||||
FF1BBB69-5D14-4df2-980B-3A668264EA16 // Modify the Location
|
FF1BBB69-5D14-4df2-980B-3A668264EA16 // Modify the Location
|
||||||
|
|
||||||
|
FF1BBB70-5D14-4df2-980B-3A668264EA16 // Projection
|
||||||
|
|
||||||
1C3A0F3F-729D-4E83-8232-78E74FC5637C // Pipe T-Shape
|
1C3A0F3F-729D-4E83-8232-78E74FC5637C // Pipe T-Shape
|
||||||
|
@ -103,6 +103,7 @@ salomeinclude_HEADERS = \
|
|||||||
GEOMImpl_MarkerDriver.hxx \
|
GEOMImpl_MarkerDriver.hxx \
|
||||||
GEOMImpl_TranslateDriver.hxx \
|
GEOMImpl_TranslateDriver.hxx \
|
||||||
GEOMImpl_MirrorDriver.hxx \
|
GEOMImpl_MirrorDriver.hxx \
|
||||||
|
GEOMImpl_ProjectionDriver.hxx \
|
||||||
GEOMImpl_OffsetDriver.hxx \
|
GEOMImpl_OffsetDriver.hxx \
|
||||||
GEOMImpl_ScaleDriver.hxx \
|
GEOMImpl_ScaleDriver.hxx \
|
||||||
GEOMImpl_PositionDriver.hxx \
|
GEOMImpl_PositionDriver.hxx \
|
||||||
@ -172,6 +173,7 @@ dist_libGEOMimpl_la_SOURCES = \
|
|||||||
GEOMImpl_MarkerDriver.cxx \
|
GEOMImpl_MarkerDriver.cxx \
|
||||||
GEOMImpl_TranslateDriver.cxx \
|
GEOMImpl_TranslateDriver.cxx \
|
||||||
GEOMImpl_MirrorDriver.cxx \
|
GEOMImpl_MirrorDriver.cxx \
|
||||||
|
GEOMImpl_ProjectionDriver.cxx \
|
||||||
GEOMImpl_OffsetDriver.cxx \
|
GEOMImpl_OffsetDriver.cxx \
|
||||||
GEOMImpl_ScaleDriver.cxx \
|
GEOMImpl_ScaleDriver.cxx \
|
||||||
GEOMImpl_PositionDriver.cxx \
|
GEOMImpl_PositionDriver.cxx \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user