CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GiUtils.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
25#ifndef __OD_GI_UTILS__
26#define __OD_GI_UTILS__
27
28#include "UInt32Array.h"
29#include "Ge/GeVector3d.h"
30#include "BoolArray.h"
31
32template <class T3dPtIter>
33void odgiSquareValues(OdInt32 nPoints, T3dPtIter pPoints, OdGeVector3d& n1, OdGeVector3d& n2)
34{
35 OdGeVector3d res;
36 nPoints -= 2;
38 for(T3dPtIter pPt1 = pPoints + 1, pPt2 = pPoints + 2; nPoints-- > 0; ++pPt1, ++pPt2)
39 {
40 res = (*pPt2 - *pPoints).crossProduct(*pPt1 - *pPoints);
41 if(res.dotProduct(n1) >= 0.)
42 n1 += res;
43 else
44 n2 += res;
45 }
46}
47
48template <class T3dPtIter>
49OdGeVector3d odgiFaceNormal(OdInt32 nPoints, T3dPtIter pPoints)
50{
51 OdGeVector3d n1, n2;
52 odgiSquareValues(nPoints, pPoints, n1, n2);
53 n1 += n2;
56 if(f!=OdGe::kOk)
58 return n1;
59}
60
61// IN: triangleIndicies - array of triangle indices. should look as follows: 3, 1-st point index, 2-nd point index, 3-d point index, etc.
62// OUT: loops - array of loops; each loop is array of indicies of points that describe continious loop of the shell (shells) described by triangle mesh in triangleIndicies
63// OUT: isClosed - bool array that describes whether corresponding loop is closed or not
64// RET: bool - returns false if failed to generate any loop
66
67#endif // __OD_GI_UTILS__
bool OD_TOOLKIT_EXPORT odgiCalculateTriangleShellLoops(const OdUInt32Array &triangleIndicies, OdArray< OdUInt32Array > &loops, OdBoolArray *isClosed=NULL)
void odgiSquareValues(OdInt32 nPoints, T3dPtIter pPoints, OdGeVector3d &n1, OdGeVector3d &n2)
Definition: GiUtils.h:33
OdGeVector3d odgiFaceNormal(OdInt32 nPoints, T3dPtIter pPoints)
Definition: GiUtils.h:49
#define OD_TOOLKIT_EXPORT
int OdInt32
static GE_STATIC_EXPORT const OdGeVector3d kIdentity
Definition: GeVector3d.h:100
double dotProduct(const OdGeVector3d &vect) const
Definition: GeVector3d.h:586
OdGeVector3d & normalize(const OdGeTol &tol=OdGeContext::gTol)
GLfloat f
Definition: gles2_ext.h:564
static GE_STATIC_EXPORT OdGeTol gZeroTol
Definition: GeGbl.h:72
ErrorCondition
Definition: Ge.h:413
@ kOk
Definition: Ge.h:415