CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GiPlineContour.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24#ifndef __ODGIPLINECONTOUR_H__
25#define __ODGIPLINECONTOUR_H__
26
28#include "Gi/GiPathNode.h"
29#define STL_USING_SET
30#include "OdaSTL.h"
31
32#include "TD_PackPush.h"
33
42 void pline(const OdGiPolyline & /*polyline*/, OdUInt32 /*fromIndex*/ = 0, OdUInt32 /*numSegs*/ = 0) {}
43};
44
50{
58 virtual void plineCalcShellWires(OdInt32 faceListSize, const OdInt32 *faceList,
59 const OdGiEdgeData *pEdgeData = 0, const OdGiFaceData *pFaceData = 0) = 0;
64 virtual void dropPlineCalcShellWires(bool bStrips) = 0;
65};
66
71template <typename SimplClass = OdGiGeometrySimplifier>
73{
74 OdGiPlineContourCalcSimplifierInterface *m_pPlineCtrCalcInterface;
75 protected:
80 void setPlineCalcInterface(OdGiPlineContourCalcSimplifierInterface *pInterface) { m_pPlineCtrCalcInterface = pInterface; }
88 virtual void generateShellWires(OdInt32 faceListSize, const OdInt32 *faceList,
89 const OdGiEdgeData *pEdgeData = 0, const OdGiFaceData *pFaceData = 0)
90 {
91 m_pPlineCtrCalcInterface->plineCalcShellWires(faceListSize, faceList, pEdgeData, pFaceData);
92 }
100 void plineCalcRedirectGenerateShellWires(OdInt32 faceListSize, const OdInt32 *faceList,
101 const OdGiEdgeData *pEdgeData, const OdGiFaceData *pFaceData)
102 {
103 SimplClass::generateShellWires(faceListSize, faceList, pEdgeData, pFaceData);
104 }
109};
110
116{
117 OdGiGeometrySimplifier *m_pPlineCtrCalcSimplifier;
118 public:
119 OdGiPlineContourCalcNonSimplifierInheritance() : m_pPlineCtrCalcSimplifier(NULL) {}
120 protected:
129 void setPlineCalcSimplifier(OdGiGeometrySimplifier *pSimplifier) { m_pPlineCtrCalcSimplifier = pSimplifier; }
137 void plineCalcRedirectGenerateShellWires(OdInt32 faceListSize, const OdInt32 *faceList,
138 const OdGiEdgeData *pEdgeData, const OdGiFaceData *pFaceData)
139 {
140 m_pPlineCtrCalcSimplifier->generateShellWires(faceListSize, faceList, pEdgeData, pFaceData);
141 }
145 OdGiGeometrySimplifier *plineCalcSimplifier() { return m_pPlineCtrCalcSimplifier; }
146};
147
152template <typename VectClass = OdGiPlineContourCalcEmptyInheritance, typename SimplClass = OdGiPlineContourCalcNonSimplifierInheritance>
153class OdGiPlineContourCalc : public VectClass, public SimplClass, public OdGiPlineContourCalcSimplifierInterface
154{
155 protected:
157 {
162 kPlineCtrCalcPlDrop = (1 << 4)
163 };
164 protected:
166 typedef std::pair<OdGePoint3d, OdGePoint3d> EdgePointsPair;
167 typedef std::pair<OdInt32, OdInt32> EdgePointsKey;
168 class PlineCtrCalcNode : public std::pair<OdGePoint3d, OdGePoint3d>
169 {
170 OdGsMarker m_gsMarker;
171 static inline int cmp_el(double d1, double d2, const OdGeTol &tol = OdGeContext::gTol)
172 {
173 if (OdLess(d1, d2, tol.equalPoint()))
174 return 1;
175 if (OdGreater(d1, d2, tol.equalPoint()))
176 return 0;
177 return -1;
178 }
179 public:
180 PlineCtrCalcNode(const OdGePoint3d &pt1, const OdGePoint3d &pt2, OdGsMarker gsMarker)
181 : std::pair<OdGePoint3d, OdGePoint3d>(pt1, pt2), m_gsMarker(gsMarker)
182 {}
183 OdGsMarker subentMarker() const { return m_gsMarker; }
184
185 bool operator <(const PlineCtrCalcNode &p2) const
186 { int
187 rv = cmp_el(first.x, p2.first.x); if (rv >= 0) return rv > 0;
188 rv = cmp_el(first.y, p2.first.y); if (rv >= 0) return rv > 0;
189 rv = cmp_el(first.z, p2.first.z); if (rv >= 0) return rv > 0;
190 rv = cmp_el(second.x, p2.second.x); if (rv >= 0) return rv > 0;
191 rv = cmp_el(second.y, p2.second.y); if (rv >= 0) return rv > 0;
192 return OdLess(second.z, p2.second.z, OdGeContext::gTol.equalPoint());
193 }
194 };
195 typedef std::set<PlineCtrCalcNode> PlineCtrCalcMap;
198 protected:
199 void filterPlineCalcMap(const OdGePoint3d &p1, const OdGePoint3d &p2, OdGsMarker gsMarker)
200 { OD_TYPENAME PlineCtrCalcMap::iterator it = m_plineCtrCalcMap.find(PlineCtrCalcNode(p2, p1, gsMarker));
201 //if (it == m_plineCtrCalcMap.end()) // #CORE-17334 : can eliminate overlapped segments contour
202 // it = m_plineCtrCalcMap.find(PlineCtrCalcNode(p1, p2, gsMarker));
203 if (it == m_plineCtrCalcMap.end())
204 m_plineCtrCalcMap.insert(PlineCtrCalcNode(p1, p2, gsMarker));
205 else // Remove duplicate edge
206 m_plineCtrCalcMap.erase(it);
207 }
209 { bool bFirst = false;
210 OD_TYPENAME PlineCtrCalcMap::iterator curPair = m_plineCtrCalcMap.begin();
211 const OdGsMarker gsMarker = curPair->subentMarker();
212 m_plineCtrCalcStrip.push_back(curPair->first);
213 m_plineCtrCalcStrip.push_back(curPair->second);
214 for (;;)
215 { OD_TYPENAME PlineCtrCalcMap::iterator it = m_plineCtrCalcMap.begin();
216 for (; it != m_plineCtrCalcMap.end(); it++)
217 {
218 if (it == curPair)
219 continue;
220 bool bSecond = false;
221 if ((bFirst) ? (it->first == curPair->first) : (it->first == curPair->second))
222 { m_plineCtrCalcMap.erase(curPair); curPair = it; bFirst = false;
223 if (it->subentMarker() == gsMarker)
224 { m_plineCtrCalcStrip.push_back(it->second);
225 break; }
226 return gsMarker;
227 }
228 else if ((bFirst) ? (it->second == curPair->first) : (it->second == curPair->second))
229 { m_plineCtrCalcMap.erase(curPair); curPair = it; bFirst = true;
230 if (it->subentMarker() == gsMarker)
231 { m_plineCtrCalcStrip.push_back(it->first);
232 break; }
233 return gsMarker;
234 }
235 }
236 if (it == m_plineCtrCalcMap.end())
237 {
238 m_plineCtrCalcMap.erase(curPair);
239 break;
240 }
241 }
242 return gsMarker;
243 }
244 public:
246 { this->setPlineCalcInterface(this); }
247
253
258
263 {
265 {
267 }
268 }
273 {
275 {
276 if (!m_plineCtrCalcMap.empty())
278 }
280 }
281
288 virtual void pline(const OdGiPolyline &polyline, OdUInt32 fromIndex = 0, OdUInt32 numSegs = 0)
289 {
291 VectClass::pline(polyline, fromIndex, numSegs);
293 }
294
298 bool hasPlineStarted() const
299 {
301 }
302
310 virtual void plineCalcShellWires(OdInt32 faceListSize, const OdInt32* faceList,
311 const OdGiEdgeData* pEdgeData = 0, const OdGiFaceData* pFaceData = 0)
312 { OdGiGeometrySimplifier *pSimplifier;
313 if (hasPlineStarted() && !GETBIT((pSimplifier = this->plineCalcSimplifier())->drawContext()->subEntityTraits().drawFlags(), OdGiSubEntityTraits::kDrawPolygonFill))
314 { const OdGsMarker gsMarker = pSimplifier->drawContext()->currentGiPath()->selectionMarker();
315 const OdGePoint3d* pVtx = pSimplifier->vertexDataList();
316 const OdUInt8 *pEdgeVis = pEdgeData ? pEdgeData->visibility() : NULL;
317 for (OdInt32 nFaceList = 0; nFaceList < faceListSize; nFaceList++)
318 { const OdInt32 nElems = Od_abs(faceList[nFaceList]);
319 for (OdInt32 nSeg = 1; nSeg < nElems; nSeg++)
320 { if (!pEdgeVis || *pEdgeVis++)
321 filterPlineCalcMap(pVtx[faceList[nFaceList + nSeg]], pVtx[faceList[nFaceList + nSeg + 1]], gsMarker);
322 }
323 if (!pEdgeVis || *pEdgeVis++)
324 filterPlineCalcMap(pVtx[faceList[nFaceList + nElems]], pVtx[faceList[nFaceList + 1]], gsMarker);
325 nFaceList += nElems;
326 }
328 }
329 else
330 this->plineCalcRedirectGenerateShellWires(faceListSize, faceList, pEdgeData, pFaceData);
331 }
332
337 void enablePlineCalcSrips(bool bSet)
338 {
340 }
341
346 {
348 }
349
354 {
356 }
357
362 virtual void dropPlineCalcShellWires(bool bStrips)
363 { OdGiGeometrySimplifier *pSimplifier = this->plineCalcSimplifier();
364 OdGsMarker curMarker = pSimplifier->drawContext()->currentGiPath()->selectionMarker();
365 const bool bUpdateMarkers = GETBIT(pSimplifier->drawContext()->drawContextFlags(), OdGiConveyorContext::kForceMarkersOnModified);
367 if (!bStrips)
368 { OdGePoint3d outPts[2];
369 for (OD_TYPENAME PlineCtrCalcMap::iterator it = m_plineCtrCalcMap.begin(); it != m_plineCtrCalcMap.end(); it++)
370 { outPts[0] = it->first; outPts[1] = it->second;
371 if (curMarker != it->subentMarker())
372 { pSimplifier->drawContext()->subEntityTraits().setSelectionMarker(curMarker = it->subentMarker());
373 if (bUpdateMarkers)
374 pSimplifier->drawContext()->onTraitsModified();
375 }
376 pSimplifier->polylineOut(2, outPts);
377 }
378 }
379 else
380 {
381 while (!m_plineCtrCalcMap.empty())
382 { const OdGsMarker gsMarker = buildPlineCalcStrip();
383 if (curMarker != gsMarker)
384 { pSimplifier->drawContext()->subEntityTraits().setSelectionMarker(curMarker = gsMarker);
385 if (bUpdateMarkers)
386 pSimplifier->drawContext()->onTraitsModified();
387 }
390 }
391 }
393 }
394};
395
396#include "TD_PackPop.h"
397
398#endif //#ifndef __ODGIPLINECONTOUR_H__
tol
Definition: DimVarDefs.h:2287
#define Od_abs
Definition: OdPlatform.h:141
#define OD_TYPENAME
Definition: OdPlatform.h:631
ptrdiff_t OdGsMarker
unsigned int OdUInt32
int OdInt32
unsigned char OdUInt8
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:516
#define SETBIT_0(flags, bit)
Definition: OdaDefs.h:519
bool OdLess(double x, double y, double tol=1.e-10)
Definition: OdaDefs.h:547
bool OdGreater(double x, double y, double tol=1.e-10)
Definition: OdaDefs.h:557
#define GETBIT(flags, bit)
Definition: OdaDefs.h:517
#define SETBIT_1(flags, bit)
Definition: OdaDefs.h:520
void clear()
Definition: OdArray.h:1400
size_type size() const
Definition: OdArray.h:1247
void push_back(const T &value)
Definition: OdArray.h:1411
const T * getPtr() const
Definition: OdArray.h:1600
Definition: GeTol.h:49
double equalPoint() const
Definition: GeTol.h:76
virtual OdUInt32 drawContextFlags() const
virtual const OdGiPathNode * currentGiPath() const =0
virtual OdGiSubEntityTraits & subEntityTraits() const =0
virtual void onTraitsModified()=0
const OdGePoint3d * vertexDataList() const
virtual void generateShellWires(OdInt32 faceListSize, const OdInt32 *faceList, const OdGiEdgeData *pEdgeData=0, const OdGiFaceData *pFaceData=0)
virtual void polylineOut(OdInt32 numPoints, const OdGePoint3d *vertexList)
OdGiConveyorContext * drawContext()
virtual OdGsMarker selectionMarker() const =0
bool operator<(const PlineCtrCalcNode &p2) const
PlineCtrCalcNode(const OdGePoint3d &pt1, const OdGePoint3d &pt2, OdGsMarker gsMarker)
OdGePoint3dArray m_plineCtrCalcStrip
bool plineContoursCalcEnabled() const
void enablePlineContoursCalc(bool bSet)
std::pair< OdGePoint3d, OdGePoint3d > EdgePointsPair
virtual void dropPlineCalcShellWires(bool bStrips)
bool plineCalcDroppingState() const
void filterPlineCalcMap(const OdGePoint3d &p1, const OdGePoint3d &p2, OdGsMarker gsMarker)
PlineCtrCalcMap m_plineCtrCalcMap
std::pair< OdInt32, OdInt32 > EdgePointsKey
std::set< PlineCtrCalcNode > PlineCtrCalcMap
void enablePlineCalcSrips(bool bSet)
bool plineCalcStripsEnabled() const
virtual void plineCalcShellWires(OdInt32 faceListSize, const OdInt32 *faceList, const OdGiEdgeData *pEdgeData=0, const OdGiFaceData *pFaceData=0)
OdGsMarker buildPlineCalcStrip()
bool hasPlineStarted() const
virtual void pline(const OdGiPolyline &polyline, OdUInt32 fromIndex=0, OdUInt32 numSegs=0)
void setPlineCalcInterface(OdGiPlineContourCalcSimplifierInterface *)
void plineCalcRedirectGenerateShellWires(OdInt32 faceListSize, const OdInt32 *faceList, const OdGiEdgeData *pEdgeData, const OdGiFaceData *pFaceData)
void setPlineCalcSimplifier(OdGiGeometrySimplifier *pSimplifier)
OdGiGeometrySimplifier * plineCalcSimplifier()
OdGiGeometrySimplifier * plineCalcSimplifier()
void plineCalcRedirectGenerateShellWires(OdInt32 faceListSize, const OdInt32 *faceList, const OdGiEdgeData *pEdgeData, const OdGiFaceData *pFaceData)
virtual void generateShellWires(OdInt32 faceListSize, const OdInt32 *faceList, const OdGiEdgeData *pEdgeData=0, const OdGiFaceData *pFaceData=0)
void setPlineCalcInterface(OdGiPlineContourCalcSimplifierInterface *pInterface)
virtual void setSelectionMarker(OdGsMarker selectionMarker)=0
@ kDrawPolygonFill
Definition: Gi.h:120
static GE_STATIC_EXPORT OdGeTol gTol
Definition: GeGbl.h:65
void pline(const OdGiPolyline &, OdUInt32=0, OdUInt32=0)
virtual void plineCalcShellWires(OdInt32 faceListSize, const OdInt32 *faceList, const OdGiEdgeData *pEdgeData=0, const OdGiFaceData *pFaceData=0)=0
virtual void dropPlineCalcShellWires(bool bStrips)=0