-// File: HLRBRep_Data.cxx
-// Created: Thu Apr 17 19:17:52 1997
-// Author: Christophe MARION
-// <cma@partox.paris1.matra-dtv.fr>
+// Created on: 1997-04-17
+// Created by: Christophe MARION
+// Copyright (c) 1997-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.
//#define No_Standard_OutOfRange
-#define OCC191 // jfa 26/02/2002 Bug of cone display
-
-#include <HLRBRep_Data.ixx>
-
-#include <StdFail_UndefinedDerivative.hxx>
-#include <Precision.hxx>
-#include <gp_Dir.hxx>
+#include <BRepTopAdaptor_Tool.hxx>
+#include <BRepTopAdaptor_TopolTool.hxx>
+#include <ElCLib.hxx>
#include <Geom2d_Curve.hxx>
-#include <IntRes2d_IntersectionPoint.hxx>
-#include <IntRes2d_IntersectionSegment.hxx>
-#include <IntCurveSurface_IntersectionPoint.hxx>
-#include <IntCurveSurface_TransitionOnCurve.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <gp.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Dir2d.hxx>
#include <HLRAlgo.hxx>
+#include <HLRAlgo_Interference.hxx>
#include <HLRAlgo_ListIteratorOfInterferenceList.hxx>
+#include <HLRAlgo_Projector.hxx>
+#include <HLRBRep_Data.hxx>
+#include <HLRBRep_EdgeData.hxx>
#include <HLRBRep_EdgeFaceTool.hxx>
-#include <ElCLib.hxx>
-#include <gp.hxx>
+#include <HLRBRep_FaceData.hxx>
+#include <IntCurveSurface_IntersectionPoint.hxx>
+#include <IntCurveSurface_TransitionOnCurve.hxx>
+#include <IntRes2d_IntersectionPoint.hxx>
+#include <IntRes2d_IntersectionSegment.hxx>
+#include <Precision.hxx>
+#include <Standard_Type.hxx>
+#include <StdFail_UndefinedDerivative.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
#include <stdio.h>
-#include <BRepTopAdaptor_Tool.hxx>
+IMPLEMENT_STANDARD_RTTIEXT(HLRBRep_Data,MMgt_TShared)
Standard_Integer nbOkIntersection;
Standard_Integer nbPtIntersection;
long unsigned **TabBit;
Standard_Integer nTabBit;
-#ifdef DEB
+#ifdef OCCT_DEBUG
Standard_Integer StNbLect,StNbEcr,StNbMax,StNbMoy,StNbMoyNonNul; //-- STAT
#endif
+private:
+ TableauRejection(const TableauRejection&);
+ TableauRejection& operator=(const TableauRejection&);
+
public:
//-- ============================================================
TableauRejection() {
N=0; nTabBit=0; UV=NULL; nbUV=NULL; IndUV=NULL; TabBit=NULL;
-#ifdef DEB
+#ifdef OCCT_DEBUG
StNbLect=StNbEcr=StNbMax=StNbMoy=StNbMoyNonNul=0;
#endif
}
//-- ============================================================
void SetDim(const Standard_Integer n) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout<<"\n@#@#@#@#@# SetDim "<<n<<endl;
#endif
if(UV)
Destroy();
-#ifdef DEB
+#ifdef OCCT_DEBUG
StNbLect=StNbEcr=StNbMax=StNbMoy=0;
#endif
N=n;
}
//-- ============================================================
void Destroy() {
-#ifdef DEB
+#ifdef OCCT_DEBUG
if(N) {
Standard_Integer nnn=0;
StNbMoy=StNbMoyNonNul=0;
free(IndUV[i]);
IndUV[i]=NULL;
}
- else { cout<<" IndUV ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; }
-
+#ifdef OCCT_DEBUG
+ else
+ cout<<" IndUV ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
+#endif
}
for(i=0;i<N;i++) {
if(UV[i]) {
free(UV[i]);
UV[i]=NULL;
}
+#ifdef OCCT_DEBUG
else { cout<<" UV ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; }
+#endif
}
- if(nbUV) { free(nbUV); nbUV=NULL; } else { cout<<" nbUV ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; }
- if(IndUV) { free(IndUV); IndUV=NULL;} else { cout<<" IndUV ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; }
- if(UV) { free(UV); UV=NULL; } else { cout<<" UV ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; }
+ if(nbUV) { free(nbUV); nbUV=NULL; }
+ if(IndUV) { free(IndUV); IndUV=NULL;}
+ if(UV) { free(UV); UV=NULL; }
N=0;
}
}
//-- ============================================================
void Set(Standard_Integer i0,Standard_Integer j0,const Standard_Real u) {
i0--; j0--;
-#ifdef DEB
+#ifdef OCCT_DEBUG
StNbEcr++;
#endif
Standard_Integer k=-1;
//-- ============================================================
Standard_Real Get(Standard_Integer i0,Standard_Integer j0) {
i0--; j0--;
-#ifdef DEB
+#ifdef OCCT_DEBUG
StNbLect++;
#endif
}
}
};
-
-
-
+
//-- ================================================================================
-//=======================================================================
-//function : FindInList
-//purpose :
-//=======================================================================
-// Unused :
-#ifdef DEB
-static Standard_Boolean FindInList (const TColStd_ListOfInteger& L,
- const Standard_Integer V)
-{
- for (TColStd_ListIteratorOfListOfInteger ILV(L);
- ILV.More();
- ILV.Next()) {
- if (V == ILV.Value())
- return Standard_True;
- }
- return Standard_False;
-}
-#endif
-
//=======================================================================
//function : AdjustParameter
//purpose :
const Standard_Integer de,
const Standard_Integer df)
{
-#ifdef DEB
- Standard_Integer n1vert =
-#endif
- DS->NbVertices();
Standard_Integer n1edge = DS->NbEdges();
Standard_Integer n1face = DS->NbFaces();
Standard_Boolean withOutL = Standard_False;
for (myFaceItr1.InitEdge(*fd);
- myFaceItr1.MoreEdge() && !cut && !withOutL;
+ myFaceItr1.MoreEdge();
myFaceItr1.NextEdge()) {
if (myFaceItr1.Internal()) {
withOutL = Standard_True;
myFEOutLine = myFaceItr1.OutLine ();
myFEInternal = myFaceItr1.Internal ();
myFEDouble = myFaceItr1.Double ();
- HLRBRep_EdgeData* ed = &(myEData(myFE));
+ HLRBRep_EdgeData* EDataFE1 = &(myEData(myFE));
if (!myFEDouble &&
(myFEOri == TopAbs_FORWARD ||
myFEOri == TopAbs_REVERSED)) {
- myFEGeom = &(ed->ChangeGeometry());
- const HLRBRep_Curve& EC = ed->Geometry();
+ myFEGeom = &(EDataFE1->ChangeGeometry());
+ const HLRBRep_Curve& EC = EDataFE1->Geometry();
p = EC.Parameter3d((EC.LastParameter () +
EC.FirstParameter()) / 2);
if (HLRBRep_EdgeFaceTool::UVPoint(p,myFEGeom,iFaceGeom,pu,pv)) {
mySLProps.SetParameters(pu,pv);
gp_Pnt Pt;
Pt = EC.Value3D(p);
-#ifdef OCC191
if (mySLProps.IsNormalDefined())
-#endif
{
gp_Vec Nm = mySLProps.Normal();
Pt.Transform(T);
myFaceItr1.MoreEdge();
myFaceItr1.NextEdge()) {
myFE = myFaceItr1.Edge();
- HLRBRep_EdgeData* ed = &(myEData(myFE));
- if (!fd->Simple()) ed->AutoIntersectionDone(Standard_False);
- HLRAlgo::DecodeMinMax(ed->MinMax(),
+ HLRBRep_EdgeData* EDataFE2 = &(myEData(myFE));
+ if (!fd->Simple()) EDataFE2->AutoIntersectionDone(Standard_False);
+ HLRAlgo::DecodeMinMax(EDataFE2->MinMax(),
(Standard_Address)EdgeMin,
(Standard_Address)EdgeMax);
if (myFaceItr1.BeginningOfWire())
if (myFEOri == TopAbs_FORWARD ||
myFEOri == TopAbs_REVERSED) {
// Edge from the boundary
- if (!((HLRBRep_EdgeData*)myFEData)->Vertical() && !myFEDouble) {
+ if (!((HLRBRep_EdgeData*)myFEData)->Vertical() && !(myFEDouble && !myFEOutLine)) {
// not a vertical edge and not a double Edge
Standard_Address MinMaxFEdg = ((HLRBRep_EdgeData*)myFEData)->MinMax();
//-- -----------------------------------------------------------------------
}
else {
myNbPoints = myNbSegments = 0;
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "HLRBRep_Data::NextInterference : ";
if (myLE == myFE)
cout << "Edge " << myLE
//=======================================================================
void HLRBRep_Data::EdgeState (const Standard_Real p1,
- const Standard_Real p2,
- TopAbs_State& stbef,
- TopAbs_State& staft)
+ const Standard_Real p2,
+ TopAbs_State& stbef,
+ TopAbs_State& staft)
{
// compute the state of The Edge near the Intersection
// this method should give the states before and after
// it should get the parameters on the surface
-
- gp_Pnt Pbid;
- gp_Vec TngEdge;
- ((HLRBRep_Curve*)myLEGeom)->D1(p1,Pbid,TngEdge);
+
Standard_Real pu,pv;
- if (HLRBRep_EdgeFaceTool::UVPoint(p2,myFEGeom,iFaceGeom,pu,pv)) {
+ if (HLRBRep_EdgeFaceTool::UVPoint(p2,myFEGeom,iFaceGeom,pu,pv))
+ {
mySLProps.SetParameters(pu,pv);
- gp_Dir NrmFace = mySLProps.Normal();
- const gp_Trsf& TI = myProj.InvertedTransformation();
- gp_Dir V;
- if (myProj.Perspective()) {
- gp_Pnt2d P2d;
- myProj.Project(Pbid,P2d);
- V = gp_Dir(P2d.X(),P2d.Y(),-myProj.Focus());
+ if (mySLProps.IsNormalDefined())
+ {
+ gp_Dir NrmFace = mySLProps.Normal();
+
+ gp_Pnt Pbid;
+ gp_Vec TngEdge;
+ ((HLRBRep_Curve*)myLEGeom)->D1(p1,Pbid,TngEdge);
+
+ const gp_Trsf& TI = myProj.InvertedTransformation();
+ gp_Dir V;
+ if (myProj.Perspective()) {
+ gp_Pnt2d P2d;
+ myProj.Project(Pbid,P2d);
+ V = gp_Dir(P2d.X(),P2d.Y(),-myProj.Focus());
+ }
+ else {
+ V = gp_Dir(0,0,-1);
+ }
+ V.Transform(TI);
+ if (NrmFace.Dot(V) > 0.)
+ NrmFace.Reverse();
+
+ const Standard_Real scal = (TngEdge.SquareMagnitude()>1.e-10)? NrmFace.Dot(gp_Dir(TngEdge)) : 0.;
+
+ if (scal > myToler*10) {stbef = TopAbs_IN ;staft = TopAbs_OUT;}
+ else if (scal < -myToler*10) {stbef = TopAbs_OUT;staft = TopAbs_IN ;}
+ else {stbef = TopAbs_ON ;staft = TopAbs_ON ;}
}
else {
- V = gp_Dir(0,0,-1);
+ stbef = TopAbs_OUT;
+ staft = TopAbs_OUT;
+#ifdef OCCT_DEBUG
+ cout << "HLRBRep_Data::EdgeState : undefined" << endl;
+#endif
}
- V.Transform(TI);
- if (NrmFace.Dot(V) > 0)
- NrmFace.Reverse();
-
- Standard_Real scal;
- if(TngEdge.SquareMagnitude()>1e-10)
- scal=NrmFace.Dot(gp_Dir(TngEdge));
- else scal=0.0;
-
- if (scal > myToler*10) {stbef = TopAbs_IN ;staft = TopAbs_OUT;}
- else if (scal < -myToler*10) {stbef = TopAbs_OUT;staft = TopAbs_IN ;}
- else {stbef = TopAbs_ON ;staft = TopAbs_ON ;}
}
else {
stbef = TopAbs_OUT;
staft = TopAbs_OUT;
-#ifdef DEB
- cout << "HLRBRep_Data::EdgeState : undefined" << endl;
+#ifdef OCCT_DEBUG
+ cout << "HLRBRep_Data::EdgeState : undefined" << endl;
#endif
}
}
Loop = Standard_False;
else {
if (Abs(param-sta) > Abs(param-end))
- end = param;
+ end = param;
else
- sta = param;
+ sta = param;
}
It.Next();
}
- param = (sta + end) / 2;
-#ifndef DEB
+ param = 0.5 * (sta + end);
Standard_Integer level = 0;
-#else
- Standard_Integer level;
-#endif
-#ifdef DEB
- TopAbs_State st =
-#endif
- Classify(E,ED,Standard_True,level,param);
+ /*TopAbs_State st = */Classify(E,ED,Standard_True,level,param);
Loop = Standard_True;
It.Initialize(IL);
switch (Int.Transition()) {
case TopAbs_FORWARD :
- level = level - Int.Intersection().Level();
- break;
+ level -= Int.Intersection().Level();
+ break;
case TopAbs_REVERSED :
- level = level + Int.Intersection().Level();
- break;
+ level += Int.Intersection().Level();
+ break;
case TopAbs_EXTERNAL :
case TopAbs_INTERNAL :
- default :
- break;
+ default :
+ break;
}
}
else if (p > param + tolpar)
Loop = Standard_False;
else {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "HLRBRep_Data::HidingStartLevel : ";
cout << "Bad Parameter." << endl;
#endif
//=======================================================================
TopAbs_State HLRBRep_Data::Compare (const Standard_Integer E,
- const HLRBRep_EdgeData& ED)
+ const HLRBRep_EdgeData& ED)
{
- Standard_Integer level;
- Standard_Real parbid = 0;
+ Standard_Integer level = 0;
+ Standard_Real parbid = 0.;
return Classify(E,ED,Standard_False,level,parbid);
}
//purpose :
//=======================================================================
-Standard_Boolean
-HLRBRep_Data::OrientOutLine (const Standard_Integer I,
- HLRBRep_FaceData& FD)
+
+Standard_Boolean HLRBRep_Data::OrientOutLine (const Standard_Integer I, HLRBRep_FaceData& FD)
{
+ (void)I; // avoid compiler warning
+
const Handle(HLRAlgo_WiresBlock)& wb = FD.Wires();
Standard_Integer nw = wb->NbWires();
Standard_Integer iw1,ie1,ne1;
(iFaceGeom,pu,pv,V);
gp_Vec Nm = mySLProps.Normal();
if (curv == 0) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "HLRBRep_Data::OrientOutLine " << I;
cout << " Edge " << myFE << " : ";
cout << "CurvatureValue == 0." << endl;
Nm.Transform(T);
Nm.Cross(Tg);
if (Tg.Magnitude() < gp::Resolution()) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "HLRBRep_Data::OrientOutLine " << I;
cout << " Edge " << myFE << " : ";
cout << "Tg.Magnitude() == 0." << endl;
eb1->Orientation(ie1,myFEOri);
}
else {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "HLRBRep_Data::OrientOutLine " << I;
cout << " Edge " << myFE << " : ";
cout << "UVPoint not found, OutLine not Oriented" << endl;
eb1->Orientation(ie1,myFEOri);
}
}
+#ifdef OCCT_DEBUG
else {
cout << "HLRBRep_Data::OrientOthEdge " << I;
cout << " Edge " << myFE << " : ";
cout << "UVPoint not found, Edge not Oriented" << endl;
}
+#else
+ (void)I; // avoid compiler warning
+#endif
}
}
}
Standard_Integer& Level,
const Standard_Real param)
{
+ (void)E; // avoid compiler warning
+
nbClassification++;
Standard_Integer VertMin[16],VertMax[16],MinMaxVert[16];
Standard_Real TotMin[16],TotMax[16];
HLRAlgo::EncodeMinMax((Standard_Address)VertMin,
(Standard_Address)VertMax,
(Standard_Address)MinMaxVert);
-
-
-
-#if 0
+ /*
+#ifdef OCCT_DEBUG
{
Standard_Integer qwe,qwep8,q,q1,q2;
printf("\n E:%d -------\n",E);
cout<<endl;
}
#endif
-
-
-
+ */
if (((MaxFace1 - MinVert1) & 0x80008000) != 0 ||
((MaxVert1 - MinFace1) & 0x80008000) != 0 ||
do {
gp_Pnt2d pnt2d(u,v);
- if (myClassifier->Classify(pnt2d,0.0)!=TopAbs_OUT) {
+ if (myClassifier->Classify(pnt2d,Precision::PConfusion())
+ != TopAbs_OUT)
+ {
InsideRestriction = Standard_True;
state = TopAbs_IN;
Level++;
//purpose :
//=======================================================================
-TopAbs_State HLRBRep_Data::SimplClassify (const Standard_Integer E,
+TopAbs_State HLRBRep_Data::SimplClassify (const Standard_Integer /*E*/,
const HLRBRep_EdgeData& ED,
const Standard_Integer Nbp,
const Standard_Real p1,
Standard_Real p1,p2,dz;
Standard_ShortReal t1,t2;
TopAbs_State st;
-#ifndef DEB
TopAbs_Orientation Orie =TopAbs_FORWARD ;
-#else
- TopAbs_Orientation Orie ;
-#endif
TopAbs_Orientation Or2 = TopAbs_INTERNAL;
Standard_Boolean inverted = Standard_False;
const IntRes2d_Transition* Tr1;
}
if (iFaceBack) Orie = TopAbs::Complement(Orie); // change the transition
-#ifndef DEB
TopAbs_Orientation Ori = TopAbs_FORWARD;
-#else
- TopAbs_Orientation Ori;
-#endif
switch (Tr1->PositionOnCurve()) {
case IntRes2d_Head : Ori = TopAbs_FORWARD ; break;
case IntRes2d_Middle : Ori = TopAbs_INTERNAL; break;
}
return SameV;
}
-