Skip to content
Snippets Groups Projects
Commit 5f1d4f92 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

support opencascade 6.5

parent 716f2d35
Branches
Tags
No related merge requests found
......@@ -12,17 +12,17 @@
#include "Context.h"
#if defined(HAVE_OCC)
#include "Geom2dLProp_CLProps2d.hxx"
#include "Geom_BezierCurve.hxx"
#include "Geom_OffsetCurve.hxx"
#include "Geom_Ellipse.hxx"
#include "Geom_Parabola.hxx"
#include "Geom_Hyperbola.hxx"
#include "Geom_TrimmedCurve.hxx"
#include "Geom_Circle.hxx"
#include "Geom_Line.hxx"
#include "Geom_Conic.hxx"
#include "BOPTools_Tools.hxx"
#include <Geom2dLProp_CLProps2d.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_OffsetCurve.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_Parabola.hxx>
#include <Geom_Hyperbola.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Line.hxx>
#include <Geom_Conic.hxx>
#include <BOPTools_Tools.hxx>
GEdge *getOCCEdgeByNativePtr(GModel *model, TopoDS_Edge toFind)
{
......@@ -31,11 +31,9 @@ GEdge *getOCCEdgeByNativePtr(GModel *model, TopoDS_Edge toFind)
OCCEdge *ed = dynamic_cast<OCCEdge*>(*it);
if (ed){
if (toFind.IsSame(ed->getTopoDS_Edge())){
// printf("found %d coucou\n",ed->tag());
return *it;
}
if (toFind.IsSame(ed->getTopoDS_EdgeOld())){
// printf("found %d coucou\n",ed->tag());
return *it;
}
}
......@@ -47,7 +45,6 @@ GEdge *getOCCEdgeByNativePtr(GModel *model, TopoDS_Edge toFind)
OCCEdge::OCCEdge(GModel *model, TopoDS_Edge edge, int num, GVertex *v1, GVertex *v2)
: GEdge(model, num, v1, v2), c(edge), trimmed(0)
{
// printf("NEW OCCEDGE %d\n",num);
curve = BRep_Tool::Curve(c, s0, s1);
// build the reverse curve
c_rev = c;
......
......@@ -14,19 +14,20 @@
#include "Context.h"
#if defined(HAVE_OCC)
#include "Geom_CylindricalSurface.hxx"
#include "Geom_ConicalSurface.hxx"
#include "Geom_BSplineSurface.hxx"
#include "Geom_SphericalSurface.hxx"
#include "Geom_ToroidalSurface.hxx"
#include "Geom_SurfaceOfRevolution.hxx"
#include "Geom_BezierSurface.hxx"
#include "Geom_Plane.hxx"
#include "gp_Pln.hxx"
#include "BRepMesh_FastDiscret.hxx"
#include "IntTools_Context.hxx"
#include "BOPTools_Tools2D.hxx"
#include "BOPTools_Tools3D.hxx"
#include <Standard_Version.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_ConicalSurface.hxx>
#include <Geom_BSplineSurface.hxx>
#include <Geom_SphericalSurface.hxx>
#include <Geom_ToroidalSurface.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
#include <Geom_BezierSurface.hxx>
#include <Geom_Plane.hxx>
#include <gp_Pln.hxx>
#include <BRepMesh_FastDiscret.hxx>
#include <IntTools_Context.hxx>
#include <BOPTools_Tools2D.hxx>
#include <BOPTools_Tools3D.hxx>
OCCFace::OCCFace(GModel *m, TopoDS_Face _s, int num)
: GFace(m, num), s(_s)
......@@ -337,27 +338,25 @@ bool OCCFace::buildSTLTriangulation(bool force)
Bnd_Box aBox;
BRepBndLib::Add(s, aBox);
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
aBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
Standard_Real dX = aXmax - aXmin;
Standard_Real dY = aYmax - aYmin;
Standard_Real dZ = aZmax - aZmin;
Standard_Real dMax = dX;
if(dY > dMax) dMax = dY;
if(dZ > dMax) dMax = dZ;
Standard_Real aCoeff = 0.01;
Standard_Real aDiscret = aCoeff * dMax;
BRepMesh_FastDiscret aMesher(aDiscret, 0.5, aBox, Standard_False, Standard_True,
Standard_False, Standard_True);
BRepMesh_FastDiscret aMesher(0.1, 0.5, aBox, Standard_False, Standard_False, Standard_True, Standard_False);
aMesher.Add(s);
#if !((OCC_VERSION_MAJOR == 6) && (OCC_VERSION_MINOR < 5))
aMesher.Process(s);
#endif
TopLoc_Location loc;
Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation(s, loc);
if(triangulation.IsNull()){
Msg::Warning("OCC STL triangulation failed");
return false;
}
if(!triangulation->HasUVNodes()){
Msg::Warning("OCC STL triangulation has no u,v coordinates");
if(triangulation.IsNull() || !triangulation->HasUVNodes()){
if(triangulation.IsNull())
Msg::Warning("OCC STL triangulation of surface %d failed", tag());
else
Msg::Warning("OCC STL triangulation of surface %d has no u,v coordinates", tag());
// add a dummy triangle so that we won't try again
stl_vertices.push_back(SPoint2(0., 0.));
stl_triangles.push_back(0);
stl_triangles.push_back(0);
stl_triangles.push_back(0);
return false;
}
......
......@@ -14,106 +14,106 @@
using std::iostream;
#if !defined(HAVE_NO_OCC_CONFIG_H)
#include "config.h"
#include <config.h>
#endif
#include "BRep_Tool.hxx"
#include "Geom_Curve.hxx"
#include "Geom2d_Curve.hxx"
#include "Geom_Surface.hxx"
#include "GeomAPI_ProjectPointOnSurf.hxx"
#include "GeomAPI_ProjectPointOnCurve.hxx"
#include "BRepTools.hxx"
#include "TopExp.hxx"
#include "BRepBuilderAPI_MakeVertex.hxx"
#include "BRepBuilderAPI_MakeShell.hxx"
#include "BRepBuilderAPI_MakeSolid.hxx"
#include "BRepOffsetAPI_Sewing.hxx"
#include "BRepLProp_SLProps.hxx"
#include "BRepAdaptor_Surface.hxx"
#include "Poly_Triangulation.hxx"
#include "Poly_Array1OfTriangle.hxx"
#include "TColgp_Array1OfPnt2d.hxx"
#include "Poly_Triangle.hxx"
#include "GProp_GProps.hxx"
#include "BRepGProp.hxx"
#include "Geom_Surface.hxx"
#include "TopExp.hxx"
#include "gp_Pnt.hxx"
#include "TopoDS.hxx"
#include "TopoDS_Solid.hxx"
#include "TopExp_Explorer.hxx"
#include "BRep_Tool.hxx"
#include "BRep_Builder.hxx"
#include "Geom_Curve.hxx"
#include "Geom2d_Curve.hxx"
#include "Geom_Surface.hxx"
#include "GeomAPI_ProjectPointOnSurf.hxx"
#include "GeomAPI_ProjectPointOnCurve.hxx"
#include "TopoDS_Wire.hxx"
#include "BRepTools_WireExplorer.hxx"
#include "BRepTools.hxx"
#include "TopTools_IndexedMapOfShape.hxx"
#include "TopExp.hxx"
#include "BRepBuilderAPI_MakeVertex.hxx"
#include "BRepBuilderAPI_MakeShell.hxx"
#include "BRepBuilderAPI_MakeSolid.hxx"
#include "BRepOffsetAPI_Sewing.hxx"
#include "BRepLProp_CLProps.hxx"
#include "BRepLProp_SLProps.hxx"
#include "BRepAdaptor_Surface.hxx"
#include "BRepAdaptor_Curve.hxx"
#include "Poly_Triangulation.hxx"
#include "Poly_Array1OfTriangle.hxx"
#include "Poly_Triangle.hxx"
#include "GProp_GProps.hxx"
#include "BRepGProp.hxx"
#include "IGESControl_Reader.hxx"
#include "STEPControl_Reader.hxx"
#include "TopoDS_Shape.hxx"
#include "TopoDS_Face.hxx"
#include "IGESToBRep_Reader.hxx"
#include "Interface_Static.hxx"
#include "GeomAPI_ExtremaCurveCurve.hxx"
#include "Standard_ErrorHandler.hxx"
#include "Standard_Failure.hxx"
#include "ShapeUpgrade_ShellSewing.hxx"
#include "ShapeFix_Shape.hxx"
#include "ShapeFix_Wireframe.hxx"
#include "BRepMesh.hxx"
#include "BRepMesh_IncrementalMesh.hxx"
#include "BRepBndLib.hxx"
#include "Bnd_Box.hxx"
#include "ShapeAnalysis.hxx"
#include "ShapeBuild_ReShape.hxx"
#include "IGESControl_Writer.hxx"
#include "STEPControl_Writer.hxx"
#include "StlAPI_Writer.hxx"
#include "STEPControl_StepModelType.hxx"
#include "ShapeAnalysis_ShapeTolerance.hxx"
#include "ShapeAnalysis_ShapeContents.hxx"
#include "ShapeAnalysis_CheckSmallFace.hxx"
#include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"
#include "BRepAlgoAPI_Fuse.hxx"
#include "BRepCheck_Analyzer.hxx"
#include "BRepLib.hxx"
#include "ShapeBuild_ReShape.hxx"
#include "ShapeFix.hxx"
#include "ShapeFix_FixSmallFace.hxx"
#include "TopoDS_Compound.hxx"
#include "TopoDS_Iterator.hxx"
#include "BRepPrimAPI_MakeSphere.hxx"
#include "BRepPrimAPI_MakeBox.hxx"
#include "BRepPrimAPI_MakeCylinder.hxx"
#include "BRepPrimAPI_MakeCone.hxx"
#include "BRepPrimAPI_MakeTorus.hxx"
#include "TopTools_ListIteratorOfListOfShape.hxx"
#include "Precision.hxx"
#include "BRepAlgoAPI_Common.hxx"
#include "BRepAlgoAPI_Cut.hxx"
#include "BRepAlgoAPI_Section.hxx"
#include "BRepAlgoAPI_Fuse.hxx"
#include "BRepFilletAPI_MakeFillet.hxx"
#include <BRep_Tool.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Surface.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <BRepTools.hxx>
#include <TopExp.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakeShell.hxx>
#include <BRepBuilderAPI_MakeSolid.hxx>
#include <BRepOffsetAPI_Sewing.hxx>
#include <BRepLProp_SLProps.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <Poly_Triangulation.hxx>
#include <Poly_Array1OfTriangle.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <Poly_Triangle.hxx>
#include <GProp_GProps.hxx>
#include <BRepGProp.hxx>
#include <Geom_Surface.hxx>
#include <TopExp.hxx>
#include <gp_Pnt.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Solid.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Surface.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <TopoDS_Wire.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <BRepTools.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopExp.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakeShell.hxx>
#include <BRepBuilderAPI_MakeSolid.hxx>
#include <BRepOffsetAPI_Sewing.hxx>
#include <BRepLProp_CLProps.hxx>
#include <BRepLProp_SLProps.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <Poly_Triangulation.hxx>
#include <Poly_Array1OfTriangle.hxx>
#include <Poly_Triangle.hxx>
#include <GProp_GProps.hxx>
#include <BRepGProp.hxx>
#include <IGESControl_Reader.hxx>
#include <STEPControl_Reader.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Face.hxx>
#include <IGESToBRep_Reader.hxx>
#include <Interface_Static.hxx>
#include <GeomAPI_ExtremaCurveCurve.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <ShapeUpgrade_ShellSewing.hxx>
#include <ShapeFix_Shape.hxx>
#include <ShapeFix_Wireframe.hxx>
#include <BRepMesh.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <BRepBndLib.hxx>
#include <Bnd_Box.hxx>
#include <ShapeAnalysis.hxx>
#include <ShapeBuild_ReShape.hxx>
#include <IGESControl_Writer.hxx>
#include <STEPControl_Writer.hxx>
#include <StlAPI_Writer.hxx>
#include <STEPControl_StepModelType.hxx>
#include <ShapeAnalysis_ShapeTolerance.hxx>
#include <ShapeAnalysis_ShapeContents.hxx>
#include <ShapeAnalysis_CheckSmallFace.hxx>
#include <ShapeAnalysis_DataMapOfShapeListOfReal.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <BRepLib.hxx>
#include <ShapeBuild_ReShape.hxx>
#include <ShapeFix.hxx>
#include <ShapeFix_FixSmallFace.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
#include <BRepPrimAPI_MakeSphere.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <BRepPrimAPI_MakeCone.hxx>
#include <BRepPrimAPI_MakeTorus.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <Precision.hxx>
#include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepAlgoAPI_Section.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepFilletAPI_MakeFillet.hxx>
#endif
#if defined(WIN32)
......
......@@ -13,8 +13,6 @@
#if defined(HAVE_OCC)
OCCRegion::OCCRegion(GModel *m, TopoDS_Solid _s, int num)
: GRegion(m, num), s(_s)
{
......@@ -126,4 +124,5 @@ GRegion *getOCCRegionByNativePtr(GModel *model, TopoDS_Solid toFind)
}
return 0;
}
#endif
......@@ -15,6 +15,8 @@
#if defined(HAVE_OCC)
#include <Standard_Version.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Solid.hxx>
......@@ -597,7 +599,12 @@ void OCC_Connect::Intersect(BRep_Builder &BB, TopoDS_Shape &target,
double tolerance=std::max(BRep_Tool::Tolerance(edge),
BRep_Tool::Tolerance(vertex));
for(int i=1;i<=distance.NbExt();i++) {
if(distance.Value(i)<tolerance) {
#if (OCC_VERSION_MAJOR == 6) && (OCC_VERSION_MINOR < 5)
double value = distance.Value(i);
#else
double value = distance.SquareDistance(i);
#endif
if(value<tolerance) {
try {
// No idea why this can fail
splitter1.Add(vertex,distance.Parameter(i),edge);
......@@ -616,7 +623,7 @@ void OCC_Connect::Intersect(BRep_Builder &BB, TopoDS_Shape &target,
double d2=BRep_Tool::Pnt(v2).Distance(
BRep_Tool::Pnt(vertex));
cout << "Adding " << i << " to edge " << e
<< " distance=" << distance.Value(i)
<< " distance=" << value
<< " parameter=" << distance.Parameter(i)
<< " point=" << distance.Point(i)
<< " dv1=" << d1
......@@ -649,7 +656,12 @@ void OCC_Connect::Intersect(BRep_Builder &BB, TopoDS_Shape &target,
double tolerance=std::max(BRep_Tool::Tolerance(edge),
BRep_Tool::Tolerance(vertex));
for(int i=1;i<=distance.NbExt();i++) {
if(distance.Value(i)<tolerance) {
#if (OCC_VERSION_MAJOR == 6) && (OCC_VERSION_MINOR < 5)
double value = distance.Value(i);
#else
double value = distance.SquareDistance(i);
#endif
if(value<tolerance) {
try {
splitter2.Add(vertex,distance.Parameter(i),edge);
}
......@@ -667,7 +679,7 @@ void OCC_Connect::Intersect(BRep_Builder &BB, TopoDS_Shape &target,
double d2=BRep_Tool::Pnt(v2).Distance(
BRep_Tool::Pnt(vertex));
cout << "Adding " << i << " to edge " << e
<< " distance=" << distance.Value(i)
<< " distance=" << value
<< " parameter=" << distance.Parameter(i)
<< " point=" << distance.Point(i)
<< " dv1=" << d1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment