Hide menu
Loading...
Searching...
No Matches
exploring/validationproperties/validationproperties.py

Refer to the Validation Properties Example.

1#!/usr/bin/env python3
2
3# $Id$
4
5# Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
6# Copyright (C) 2014-2023, CADEX. All rights reserved.
7
8# This file is part of the CAD Exchanger software.
9
10# You may use this file under the terms of the BSD license as follows:
11
12# Redistribution and use in source and binary forms, with or without
13# modification, are permitted provided that the following conditions are met:
14# * Redistributions of source code must retain the above copyright notice,
15# this list of conditions and the following disclaimer.
16# * Redistributions in binary form must reproduce the above copyright notice,
17# this list of conditions and the following disclaimer in the documentation
18# and/or other materials provided with the distribution.
19
20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30# POSSIBILITY OF SUCH DAMAGE.
31
32
33import sys
34from pathlib import Path
35import os
36
37
38import cadexchanger.CadExCore as cadex
39
40sys.path.append(os.path.abspath(os.path.dirname(Path(__file__).resolve()) + r"/../../"))
41import cadex_license as license
42
43
44def main():
45 aKey = license.Value()
46
47 if not cadex.LicenseManager.Activate(aKey):
48 print("Failed to activate CAD Exchanger license.")
49 return 1
50
53
54 # Compute Properties
56
58
59 aCentroid = cadex.ModelData_Point()
61
62 aBBox = cadex.ModelData_Box()
64
65 # Output properties
66 print(f"Surface area: {aSurfaceArea}")
67 print(f"Volume: {aVolume}")
68 print(f"Centroid: ({aCentroid.X()}, {aCentroid.Y()}, {aCentroid.Z()})")
69 print(f"Bounding Box: ({aBBox.XRange()}, {aBBox.YRange()}, {aBBox.ZRange()})")
70
71 print("Completed")
72 return 0
73
74if __name__ == "__main__":
75 sys.exit(main())
76
static void Compute(const ModelData_Model &theSG, ModelData_Box &theBox, bool theForcedFlush=true)
Returns a bounding box of a scene graph.
Definition: ModelAlgo_BoundingBox.cxx:346
static ModelData_Solid CreateCylinder(double theRadius, double theHeight, double theAngle=2 *M_PI)
Creates a cylinder.
Definition: ModelAlgo_TopoPrimitives.cxx:196
Computes validation properties of the objects.
Definition: ModelAlgo_ValidationProperty.hxx:35
static void ComputeCentroid(const ModelData_Model &theModel, ModelData_Point &theValue)
Returns a center of mass of a scene graph.
Definition: ModelAlgo_ValidationProperty.cxx:450
static double ComputeSurfaceArea(const ModelData_Model &theModel, bool theUseProperty=false, bool theStoreProperty=false)
Returns a surface area of a scene graph.
Definition: ModelAlgo_ValidationProperty.cxx:362
static double ComputeVolume(const ModelData_Model &theModel, bool theUseProperty=false, bool theStoreProperty=false)
Returns a volume of a scene graph.
Definition: ModelAlgo_ValidationProperty.cxx:402
Defines precise Boundary Representation of part.
Definition: ModelData_BRepRepresentation.hxx:39
Defines a 3D axis-aligned bounding box.
Definition: ModelData_Box.hxx:31
Defines a 3D point.
Definition: ModelData_Point.hxx:295