+// Created on: 2000-06-23
+// Created by: Sergey MOZOKHIN
+// Copyright (c) 2000-2014 OPEN CASCADE SAS
+//
+// 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.
+
//=======================================================================
-// File: StlTransfer.cxx
-// Created: Fri Jun 23 14:36:58 2000
-// Author: Sergey MOZOKHIN
-// <smh@russox.nnov.matra-dtv.fr>
-#include <StlTransfer.ixx>
-#include <Standard_ErrorHandler.hxx>
-#include <Standard_Failure.hxx>
-#include <TopoDS_Face.hxx>
-#include <Poly_Connect.hxx>
-#include <TColgp_Array1OfDir.hxx>
-#include <Poly_Triangulation.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <TopLoc_Location.hxx>
-#include <Geom_Surface.hxx>
+
#include <BRep_Tool.hxx>
-#include <gp_Vec.hxx>
-#include <gp_Pnt.hxx>
-#include <CSLib.hxx>
-#include <TColgp_Array1OfPnt2d.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepMesh_IncrementalMesh.hxx>
#include <CSLib.hxx>
+#include <Geom_Surface.hxx>
#include <gp_Dir.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
#include <gp_XYZ.hxx>
-#include <BRepMesh.hxx>
-#include <TopAbs.hxx>
+#include <Poly_Connect.hxx>
+#include <Poly_Triangulation.hxx>
#include <Precision.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_Failure.hxx>
+#include <StlMesh_Mesh.hxx>
+#include <StlTransfer.hxx>
+#include <TColgp_Array1OfDir.hxx>
+#include <TColgp_Array1OfPnt2d.hxx>
+#include <TColgp_SequenceOfXYZ.hxx>
+#include <TopAbs.hxx>
#include <TopExp_Explorer.hxx>
+#include <TopLoc_Location.hxx>
#include <TopoDS.hxx>
-#include <TColgp_SequenceOfXYZ.hxx>
-//function computes normals for surface
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+//function computes normals for surface
static void Normal(const TopoDS_Face& aFace,
Poly_Connect& pc,
TColgp_Array1OfDir& Nor)
gp_Vec D2U,D2V,D2UV;
gp_Pnt P;
Standard_Real U, V;
- CSLib_DerivativeStatus Status;
+ CSLib_DerivativeStatus aStatus;
CSLib_NormalStatus NStat;
S.Initialize(aFace, Standard_False);
const TColgp_Array1OfPnt2d& UVNodes = T->UVNodes();
- if (!S.GetType() == GeomAbs_Plane) {
+ if (S.GetType() != GeomAbs_Plane) {
for (i = UVNodes.Lower(); i <= UVNodes.Upper(); i++) {
U = UVNodes(i).X();
V = UVNodes(i).Y();
S.D1(U,V,P,D1U,D1V);
- CSLib::Normal(D1U,D1V,Precision::Angular(),Status,Nor(i));
- if (Status != CSLib_Done) {
+ CSLib::Normal (D1U, D1V, Precision::Angular(), aStatus, Nor (i));
+ if (aStatus != CSLib_Done) {
S.D2(U,V,P,D1U,D1V,D2U,D2V,D2UV);
CSLib::Normal(D1U,D1V,D2U,D2V,D2UV,Precision::Angular(),OK,NStat,Nor(i));
}
U = UVNodes(UVNodes.Lower()).X();
V = UVNodes(UVNodes.Lower()).Y();
S.D1(U,V,P,D1U,D1V);
- CSLib::Normal(D1U,D1V,Precision::Angular(),Status,NPlane);
- if (Status != CSLib_Done) {
+ CSLib::Normal (D1U, D1V, Precision::Angular(), aStatus, NPlane);
+ if (aStatus != CSLib_Done) {
S.D2(U,V,P,D1U,D1V,D2U,D2V,D2UV);
CSLib::Normal(D1U,D1V,D2U,D2V,D2UV,Precision::Angular(),OK,NStat,NPlane);
}
}
}
-void StlTransfer::BuildIncrementalMesh (const TopoDS_Shape& Shape,
- const Standard_Real Deflection,
- const Handle(StlMesh_Mesh)& Mesh)
+void StlTransfer::RetrieveMesh (const TopoDS_Shape& Shape,
+ const Handle(StlMesh_Mesh)& Mesh)
{
- if (Deflection <= Precision::Confusion ()) {
- Standard_ConstructionError::Raise ("StlTransfer::BuildIncrementalMesh");
- }
-
- Standard_Integer NbVertices, NbTriangles;
- BRepMesh::Mesh (Shape, Deflection);
for (TopExp_Explorer itf(Shape,TopAbs_FACE); itf.More(); itf.Next()) {
TopoDS_Face face = TopoDS::Face(itf.Current());
TopLoc_Location Loc, loc;
if (theTriangulation.IsNull()) continue; //Meshing was not done for this face!
Poly_Array1OfTriangle theTriangles(1,theTriangulation->NbTriangles());
theTriangles.Assign(theTriangulation->Triangles());
- Mesh->AddDomain (Deflection);
-
-#ifdef DEB
- TopAbs_Orientation orientation =
-#endif
- face.Orientation();
+ Mesh->AddDomain (theTriangulation->Deflection());
TColgp_Array1OfPnt thePoints(1, theTriangulation->NbNodes());
thePoints.Assign(theTriangulation->Nodes());
gp_Pnt p = thePoints.Value(i);
p.Transform(Loc.Transformation());
p.Coord (X1, Y1, Z1);
- NbVertices = Mesh->AddVertex (X1, Y1, Z1);
+ Mesh->AddVertex (X1, Y1, Z1);
}
try {
OCC_CATCH_SIGNALS
A=V1;B=V2;C=V3;
}
}
- NbTriangles = Mesh->AddTriangle (A, B, C, average.X(), average.Y(), average.Z());
+ Mesh->AddTriangle (A, B, C, average.X(), average.Y(), average.Z());
}
}
catch(Standard_Failure)
{
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "Fail in StlTransfer::BuildIncrementalMesh" << endl;
#endif
}