blob: 3f28c01c274f5bd5bc02a90a94154d2c873252c1 [file] [edit]
// Created on: 1995-01-03
// Created by: Frederic MAUPAS
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-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.
//: gka 09.04.99: S4136: eliminate BRepAPI::Precision()
#include <BRep_Builder.hxx>
#include <Geom_CartesianPoint.hxx>
#include <Precision.hxx>
#include <StdFail_NotDone.hxx>
#include <StepData_Factors.hxx>
#include <StepShape_VertexPoint.hxx>
#include <StepToGeom.hxx>
#include <StepToTopoDS_NMTool.hxx>
#include <StepToTopoDS_Tool.hxx>
#include <StepToTopoDS_TranslateVertex.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
// #include <BRepAPI.hxx>
// For I-DEAS-like processing (ssv; 15.11.2010)
//=================================================================================================
StepToTopoDS_TranslateVertex::StepToTopoDS_TranslateVertex()
: myError(StepToTopoDS_TranslateVertexOther)
{
done = false;
}
// ============================================================================
// Method : StepToTopoDS_TranslateVertex::StepToTopoDS_TranslateVertex
// Purpose : Constructor with a Vertex and a Tool
// ============================================================================
StepToTopoDS_TranslateVertex::StepToTopoDS_TranslateVertex(const occ::handle<StepShape_Vertex>& V,
StepToTopoDS_Tool& T,
StepToTopoDS_NMTool& NMTool,
const StepData_Factors& theLocalFactors)
{
Init(V, T, NMTool, theLocalFactors);
}
//=================================================================================================
void StepToTopoDS_TranslateVertex::Init(const occ::handle<StepShape_Vertex>& aVertex,
StepToTopoDS_Tool& aTool,
StepToTopoDS_NMTool& NMTool,
const StepData_Factors& theLocalFactors)
{
if (aVertex.IsNull())
{
myError = StepToTopoDS_TranslateVertexOther;
done = false;
return;
}
if (!aTool.IsBound(aVertex))
{
// [BEGIN] Proceed with non-manifold topology (ssv; 14.11.2010)
if (NMTool.IsActive() && NMTool.IsBound(aVertex))
{
myResult = NMTool.Find(aVertex);
myError = StepToTopoDS_TranslateVertexDone;
done = true;
return;
}
// [END] Proceed with non-manifold topology (ssv; 14.11.2010)
// [BEGIN] Proceed with I-DEAS-like STP (ssv; 15.11.2010)
const occ::handle<TCollection_HAsciiString> aVName = aVertex->Name();
if (NMTool.IsActive() && NMTool.IsIDEASCase() && !aVName.IsNull() && !aVName->IsEmpty()
&& NMTool.IsBound(aVName->String()))
{
myResult = NMTool.Find(aVName->String());
myError = StepToTopoDS_TranslateVertexDone;
done = true;
return;
}
// [END] Proceed with I-DEAS-like STP (ssv; 15.11.2010)
//: S4136 double preci = BRepAPI::Precision();
const occ::handle<StepShape_VertexPoint> VP = occ::down_cast<StepShape_VertexPoint>(aVertex);
const occ::handle<StepGeom_Point> P = VP->VertexGeometry();
if (P.IsNull())
{
myError = StepToTopoDS_TranslateVertexOther;
done = false;
return;
}
const occ::handle<StepGeom_CartesianPoint> P1 = occ::down_cast<StepGeom_CartesianPoint>(P);
occ::handle<Geom_CartesianPoint> P2 = StepToGeom::MakeCartesianPoint(P1, theLocalFactors);
BRep_Builder B;
TopoDS_Vertex V;
B.MakeVertex(V, P2->Pnt(), Precision::Confusion()); //: S4136: preci
aTool.Bind(aVertex, V);
// Register Vertex in NM tool (ssv; 14.11.2010)
if (NMTool.IsActive())
{
NMTool.Bind(aVertex, V);
if (NMTool.IsIDEASCase() && !aVName.IsNull() && !aVName->IsEmpty())
{
NMTool.Bind(aVName->String(), V);
}
}
myResult = V;
}
else
{
myResult = TopoDS::Vertex(aTool.Find(aVertex));
}
myError = StepToTopoDS_TranslateVertexDone;
done = true;
}
//=================================================================================================
const TopoDS_Shape& StepToTopoDS_TranslateVertex::Value() const
{
StdFail_NotDone_Raise_if(!done, "StepToTopoDS_TranslateVertex::Value() - no result");
return myResult;
}
// ============================================================================
// Method : Error
// Purpose : Return the TranslateVertex Error Code
// ============================================================================
StepToTopoDS_TranslateVertexError StepToTopoDS_TranslateVertex::Error() const
{
return myError;
}